首页 文章

在Identityserver登录页面中获取请求Uri

提问于
浏览
0

我是Identityserver和Owin的新手 . 这是我的问题 . 我使用identityserver3作为我的身份验证服务创建了一个asp.net MVC应用程序 . 我想访问身份服务器登录中的请求URI . 我已经使用MVC视图定制了登录页面(使用IdentityServer3.Samples) .

这就是流程 . 以下URL需要身份验证才能继续 . https://www.myapp.com/customer/profile 当某人导航到该URL时,它将自动重定向到身份登录页面 https://www.myapp.com/identity/login?signin=2207991967207c8e306a8c08b3abd3b8 . 提供正确的用户凭据后,它将正确地重定向回请求URL,该URL已由identityserver处理 .

在我的情况下,我在同一个身份服务器登录页面中有另一个链接,它应该重定向到我自己的链接,请求URL为 https://www.myapp.com/customer/profile 作为查询字符串参数 . 我怎样才能做到这一点?基本上,我想在登录页面内获取请求URL .

2 回答

  • 1

    您必须在客户端上覆盖 AuthorizationCodeReceived 事件的处理程序:

    AuthorizationCodeReceived = async n =>{
        n.AuthenticationTicket.Properties.RedirectUri = /*your custom logic here*/;
    }
    

    问题似乎是this的一个变种

  • 0

    您应该能够通过访问返回URL

    var env = Request.GetOwinContext().Environment;
    var msg = env.GetSignInMessage(id); // id from querystring
    var returnUrl = msg.ReturnUrl;
    

    (取自示例仓库中的login controller

相关问题