Program.cs
Код: Выделить всё
// Okta
builder.Services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
})
.AddCookie(options =>
{
options.LoginPath = new PathString("/Account/SignIn");
})
.AddOktaMvc(new OktaMvcOptions
{
OktaDomain = builder.Configuration.GetValue("Okta:OktaDomain"),
ClientId = builder.Configuration.GetValue("Okta:ClientId"),
ClientSecret = builder.Configuration.GetValue("Okta:ClientSecret"),
AuthorizationServerId = builder.Configuration.GetValue("Okta:AuthorizationServerId"),
Scope = new List { "openid", "profile", "email" },
});
// Entra
builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd"));
Код: Выделить всё
System.InvalidOperationException: 'Scheme already exists: Cookies'
Подробнее здесь: https://stackoverflow.com/questions/791 ... re-mvc-app