IdentitySever3 URL Redirection for Multiple Domains

Considering

ASP MVC website in IIS. The site authenticated users with an identifier server with a limited flow.

Several domains belong to it. Thus, the website is called from different domains.

eg.

  • foo.com
  • foo.de
  • foo.fr

Problem

Now that I am setting up my site, I have to set the redirect URL, but it depends on where the user comes from. But since this configuration is performed when the application starts, I could not change the situation depending on the incoming request.

What is the recommended approach for this?

 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 !?
    }
}
+4
1

, , ,

, 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 !?
    }
}
0

Source: https://habr.com/ru/post/1666910/


All Articles