Настройки OpenIdConnect (Azure)
// COOKIES: Tells it to use cookies for authentication.
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
CookieManager = new SystemWebCookieManager()
});
// OPEN-ID: Authenticate via Azure AD using OpenIdConnect.
//https://azure.microsoft.com/en-us/resources/samples/active-directory-dotnet-webapp-webapi-openidconnect/
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions()
{
ClientId = ClientID,
Authority = Authority,
PostLogoutRedirectUri = PostLogoutRedirectUri,
Notifications = new OpenIdConnectAuthenticationNotifications()
{
AuthenticationFailed = PrincipalService.OnAzureAuthenticationFailure,
// REFERENCE: https://russellyoung.net/2015/09/05/mvc-role-based-authorization-with-azure-active-directory-aad/
AuthorizationCodeReceived = (AuthorizationCodeReceivedNotification notification) =>
{
var username = notification.AuthenticationTicket.Identity.Name.Split('#').LastOrDefault();
Logger.Log(Level.Auth, "Azure login success! Username: '" + username + "'.");
return Task.FromResult(0);
}
}
});
Настройки перезаписи URL ARR
<rewrite>
<outboundRules>
<preConditions>
<preCondition name="ResponseIsHtml1">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
</outboundRules>
<rules>
<rule name="Secondary Server" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{CACHE_URL}" pattern="^(https?)://" />
</conditions>
<action type="Rewrite" url="https://qa2mobile.auntmillies.com/{R:1}" />
<serverVariables>
</serverVariables>
</rule>
</rules>
</rewrite>
Задача
Проверка подлинности Azure AD работает нормально, но как только я настроил обратный прокси-сервер, он переместится в мой собственный домен, как если бы это был поставщик удостоверений.
например. https://my.domain.com/<guid>/oauth2/authorize?client_id=<guid>&etc
- С этого момента, если я вручную изменю
my.domain.com
на login.microsoftonline.com
, он войдет в систему и перейдет к нормальной работе.
- Если я удаляю обратный прокси-сервер и нормально настраиваю сервер, он переходит непосредственно к
login.microsoftonline.com
вместо моего домена.
Что вызывает это? Я имею в виду, очевидно, обратный прокси, но как я могу это исправить, не удаляя обратный прокси?