Skip to content

Commit 9007264

Browse files
committed
Add slidingExpiration attribut to AddSaml2. If set to true the handler re-issue a new cookie with a new expiration time any time it processes a request which is more than halfway through the expiration window.
1 parent 10cba6a commit 9007264

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/ITfoxtec.Identity.Saml2.MvcCore/Configuration/Saml2ServiceCollectionExtensions.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@ public static class Saml2ServiceCollectionExtensions
1010
/// Add SAML 2.0 configuration.
1111
/// </summary>
1212
/// <param name="loginPath">Redirection target used by the handler.</param>
13-
public static IServiceCollection AddSaml2(this IServiceCollection services, string loginPath = "/Auth/Login")
13+
/// <param name="slidingExpiration">If set to true the handler re-issue a new cookie with a new expiration time any time it processes a request which is more than halfway through the expiration window.</param>
14+
public static IServiceCollection AddSaml2(this IServiceCollection services, string loginPath = "/Auth/Login", bool slidingExpiration = false)
1415
{
1516
services.AddAuthentication(Saml2Constants.AuthenticationScheme)
1617
.AddCookie(Saml2Constants.AuthenticationScheme, o =>
1718
{
1819
o.LoginPath = new PathString(loginPath);
20+
o.SlidingExpiration = slidingExpiration;
1921
});
2022

2123
return services;
2224
}
2325
}
24-
}
26+
}

test/TestWebAppCore/Startup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void ConfigureServices(IServiceCollection services)
5353
}
5454
});
5555

56-
services.AddSaml2();
56+
services.AddSaml2(slidingExpiration: true);
5757

5858
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
5959
}

0 commit comments

Comments
 (0)