Asgard 框架总览与路由 skill。Use when working with the Asgard framework but the request spans multiple modules, the correct entry point is unclear, or another AI needs a high-level map before choosing host, configuration, api, plugin, context, lifecycle, repository, or infrastructure skills.
../../doc/01-框架概览.md、../../doc/02-快速开始.md、../../doc/09-源码参考索引.md。YggdrasilHost.CreateBuilder(...)、PluginWebAppDefaults.RunAsync<TPlugin>()、UseBuiltInPlugin<TPlugin>()、BaseController、AbsAsgardContext。UseAuthorization();只有完全自定义或旁路默认链路时,才需要显式补齐认证授权中间件。Asgard 当前更推荐:
补充判断:
Program.cs 放进插件主体项目| 能力 | 默认责任方 | 关键结论 |
|---|---|---|
启动入口 Program.cs | starter / host 项目 | 默认承载 PluginWebAppDefaults.RunAsync<TPlugin>() 或 YggdrasilHost.CreateBuilder(...) |
插件入口类 PluginBase | 插件主体项目 | 负责插件元数据、服务装配与生命周期 |
plugin.yaml | 插件主体项目 | 插件清单与插件级元数据 |
app.yaml | starter / host 项目 | 运行配置入口;也可由插件项目输出资源承载,但应明确由启动方加载 |
| 认证主体构建(host.auth / 插件自定义) | 宿主 host.auth 或插件/外部方案 | host.auth.enabled: true 时宿主管默认 JWT;false 时可由插件/外部方案接管 |
| 身份快照建立(UseAsgardTenant + IdentityContext) | Asgard 上下文与租户中间件链路 | 业务统一从 AsgardContext.IdentityContext 读取身份,不建议自行解析 claim |
| 授权执行(UseAuthorization + AsgardAuth policy) | Asgard 授权策略 + ASP.NET Core 授权中间件 | AsgardAuth policy 由框架注册,Yggdrasil 默认链路统一执行 UseAuthorization() |
$asgard-host-project。$asgard-plugin-structure。app.yaml、plugin.yaml、ConfigPath:使用 $asgard-configuration。host.staticFiles、host.auth、host.swagger、限流、健康检查:使用 $asgard-host-features。$asgard-api-development。AsgardAuth、授权 DSL、token_type / 角色 / 权限 / metadata 授权:使用 $asgard-auth-authorization。$asgard-plugin-development。$asgard-plugin-lifecycle。AbsAsgardContext 与公共能力获取:使用 $asgard-context-usage。AsgardContext.Trace:使用 $asgard-tracing-observability。AbsAsgardUserInfo、IAsgardIdentityContext、IDP claim 设计、测试身份构造:使用 $asgard-identity-userinfo。$asgard-base-types。$asgard-repository-service-registration。$asgard-cache、$asgard-database、$asgard-messaging、$asgard-job-scheduling、$asgard-security。AbsAsgardContext 获取;确实需要更底层控制时再注入具体接口。app.yaml,插件主体维护 plugin.yaml。$asgard-dotnet-10-csharp-14 一致的仓库级规则。以下锚点用于总览问题快速落到真实实现:
Common/Asgard.AspNetCore.Core/ServiceCollectionExtensions.cs - AddAsgardAspNetCore() 与 AsgardAuth policy 注册Host/Asgard.Yggdrasil.AspNetCore/YggdrasilHostBuilder.Services.cs - host.auth.enabled 与默认 JWT 服务注册Host/Asgard.Yggdrasil.AspNetCore/YggdrasilHostBuilder.Configurator.cs - 默认中间件顺序与 UseAuthorization()Common/Asgard.Abstractions.AspNetCore/Authorization/AsgardAuthAttributes.cs - 授权特性与策略绑定Common/Asgard.Abstractions.AspNetCore/Host/AuthOptions.cs - 认证配置语义