The authentication (Cookie) of my project is set as below,
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
})
.AddCookie(options =>
{
options.ClaimsIssuer = "xxx.admin";
options.Cookie.HttpOnly = true;
options.Cookie.SecurePolicy = CookieSecurePolicy.SameAsRequest;
options.LoginPath = "/Login/Index/";
options.AccessDeniedPath = "/Account/Unauthorized/";
options.Cookie.SameSite = SameSiteMode.Strict;
});
and I configured second authentication option (OpenIdConnect) in different project as below,
services.AddRazorPages().AddMvcOptions(options =>
{
var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build();
options.Filters.Add(new AuthorizeFilter(policy));
}).AddMicrosoftIdentityUI();
services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme).AddMicrosoftIdentityWebApp(options =>
{
Configuration.Bind("AzureActiveDirectoryConnection", options);
options.Events ??= new OpenIdConnectEvents();
options.Events.OnTokenValidated += OnTokenValidated;
options.Events.OnTicketReceived += OnTicketReceived;
//options.Events.OnRedirectToIdentityProvider += OnRedirectToIdentityProvider;
});
Now, I need to combine them to support multiple authentication types in my app. How can I do that?