Skip to content

Commit c9a36e9

Browse files
committed
Merge branch 'dev' into wam
2 parents 46ef0e5 + bdbc23a commit c9a36e9

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

msal/application.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,10 @@ def _get_regional_authority(self, central_authority):
566566
if region_to_use:
567567
regional_host = ("{}.r.login.microsoftonline.com".format(region_to_use)
568568
if central_authority.instance in (
569-
# The list came from https://github.com/AzureAD/microsoft-authentication-library-for-python/pull/358/files#r629400328
569+
# The list came from point 3 of the algorithm section in this internal doc
570+
# https://identitydivision.visualstudio.com/DevEx/_git/AuthLibrariesApiReview?path=/PinAuthToRegion/AAD%20SDK%20Proposal%20to%20Pin%20Auth%20to%20region.md&anchor=algorithm&_a=preview
570571
"login.microsoftonline.com",
572+
"login.microsoft.com",
571573
"login.windows.net",
572574
"sts.windows.net",
573575
)
@@ -1421,7 +1423,7 @@ def _acquire_token_silent_by_finding_specific_refresh_token(
14211423
reverse=True):
14221424
logger.debug("Cache attempts an RT")
14231425
headers = telemetry_context.generate_headers()
1424-
if "home_account_id" in query: # Then use it as CCS Routing info
1426+
if query.get("home_account_id"): # Then use it as CCS Routing info
14251427
headers["X-AnchorMailbox"] = "Oid:{}".format( # case-insensitive value
14261428
query["home_account_id"].replace(".", "@"))
14271429
response = client.obtain_token_by_refresh_token(

msal/authority.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ def __init__(self, authority_url, http_client, validate_authority=True):
9292
tenant_discovery_endpoint = payload['tenant_discovery_endpoint']
9393
else:
9494
tenant_discovery_endpoint = (
95-
'https://{}{}{}/.well-known/openid-configuration'.format(
95+
'https://{}:{}{}{}/.well-known/openid-configuration'.format(
9696
self.instance,
97+
443 if authority.port is None else authority.port,
9798
authority.path, # In B2C scenario, it is "/tenant/policy"
9899
"" if tenant == "adfs" else "/v2.0" # the AAD v2 endpoint
99100
))

tests/test_authority.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ def _test_authority_builder(self, host, tenant):
3333
def test_wellknown_host_and_tenant(self):
3434
# Assert all well known authority hosts are using their own "common" tenant
3535
for host in WELL_KNOWN_AUTHORITY_HOSTS:
36-
self._test_given_host_and_tenant(host, "common")
36+
if host != AZURE_CHINA: # It is prone to ConnectionError
37+
self._test_given_host_and_tenant(host, "common")
3738

3839
def test_wellknown_host_and_tenant_using_new_authority_builder(self):
3940
self._test_authority_builder(AZURE_PUBLIC, "consumers")

0 commit comments

Comments
 (0)