Skip to content

Commit 4461d74

Browse files
authored
Update customize-authentication-session-expiration.md
Edit review per CI 5974
1 parent 0138bf1 commit 4461d74

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

support/entra/entra-id/app-integration/customize-authentication-session-expiration.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
---
22
title: Configure ASP.NET or ASP.NET Core App Session to Last Longer Than Entra ID Tokens
3-
description: Describes how to configure ASP.NET or ASP.NET Core App session to last longer than Microsoft Entra ID token.
3+
description: Discusses how to configure ASP.NET or ASP.NET Core App session to last longer than Microsoft Entra ID token.
44
ms.date: 05/31/2025
55
ms.reviewer: willfid
66
ms.service: entra-id
77
ms.custom: sap:Developing or Registering apps with Microsoft identity platform
88
---
9-
# Customize Middleware authentication ticket to extend user sign-in duration
9+
# Customize middleware authentication ticket to extend user sign-in duration
1010

11-
Microsoft Entra ID tokens (ID tokens, access tokens, and SAML tokens) by default expire after one hour. ASP.NET and ASP.NET Core Middleware set their authentication ticket to the expiration of these tokens by default. If you don't want your web application to redirect users to Microsoft Entra ID to sign in again, you can customize the Middleware authentication ticket.
11+
By default, Microsoft Entra ID tokens (ID tokens, access tokens, and SAML tokens) expire after one hour. Also by default, ASP.NET and ASP.NET Core middleware set their authentication tickets to the expiration of these tokens. If you don't want your web application to redirect users to Microsoft Entra ID to have them sign in again, you can customize the middleware authentication ticket.
1212

1313
This customization can also help resolve AJAX issues (such as CORS errors to `login.microsoftonline.com`) where your app is both a Web App and Web API.
1414

1515
## For ASP.NET
1616

17-
In the `ConfigureAuth` method of your `Startup.Auth.cs` file, update the `app.UseCookieAuthentication()` method to:
17+
In the `ConfigureAuth` method of the `Startup.Auth.cs` file, update the `app.UseCookieAuthentication()` method to:
1818

1919
```csharp
2020
app.UseCookieAuthentication(new CookieAuthenticationOptions()
@@ -29,20 +29,20 @@ app.UseCookieAuthentication(new CookieAuthenticationOptions()
2929
}
3030
});
3131
```
32-
Then, decouple the token lifetime from the Web App:
32+
33+
Then, decouple the token lifetime from the web app:
3334

3435
```csharp
3536
app.UseOpenIdConnectAuthentication(
3637
new OpenIdConnectAuthenticationOptions
3738
{
3839
UseTokenLifetime = false,
3940
...
40-
4141
```
4242

4343
## For ASP.NET Core
4444

45-
In ASP.NET Core, you need to add the `OnTokenValidated` event to update the ticket properties. This sets the ticket expiration time before the application redirects to Microsoft Entra ID for reauthentication.
45+
In ASP.NET Core, you have to add the `OnTokenValidated` event to update the ticket properties. This change sets the ticket expiration time to be before the application redirects to Microsoft Entra ID for reauthentication.
4646

4747
```csharp
4848
services.Configure<OpenIdConnectOptions>(AzureADDefaults.OpenIdScheme, options =>
@@ -65,9 +65,9 @@ services.Configure<OpenIdConnectOptions>(AzureADDefaults.OpenIdScheme, options =
6565

6666
### Examples
6767

68-
Here are a few examples of how to do this:
68+
Here are a few examples of how to do make this setting:
6969

70-
If you're using code similar to the following to add Microsoft Entra ID authentication:
70+
If you're using code similar to the following example to add Microsoft Entra ID authentication:
7171

7272
```csharp
7373
services.AddAuthentication(AzureADDefaults.AuthenticationScheme)
@@ -94,7 +94,7 @@ services.Configure<OpenIdConnectOptions>(AzureADDefaults.OpenIdScheme, options =
9494
});
9595
```
9696

97-
Your configuration in Startup.cs should look something like this:
97+
Your configuration in Startup.cs should resemble the following example:
9898

9999
```csharp
100100
public void ConfigureServices(IServiceCollection services)
@@ -172,7 +172,7 @@ services.Configure<OpenIdConnectOptions>(options =>
172172
});
173173
```
174174

175-
If you're integrating an ASP.NET Core WS-Fed application, then it might look something like the following:
175+
If you're integrating an ASP.NET Core WS-Fed application:
176176

177177
```csharp
178178
public void ConfigureServices(IServiceCollection services)
@@ -207,10 +207,9 @@ public void ConfigureServices(IServiceCollection services)
207207
```
208208
## More information
209209

210-
These settings control the expiration of the authentication ticket, which determines how long a user stays signed in. You can configure this expiration to suit your requirement.
210+
These settings control the expiration of the authentication ticket that determines how long a user stays signed in. You can configure this expiration to suit your requirement.
211211

212-
>[!NOTE]
213-
> If you modify the ticket expiration, users may still have access to your application even if they've been deleted or disabled in Microsoft Entra ID, until the ticket expires.
212+
> [!NOTE]
213+
> If you modify the ticket expiration, users may still have access to your application even if they've been deleted or disabled in Microsoft Entra ID,. This condition remains true until the ticket expires.
214214

215215
[!INCLUDE [Azure Help Support](../../../includes/azure-help-support.md)]
216-

0 commit comments

Comments
 (0)