SuperAPI AI 工具集

aspnet-auth-advanced

安全与审计

查看项目

更新于 10-16 06:51

技能介绍

用途:为 ASP.NET Core 应用搭建高级认证与授权,涵盖 JWT、OAuth2/OIDC、Identity、多方案与策略授权。

主要能力:JWT 签发与校验(含 ClockSkew 收紧)、刷新令牌轮换与重用检测;Google/Microsoft/Azure AD 等外部 IdP 登录;ASP.NET Core Identity 脚手架与 IdentityUser 定制;JWT 用于 /api、Cookie 用于 /admin 的多方案选择;基于角色、声明、策略及资源(用户自有资源)的授权;SPA + Cookie 认证的防伪令牌;并列出常见反模式与检查清单。

使用方式:通过 dotnet add package 安装 Microsoft.AspNetCore.Authentication.Google、MicrosoftAccount、OpenIdConnect、Microsoft.AspNetCore.Identity.EntityFrameworkCore 等包;用 AddAuthentication/AddJwtBearer/AddCookie/AddGoogle/AddOpenIdConnect 配置;Identity 可用 dotnet aspnet-codegenerator identity -dc AppDbContext --files "Account.Login;Account.Register" 脚手架 UI。

适用场景:需要 API 与 Web 混合认证、外部登录、细粒度授权或从旧 Membership/IdentityServer 迁移的项目。

限制:资料未提供具体版本要求、性能数据、收费信息与完整部署步骤;示例密钥与配置需自行替换并妥善保管。