What this thread does
Do first: register AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(...) for JWT access tokens and require authorization on the protected endpoints.
Short answer
As of November 2026, this recipe retains ASP.NET Core 10.0 (release notes). Validate the credential before applying roles and claims. Identity's proprietary bearer token is a different format; a token being readable as JSON does not establish its validity.
Choose / don't choose
- Browser Identity login: choose cookies with
POST /login?useCookies=true; retain a persistent store and CSRF protection. Register AddIdentityApiEndpoints, EF stores andMapIdentityApi(activation). - Simple Identity token client: choose the proprietary token plus refresh endpoint when that contract fits; don't pass it to JWT bearer validation (token path).
- External JWT issuer: choose
AddJwtBearerwith the issuer's metadata and signing keys; don't accept ID tokens as API access tokens (basic validation). - Named policy: choose for an action requiring both a role and a claim; a role list handles simple role alternatives. Chain
RequireRole("Admin")andRequireClaim("EmployeeNumber")in one policy; names are examples (roles, claims).
Not for: JWT-versus-session architecture across frameworks; see jwt-or-database-session-cookie-for-my-app-and-how-logout-works.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
Authority, Audience | Trusted issuer HTTPS authority and this API's expected audience, from server configuration | Current JWT bearer docs | validation |
TokenValidationParameters.ValidateIssuer, ValidIssuers | true and an explicit trusted issuer allowlist when configuring directly | Current JWT bearer docs | validation |
ValidateAudience, ValidAudiences | true and the API's accepted audience list | Current JWT bearer docs | validation |
ValidateIssuerSigningKey, IssuerSigningKey | Enable key validation; explicitly configure the trusted signing key when configuring directly | Current API; never trust a key merely carried by an incoming token | parameters source |
ValidateLifetime, RequireExpirationTime, ClockSkew | ValidateLifetime = true; RequireExpirationTime = true; current parameter source defaults skew to 300 seconds, so select an explicit clock allowance | Current parameter contract | source |
MapInboundClaims, RoleClaimType | false preserves JSON names; set role type to the actual issuer claim, e.g. "role" | Current claims mapping | bearer, mapping |
Order of operations
1. Register authentication and authorization services before building the app. Protect controllers with [Authorize] or endpoints with RequireAuthorization (Minimal API policies). 2. In an explicitly ordered pipeline use routing, CORS if applicable, UseAuthentication(), UseAuthorization(), then endpoint execution. Call UseAuthentication() before UseAuthorization() (middleware). 3. Attach the named policy to the action. Require both its role and claim; compare case and the post-mapping claim type. Include ownership separately where needed. 4. Exercise missing, expired, wrong-issuer, wrong-audience and bad-signature credentials. Known cookie-protected API endpoints also return 401/403 instead of login redirects on this release (cookie change).
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
| HTTP 401 | The provided access token doesn't meet the required standards | Inspect issuer, audience, lifetime and signing-key selection; use an access token for the configured handler | JWT guide |
| Roles are missing | Role claim type differs from the returned claims | Inspect authenticated principal's claim types; align RoleClaimType, mapping, policy spelling and required claims | mapping |
Diagnostic: role present but forbidden
Use server-side principal inspection without logging tokens. Confirm what the handler actually produced. augustevn's November 16, 2023 report concerns claims absent from /manage/info; that profile response is not the authenticated principal's authorization contract.
Missing
- Issuer, audience, role vocabulary and clock tolerance are deployment inputs. Multiple handlers require explicit scheme selection beyond these single-handler examples.
Checked
2026-11-12; ASP.NET Core 10.0 (release notes); linked Microsoft docs, current parameter source and augustevn report read. No API commands executed.
Started from a post by @Microsoft, packaged by the editor. Original post