首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用nonce书签登录页面

用nonce书签登录页面
EN

Stack Overflow用户
提问于 2018-06-13 16:21:02
回答 1查看 1.3K关注 0票数 3

我正在尝试使用Microsoft中间件OIDC身份验证v4.0.0将MVC4 web客户端与IdentityServer集成。当从授权端点请求ID令牌时,必须提供一个nonce,并且所服务的登录页面在查询字符串中具有nonce。如果用户书签它并使用它在第二天登录(例如),客户端中的当前验证将失败,因为他们将不再存储该nonce,或者它将过期,等等。

这将触发客户端中的AuthenticationFailed通知,但此例外情况如下:

"IDX21323: RequireNonce is '[PII is hidden]'. OpenIdConnectProtocolValidationContext.Nonce was null, OpenIdConnectProtocol.ValidatedIdToken.Payload.Nonce was not null. The nonce cannot be validated. If you don't need to check the nonce, set OpenIdConnectProtocolValidator.RequireNonce to 'false'. Note if a 'nonce' is found it will be evaluated."

此时,我可以HandleResponse,重定向到错误页面,等等。如果他们再次尝试访问受保护的资源,则重定向到IdentityServer将立即返回ID令牌,这是由于上一次成功登录(从它的角度来看,我想呢?)这一次,nonce验证,用户被登录到客户端。但对于用户来说,这是一种相当奇怪的体验--他们第一次尝试登录似乎失败了,他们得到了一个错误,但是当他们再次尝试时,他们甚至不需要登录,他们只是直接进入。

另一种方法是在AuthenticationFailed中通过重定向到主保护的资源来处理这种类型的异常,以便在后台“无缝地”发生这种情况。对用户来说,似乎他们的第一次登录尝试成功了。但我不确定这是否适合于真正的现在验证问题。在某些情况下,我也担心这会导致重定向循环。

为了回答我的问题..。对于此问题,登录页面/非the书签的常见方法是什么?我是否犯了一个根本的错误,或者在这条线上的某个地方发现了一个基本的误解,从而导致了这种情况的发生?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-06-07 22:41:59

下面是需要进入调用

代码语言:javascript
复制
UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
   AuthenticationType = "oidc",
   Authority = appSettings["ida:Authority"],
   ClientId = appSettings["ida:ClientId"],
   ClientSecret = appSettings["ida:ClientSecret"],
   PostLogoutRedirectUri = appSettings["ida:PostLogoutRedirectUri"],
   RedirectUri = appSettings["ida:RedirectUri"],
   RequireHttpsMetadata = false,
   ResponseType = "code id_token",
   Scope = appSettings["ida:Scope"],
   Notifications = new OpenIdConnectAuthenticationNotifications
   {
       AuthenticationFailed = authFailed =>
       {
           if (authFailed.Exception.Message.Contains("IDX21323"))
           {
              authFailed.HandleResponse();
              authFailed.OwinContext.Authentication.Challenge();
           }

           return Task.FromResult(true);
                    }
         },
      SignInAsAuthenticationType = "Cookies"
    }
});
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50841971

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档