当我尝试进行身份验证时,出现以下错误
2021-10-01T11:19:46.162027114Z: [INFO] : Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
2021-10-01T11:19:46.162072114Z: [INFO] An unhandled exception has occurred while executing the request.
2021-10-01T11:19:46.162078813Z: [INFO] System.Exception: An error was encountered while handling the remote login.
2021-10-01T11:19:46.163227804Z: [INFO] ---> System.Exception: Unable to unprotect the message.State.
2021-10-01T11:19:46.163254904Z: [INFO] --- End of inner exception stack trace ---
2021-10-01T11:19:46.163261804Z: [INFO] at Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler`1.HandleRequestAsync()
2021-10-01T11:19:46.163830499Z: [INFO] at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
2021-10-01T11:19:46.163847599Z: [INFO] at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
2021-10-01T11:19:46.163869499Z: [INFO] at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
我创建了一个核心 mvc 站点,它在 stage 和 dev 中运行良好,但 prod 失败了。我们正在使用 linux docker 来托管 azure app 服务。我们调查并发现当 azure 尝试在 prod 中运行多个实例时会发生此问题。我们在下面找到了一个关于数据保护的链接,但我需要详细了解我需要做什么。 Kubernetes 中的 Azure AD 身份验证无法取消对 message.State 的保护
在 startup.cs 中,身份验证按以下方式配置
services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(options =>
{
Configuration.Bind("AzureAD", options);
options.AccessDeniedPath = new PathString("/Download");
options.Events ??= new OpenIdConnectEvents();
options.Events.OnTokenValidated = async (context) =>
{
//code to get some data from local database
};
});