Skip to content

Commit

Permalink
Do not add v2.0 to authority endpoint if already exists (#6457)
Browse files Browse the repository at this point in the history
- Do not add v2.0 to authority endpoint if already exists.
  • Loading branch information
konstantin-msft authored Sep 12, 2023
1 parent a82c117 commit 19eed25
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Do not add v2.0 to authority endpoint if already exists #6457",
"packageName": "@azure/msal-common",
"email": "[email protected]",
"dependentChangeType": "patch"
}
1 change: 1 addition & 0 deletions lib/msal-common/src/authority/Authority.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ export class Authority {
protected get defaultOpenIdConfigurationEndpoint(): string {
const canonicalAuthorityHost = this.hostnameAndPort;
if (
this.canonicalAuthority.endsWith("v2.0/") ||
this.authorityType === AuthorityType.Adfs ||
(this.protocolMode !== ProtocolMode.AAD &&
!this.isAliasOfKnownMicrosoftAuthority(canonicalAuthorityHost))
Expand Down
26 changes: 26 additions & 0 deletions lib/msal-common/test/authority/Authority.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2543,6 +2543,32 @@ describe("Authority.ts Class Unit Tests", () => {
);
});

it("v2 is not added to authority if already provided", async () => {
const authorityUrl =
"https://login.microsoftonline.com/test-tenant-id/v2.0";
let endpoint = "";
authority = new Authority(
authorityUrl,
networkInterface,
mockStorage,
{ ...authorityOptions, knownAuthorities: [authorityUrl] },
logger
);
jest.spyOn(
networkInterface,
<any>"sendGetRequestAsync"
).mockImplementation((openIdConfigEndpoint) => {
// @ts-ignore
endpoint = openIdConfigEndpoint;
return DEFAULT_OPENID_CONFIG_RESPONSE;
});

await authority.resolveEndpointsAsync();
expect(endpoint).toBe(
`${authorityUrl}/.well-known/openid-configuration`
);
});

it("DSTS authority uses v2 well-known endpoint with common authority", async () => {
const authorityUrl =
"https://login.microsoftonline.com/dstsv2/common/";
Expand Down

0 comments on commit 19eed25

Please sign in to comment.