I’ve been working ITFoxTec SAML 2.0 library and I just found out that the services.AddSaml2();
call is basically this:
services.AddAuthentication(Saml2Constants.AuthenticationScheme)
.AddCookie(Saml2Constants.AuthenticationScheme, o =>
{
o.LoginPath = new PathString(loginPath);
o.SlidingExpiration = slidingExpiration;
if (!string.IsNullOrEmpty(accessDeniedPath))
{
o.AccessDeniedPath = new PathString(accessDeniedPath);
}
if (sessionStore != null)
{
o.SessionStore = sessionStore;
}
o.Cookie.SameSite = cookieSameSite;
o.Cookie.SecurePolicy = cookieSecurePolicy;
if (!string.IsNullOrEmpty(cookieDomain))
{
o.Cookie.Domain = cookieDomain;
}
});
Which would explain why it always seem to override my existing Authentication, which is this:
services.AddAuthentication(AuthenticationScheme)
.AddCookie(opts => {
opts.LoginPath = new PathString("/Account/Login");
opts.SlidingExpiration = true;
opts.ExpireTimeSpan = TimeSpan.FromDays(21);
});
I have 2 login buttons; one for SAML and one for my local cookie login.
I want them to work separately but the ITFoxTec services.AddSaml();
always seems to interfere with mine.
Is there a way to “chain” my existing cookie authentication into or after the ITFoxTec one?
Thanks!