Skip to content

Commit 8b49739

Browse files
trwalketrwalke
andauthored
Updating wwwAuthenticateParsing to handle v2.0 (#4610)
Co-authored-by: trwalke <trwalke@microsoft.com>
1 parent a5c1ca0 commit 8b49739

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/client/Microsoft.Identity.Client/WwwAuthenticateParameters.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,14 +420,14 @@ internal static WwwAuthenticateParameters CreateWwwAuthenticateParameters(IDicti
420420

421421
if (values.TryGetValue("authorization_uri", out string value))
422422
{
423-
wwwAuthenticateParameters.Authority = value.Replace("/oauth2/authorize", string.Empty);
423+
wwwAuthenticateParameters.Authority = value.Replace("/v2.0", string.Empty).Replace("/oauth2/authorize", string.Empty);
424424
}
425425

426426
if (string.IsNullOrEmpty(wwwAuthenticateParameters.Authority))
427427
{
428428
if (values.TryGetValue("authorization", out value))
429429
{
430-
wwwAuthenticateParameters.Authority = value.Replace("/oauth2/authorize", string.Empty);
430+
wwwAuthenticateParameters.Authority = value.Replace("/v2.0", string.Empty).Replace("/oauth2/authorize", string.Empty);
431431
}
432432
}
433433

tests/Microsoft.Identity.Test.Unit/WwwAuthenticateParametersTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ public class WwwAuthenticateParametersTests
4444
[DataRow("client_id=00000003-0000-0000-c000-000000000000", "authority=\"https://login.microsoftonline.com/common\"")]
4545
[DataRow("resource_id=00000003-0000-0000-c000-000000000000", "authorization=\"https://login.microsoftonline.com/common/oauth2/authorize\"")]
4646
[DataRow("resource=00000003-0000-0000-c000-000000000000", "authorization=\"https://login.microsoftonline.com/common/oauth2/authorize\"")]
47+
[DataRow("resource=00000003-0000-0000-c000-000000000000", "authorization_uri=\"https://login.microsoftonline.com/common/v2.0/oauth2/authorize\"")]
48+
[DataRow("resource=00000003-0000-0000-c000-000000000000", "authorization_uri=\"https://login.microsoftonline.com/common/oauth2/v2.0/authorize\"")]
49+
[DataRow("resource=00000003-0000-0000-c000-000000000000", "authorization=\"https://login.microsoftonline.com/common/v2.0/oauth2/authorize\"")]
50+
[DataRow("resource=00000003-0000-0000-c000-000000000000", "authorization=\"https://login.microsoftonline.com/common/oauth2/v2.0/authorize\"")]
4751
public void CreateWwwAuthenticateResponse(string resource, string authorizationUri)
4852
{
4953
// Arrange

0 commit comments

Comments
 (0)