使用OpenIdConnect的Azure AD身份验证未创建身份验证Cookie

时间:2018-11-29 20:50:33

标签: oauth-2.0 asp.net-identity azure-active-directory openid-connect adal

我们有一个MVC.Net(c#)应用程序。我们已使用OpenIdConnect将其与Azure Active目录集成。

通过活动目录进行的身份验证在所有环境中均能正常工作。我们已经将该应用程序测试并部署到了

  1. 开发者系统
  2. 登台服务器
  3. 生产服务器
  4. 生产服务器(仅当主服务器停机时,辅助备用服务器)

在所有环境中,身份验证工作流均可以按照建议和预期正常运行。工作流程如下

  1. 用户将进入我们应用程序中的页面。
  2. 用户将选择“使用Azure AD登录”以通过Azure AD进行身份验证。
  3. 用户将被重定向到Azure AD身份验证工作流。用户将 登录Azure并提示您输入同意屏幕。
  4. 经同意,用户将被重定向回我们的系统,其中 cookie将被创建。

以下是Startup类中的auth配置。

    app.SetDefaultSignInAsAuthenticationType(DefaultAuthenticationTypes.ApplicationCookie);
    app.UseOpenIdConnectAuthentication(
            new OpenIdConnectAuthenticationOptions
            {
                AuthenticationMode = AuthenticationMode.Passive,
                AuthenticationType = OpenIdConnectAuthenticationDefaults.AuthenticationType,
                Authority = AADAuthority,
                TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuer = false
                },
                Notifications = new OpenIdConnectAuthenticationNotifications()
                {
                    RedirectToIdentityProvider = AppOpenIdConnectAuthenticationNotifications.RedirectToIdentityProvider,
                    MessageReceived = AppOpenIdConnectAuthenticationNotifications.MessageReceived,
                    SecurityTokenReceived = AppOpenIdConnectAuthenticationNotifications.SecurityTokenReceived,
                    SecurityTokenValidated = AppOpenIdConnectAuthenticationNotifications.SecurityTokenValidated,
                    AuthorizationCodeReceived = AppOpenIdConnectAuthenticationNotifications.AuthorizationCodeReceived,
                    AuthenticationFailed = AppOpenIdConnectAuthenticationNotifications.AuthenticationFailed
                }

AADAuthority是一个值为https://login.microsoftonline.com/common/的变量。

在启动身份验证重定向之前,已设置其他必需的参数,例如ClientId,RedirectUri和Prompt。

问题是在产品服务器中部署时

  1. 它可以正常运行一两天,并且用户可以成功登录。
  2. 但是,在一段时间后,它会停止工作(通常是一天或 两个),并且不再在重定向回时创建并验证Cookie 我们的系统。
  3. 如果应用程序被回收,它将开始工作并在之后停止 一定的时间。

我做了一些查找,看看以前是否有人遇到过类似的问题。

到目前为止,我发现的相关文章是https://github.com/IdentityServer/IdentityServer3/issues/2091

任何帮助,建议或评论都将有所帮助。

0 个答案:

没有答案
相关问题