Skip to content

Commit d31d472

Browse files
committed
Better support for B2C sovereign clouds
Based on the way we implemented it, the previous implementation would still work, in a sense that the app dev would be guided to bypass the Instance Discovery. This commit merely adds a shortcut so that app dev would not have to explicitly toggle validate_authority=False.
1 parent 7d5468a commit d31d472

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

msal/authority.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@
1818
'login.microsoftonline.us',
1919
'login.microsoftonline.de',
2020
])
21-
21+
WELL_KNOWN_B2C_HOSTS = [
22+
"b2clogin.com",
23+
"b2clogin.cn",
24+
"b2clogin.us",
25+
"b2clogin.de",
26+
]
2227

2328
class Authority(object):
2429
"""This class represents an (already-validated) authority.
@@ -43,7 +48,7 @@ def __init__(self, authority_url, validate_authority=True,
4348
self.proxies = proxies
4449
self.timeout = timeout
4550
authority, self.instance, tenant = canonicalize(authority_url)
46-
is_b2c = self.instance.endswith(".b2clogin.com")
51+
is_b2c = any(self.instance.endswith("." + d) for d in WELL_KNOWN_B2C_HOSTS)
4752
if (tenant != "adfs" and (not is_b2c) and validate_authority
4853
and self.instance not in WELL_KNOWN_AUTHORITY_HOSTS):
4954
payload = instance_discovery(

0 commit comments

Comments
 (0)