Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 多个域的IdentitySever3重定向Url_Asp.net_Asp.net Mvc_Identityserver3 - Fatal编程技术网

Asp.net 多个域的IdentitySever3重定向Url

Asp.net 多个域的IdentitySever3重定向Url,asp.net,asp.net-mvc,identityserver3,Asp.net,Asp.net Mvc,Identityserver3,给定的 IIS中的ASP MVC网站。该站点使用具有impicit流的identityserver对用户进行身份验证 它有多个领域。因此,该网站是从不同的领域调用的 比如说 foo.com 富德 foo.fr 问题 现在,当我配置我的网站时,我必须设置重定向url,但这取决于用户来自哪里。但是,由于此配置是在应用程序启动时完成的,因此我无法根据传入的请求进行区分 对此,推荐的方法是什么 public static void Configure(IAppBuilder app) {

给定的

IIS中的ASP MVC网站。该站点使用具有impicit流的identityserver对用户进行身份验证

它有多个领域。因此,该网站是从不同的领域调用的

比如说

  • foo.com
  • 富德
  • foo.fr
问题

现在,当我配置我的网站时,我必须设置重定向url,但这取决于用户来自哪里。但是,由于此配置是在应用程序启动时完成的,因此我无法根据传入的请求进行区分

对此,推荐的方法是什么

 public static void Configure(IAppBuilder app)
 {
      app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
            {
                AuthenticationType = "oidc",
                Authority = ConfigurationManager.AppSettings["authority"],
                ClientId = "BlsFrontend",
                RedirectUri = "http://foo.de", //how to get this dynamically?
                ResponseType = "id_token token",
                SignInAsAuthenticationType = "Cookies",
                Scope = "openid profile",
我想到的一件事是使用
RedirectToIdentityProvider
通知并在请求中应用重定向。我对它进行了测试,它在我的案例中有效,但这是一种有效/良好的方法吗

RedirectToIdentityProvider = n =>
{
    if (!string.IsNullOrWhiteSpace(n.ProtocolMessage.RedirectUri))
    {
        n.ProtocolMessage.RedirectUri = n.Request.Scheme + "://" + n.Request.Host.ToString(); //How to make it clean !?
    }
}

我将此作为解决方案发布,因为我没有找到任何其他方法来解决问题,其他一些人也使用此解决方案

解决方案是在重定向到identity server之前根据请求设置重定向url。为此,我使用RedirectToIdentityProvider通知

RedirectToIdentityProvider = n =>
{

    if (n.ProtocolMessage.RequestType == OpenIdConnectRequestType.Authentication && 
        !string.IsNullOrWhiteSpace(n.ProtocolMessage.RedirectUri))
    {
        n.ProtocolMessage.RedirectUri = n.Request.Scheme + "://" + n.Request.Host.ToString(); //How to make it clean !?
    }
}

这是正确的方法,重定向URI由权威机构验证。