Реализация Entra:
Код: Выделить всё
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
AuthenticationType = "Entra",
Caption = "Sign-in with Entra",
ClientId = EntraService.ClientId,
RedirectUri = EntraService.RedirectUrl,
Authority = EntraService.Authority,
PostLogoutRedirectUri = EntraService.RedirectUrl,
Scope = OpenIdConnectScope.OpenIdProfile + " " + OpenIdConnectScope.Email,
ResponseType = OpenIdConnectResponseType.CodeIdToken,
ProtocolValidator = new OverrideOpenIdConnectProtocolValidator(false),
Notifications = new OpenIdConnectAuthenticationNotifications()
{
SecurityTokenValidated = (context) =>
{
UserHelper userMigration = new UserHelper();
if (!userMigration.AuthorizeFlow(context))
{
Log.Information("Entra: SecurityTokenValidated AuthorizeFlow fail");
return Task.FromResult(0);
}
Log.Information("Entra: SecurityTokenValidated AuthorizeFlow success");
return Task.FromResult(0);
}
}
});
Код: Выделить всё
context.AuthenticationTicket = new AuthenticationTicket(new ClaimsIdentity(authorizedIdentity.Claims, context.AuthenticationTicket.Identity.AuthenticationType), context.AuthenticationTicket.Properties);
Log.Information("Setting AuthenticationTicket identity");
Настройки аутентификации файлов cookie:
Код: Выделить всё
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
AuthenticationType = CookieAuthenticationDefaults.AuthenticationType,
LoginPath = new PathString("/Login"),
CookieSameSite = SameSiteMode.None,
CookieSecure = CookieSecureOption.Always,
ExpireTimeSpan = TimeSpan.FromMinutes(60)
});
Есть идеи, как решить эту проблему?>
Подробнее здесь: https://stackoverflow.com/questions/786 ... entication