You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Update token-based authentication section
Clarify token usage details and expiration settings for access and refresh tokens.
* Update links to BearerTokenOptions properties
* Document SignOut handling and security stamp validation
Added section on SignOut handling and security stamp validation.
* Fix BearerTokenOptions reference in identity API docs
Updated the reference for BearerTokenOptions to correct property for token expiration.
* Apply suggestions from code review
Co-authored-by: Wade Pickett <wpickett@microsoft.com>
* Change publication date to March 23, 2026
Update the date for the identity API authorization document.
---------
Co-authored-by: Wade Pickett <wpickett@microsoft.com>
Copy file name to clipboardExpand all lines: aspnetcore/security/authentication/identity-api-authorization.md
+17-2Lines changed: 17 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ author: tdykstra
4
4
description: Learn how to use Identity to secure a Web API backend for single page applications (SPAs).
5
5
monikerRange: '>= aspnetcore-3.0'
6
6
ms.author: tdykstra
7
-
ms.date: 05/01/2024
7
+
ms.date: 03/23/2026
8
8
uid: security/authentication/identity/spa
9
9
---
10
10
# How to use Identity to secure a Web API backend for SPAs
@@ -204,7 +204,7 @@ Some web clients might not include cookies in the header by default:
204
204
205
205
We recommend using cookies in browser-based applications, because, by default, the browser automatically handles them without exposing them to JavaScript.
206
206
207
-
A custom token (one that is proprietary to the ASP.NET Core identity platform) is issued that can be used to authenticate subsequent requests. The token is passed in the `Authorization` header as a bearer token. A refresh token is also provided. This token allows the application to request a new token when the old one expires without forcing the user to log in again.
207
+
A custom token (one that is proprietary to the ASP.NET Core identity platform) is issued that can be used to authenticate subsequent requests. The short-lived access token is passed in the `Authorization` header as a bearer token. A longer-lived refresh token is also provided. This refresh token allows the application to request a new access token when the old one expires without forcing the user to log in again.
208
208
209
209
The tokens aren't standard JSON Web Tokens (JWTs). The use of custom tokens is intentional, as the built-in Identity API is meant primarily for simple scenarios. The token option isn't intended to be a full-featured identity service provider or token server, but instead an alternative to the cookie option for clients that can't use cookies.
210
210
@@ -226,6 +226,17 @@ public signOut() {
226
226
responseType: 'text'
227
227
```
228
228
229
+
## SignOut everywhere
230
+
231
+
Apps need to react to events involving security-sensitive actions such as password changes, or other security-sensitive events. This is achieved using the [security stamp](/dotnet/api/microsoft.aspnetcore.identity.identityuser-1.securitystamp) feature of Identity.
232
+
233
+
Apps need to react to security-sensitive actions such as password changes. Identity achieves this using the [security stamp](/dotnet/api/microsoft.aspnetcore.identity.identityuser-1.securitystamp) feature:
234
+
235
+
* For cookie-based authentication, the security stamp is periodically revalidated based on [SecurityStampValidatorOptions.ValidationInterval](/dotnet/api/microsoft.aspnetcore.identity.securitystampvalidatoroptions.validationinterval).
236
+
* For token-based authentication, the access token lifetime set by [BearerTokenOptions.BearerTokenExpiration](/dotnet/api/microsoft.aspnetcore.authentication.bearertoken.bearertokenoptions.bearertokenexpiration) limits how long a session remains active after a security-sensitive change.
237
+
238
+
The validation interval is a balance between immediate session invalidation and database performance. A shorter interval requires more frequent database hits, while a longer one leaves a small window where an old, potentially compromised session might remain active.
239
+
229
240
## The `MapIdentityApi<TUser>` endpoints
230
241
231
242
The call to `MapIdentityApi<TUser>` adds the following endpoints to the app:
@@ -309,6 +320,8 @@ If `useCookies` is `false` or omitted, token-based authentication is enabled. Th
309
320
310
321
For more information about these properties, see <xref:Microsoft.AspNetCore.Authentication.BearerToken.AccessTokenResponse>.
311
322
323
+
Use the [BearerTokenOptions.BearerTokenExpiration](/dotnet/api/microsoft.aspnetcore.authentication.bearertoken.bearertokenoptions.bearertokenexpiration) property to set how long the access token remains valid.
324
+
312
325
Put the access token in a header to make authenticated requests, as shown in the following example
313
326
314
327
```http
@@ -340,6 +353,8 @@ If the call is successful, the response body is a new <xref:Microsoft.AspNetCore
340
353
}
341
354
```
342
355
356
+
Use the [BearerTokenOptions.RefreshTokenExpiration](/dotnet/api/microsoft.aspnetcore.authentication.bearertoken.bearertokenoptions.refreshtokenexpiration) property to set how long the refresh token remains valid.
357
+
343
358
## Use the `GET/confirmEmail` endpoint
344
359
345
360
If Identity is set up for email confirmation, a successful call to the `/register` endpoint sends an email that contains a link to the `/confirmEmail` endpoint. The link contains the following query string parameters:
0 commit comments