Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1163 (AppService authentication can declare aad or azureactivedirectory indifferently) #1245

Merged
merged 1 commit into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static class AppServicesAuthenticationInformation
internal const string AppServicesAuthLogoutPathEnvironmentVariable = "WEBSITE_AUTH_LOGOUT_PATH"; // /.auth/logout
internal const string AppServicesAuthIdentityProviderEnvironmentVariable = "WEBSITE_AUTH_DEFAULT_PROVIDER"; // AzureActiveDirectory
internal const string AppServicesAuthAzureActiveDirectory = "AzureActiveDirectory";
internal const string AppServicesAuthAAD = "AAD";
internal const string AppServicesAuthIdTokenHeader = "X-MS-TOKEN-AAD-ID-TOKEN";
private const string AppServicesAuthIdpTokenHeader = "X-MS-CLIENT-PRINCIPAL-IDP";

Expand All @@ -43,10 +44,16 @@ public static bool IsAppServicesAadAuthenticationEnabled
Constants.True,
StringComparison.OrdinalIgnoreCase) &&

string.Equals(
(string.Equals(
Environment.GetEnvironmentVariable(AppServicesAuthIdentityProviderEnvironmentVariable),
AppServicesAuthAzureActiveDirectory,
StringComparison.OrdinalIgnoreCase);
StringComparison.OrdinalIgnoreCase)
||
string.Equals(
Environment.GetEnvironmentVariable(AppServicesAuthIdentityProviderEnvironmentVariable),
AppServicesAuthAAD,
StringComparison.OrdinalIgnoreCase)
);
}
}

Expand Down
2 changes: 2 additions & 0 deletions tests/Microsoft.Identity.Web.Test/WebAppExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,8 @@ public void AddMicrosoftIdentityWebApp_AddsInMemoryTokenCaches()
[InlineData("true", "azureactivedirectory")]
[InlineData("tRue", AppServicesAuthenticationInformation.AppServicesAuthAzureActiveDirectory)]
[InlineData("true", AppServicesAuthenticationInformation.AppServicesAuthAzureActiveDirectory)]
[InlineData("tRue", AppServicesAuthenticationInformation.AppServicesAuthAAD)]
[InlineData("true", AppServicesAuthenticationInformation.AppServicesAuthAAD)]
// Regression for https://github.com/AzureAD/microsoft-identity-web/issues/1163
public void AppServices_EnvironmentTest(string appServicesEnvEnabledValue, string idpEnvValue)
{
Expand Down