簡體   English   中英

Azure Active Directory身份驗證后,ASP.NET將用戶重定向到當前自定義域

[英]ASP.NET Redirect user to current custom domain after Azure Active Directory Authentication

我試圖將用戶重定向到他們嘗試訪問我的網站的域,然后再重定向到Azure Active Directory登錄頁面。 我正在使用OpenIDConnect,下面是一些代碼,用於定義登錄后需要重定向用戶的URI:

Notifications = new OpenIdConnectAuthenticationNotifications
                {
                    RedirectToIdentityProvider = context =>
                    {
                        string appBaseUrl = "https://" + context.Request.Host + context.Request.PathBase + context.Request.Uri.PathAndQuery;
                        context.ProtocolMessage.RedirectUri = "https://" + context.Request.Host + context.Request.PathBase + context.Request.Uri.PathAndQuery;
                        context.ProtocolMessage.PostLogoutRedirectUri = appBaseUrl;
                        return Task.FromResult(0);
                    },

                    //custom validation
                    SecurityTokenValidated = onValidate,
                    AuthenticationFailed = onFailure
                }

我遇到的問題是我有自定義域和context.Request.Host返回我網站的通用域,而不是我所需要的。

例如,我有我的網站和2個自定義域:

  • mywebsite.azurewebsites.net通用主機
  • mywebsite.customdomain1.com
  • mywebsite.customdomain2.com

mywebsite.customdomain1.com連接時, context.Request.Host等於mywebsite.azurewebsites.net 不知道我的用戶來自哪個域,我被迫將他們重定向到一個唯一的域……這不是很理想。

我在這里有什么選擇?

關於我的問題,該問題來自以下事實:我使用CDN從customdomain1customdomain2提供對我的網站的訪問。 CDN配置錯誤,沒有讓接收到的請求中的原始主機名通過。 我更改了配置,現在一切正常。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM