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

Add 'haschrome=1' to avoid unexpected back buttons on the first page. #4836

Merged
merged 4 commits into from
Jul 15, 2024
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 @@ -126,6 +126,10 @@ private async Task<MsalTokenResponse> GetTokenResponseAsync(CancellationToken ca
_requestParams.AppConfig.ExtraQueryParameters[InstanceAwareParam] = "true";
}

// Aligh with MSAL CPP: https://github.com/AzureAD/microsoft-authentication-library-for-cpp/blob/4fa774db2b38cdce9c9b94e3e686ab53fc24b948/source/xplat/requests/WebRequestManager.cpp#L566
// Always add 'haschrome=1' in the protocol to avoid unexpected back buttons on the first page.
_requestParams.AppConfig.ExtraQueryParameters["haschrome"] = "1";

IAuthCodeRequestComponent authorizationFetcher =
_authCodeRequestComponentOverride ??
new AuthCodeRequestComponent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,16 @@ public async Task WithExtraQueryParamsAndClaimsAsync()

MockInstanceDiscoveryAndOpenIdRequest(harness.HttpManager);

IDictionary<string, string> expectedQueryParams = new Dictionary<string, string>();
foreach (var kvp in TestConstants.ExtraQueryParameters)
{
expectedQueryParams[kvp.Key] = kvp.Value;
}
expectedQueryParams.Add("haschrome", "1");
var tokenResponseHandler = new MockHttpMessageHandler
{
ExpectedMethod = HttpMethod.Post,
ExpectedQueryParams = TestConstants.ExtraQueryParameters,
ExpectedQueryParams = expectedQueryParams,
ExpectedPostData = new Dictionary<string, string>()
{ {OAuth2Parameter.Claims, TestConstants.Claims } },
ResponseMessage = MockHelpers.CreateSuccessTokenResponseMessage()
Expand All @@ -82,7 +88,7 @@ public async Task WithExtraQueryParamsAndClaimsAsync()
TestConstants.AuthorityHomeTenant,
TestConstants.s_scope,
cache,
extraQueryParameters: TestConstants.ExtraQueryParameters,
extraQueryParameters: expectedQueryParams,
claims: TestConstants.Claims);

parameters.RedirectUri = new Uri("some://uri");
Expand Down Expand Up @@ -343,7 +349,12 @@ public void DuplicateQueryParameterErrorTest()
[DataRow(false)]
public async Task WithMultiCloudSupportEnabledAsync(bool multiCloudSupportEnabled)
{
var expectedQueryParams = TestConstants.ExtraQueryParameters;
IDictionary<string, string> expectedQueryParams = new Dictionary<string, string>();
foreach (var kvp in TestConstants.ExtraQueryParameters)
{
expectedQueryParams[kvp.Key] = kvp.Value;
}
expectedQueryParams.Add("haschrome", "1");
var authorizationResultUri = TestConstants.AuthorityHomeTenant + "?code=some-code";

if (multiCloudSupportEnabled)
Expand Down
1 change: 1 addition & 0 deletions tests/devapps/WAM/NetFrameworkWam/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ private async Task<AuthenticationResult> RunAtiAsync(IPublicClientApplication pc
var scopes = GetScopes();

var builder = pca.AcquireTokenInteractive(scopes)
.WithPrompt(Prompt.ForceLogin).WithLoginHint(loginHint)
.WithParentActivityOrWindow(this.Handle);

var webview = GetWebView();
Expand Down