Skip to content

Commit 6e82d29

Browse files
committed
Refactor authority implementation
1 parent 05d2aa4 commit 6e82d29

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

msal/authority.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,17 @@ def __init__(self, authority_url, validate_authority=True,
3838
self.proxies = proxies
3939
self.timeout = timeout
4040
canonicalized, self.instance, tenant = canonicalize(authority_url)
41-
tenant_discovery_endpoint = ( # Hard code a V2 pattern as default value
42-
'https://{}/{}/v2.0/.well-known/openid-configuration'
43-
.format(self.instance, tenant))
44-
if validate_authority and self.instance not in WELL_KNOWN_AUTHORITY_HOSTS:
41+
tenant_discovery_endpoint = (
42+
'https://{}/{}{}/.well-known/openid-configuration'.format(
43+
self.instance,
44+
tenant,
45+
"" if tenant == "adfs" else "/v2.0" # the AAD v2 endpoint
46+
))
47+
if (tenant != "adfs" and validate_authority
48+
and self.instance not in WELL_KNOWN_AUTHORITY_HOSTS):
4549
tenant_discovery_endpoint = instance_discovery(
4650
canonicalized + "/oauth2/v2.0/authorize",
4751
verify=verify, proxies=proxies, timeout=timeout)
48-
if tenant.lower() == "adfs":
49-
tenant_discovery_endpoint = ("https://{}/adfs/.well-known/openid-configuration"
50-
.format(self.instance))
5152
openid_config = tenant_discovery(
5253
tenant_discovery_endpoint,
5354
verify=verify, proxies=proxies, timeout=timeout)

0 commit comments

Comments
 (0)