Skip to content

Commit 7037231

Browse files
committed
update
1 parent e2cc47e commit 7037231

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

msal/application.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ def _decide_broker(self, allow_broker, enable_pii_log):
701701

702702
def is_pop_supported(self):
703703
"""Returns True if this client supports Proof-of-Possession Access Token."""
704-
return self._enable_broker
704+
return self._enable_broker and sys.platform != "linux"
705705

706706
def _decorate_scope(
707707
self, scopes,
@@ -1573,10 +1573,14 @@ def _acquire_token_silent_from_cache_and_possibly_refresh_it(
15731573
raise ValueError("auth_scheme is not supported in Cloud Shell")
15741574
return self._acquire_token_by_cloud_shell(scopes, data=data)
15751575

1576+
is_ssh_cert_or_pop_request = (
1577+
data.get("token_type") == "ssh-cert" or
1578+
data.get("token_type") == "pop" or
1579+
isinstance(auth_scheme, msal.auth_scheme.PopAuthScheme))
15761580
if self._enable_broker and account and account.get("account_source") in (
15771581
_GRANT_TYPE_BROKER, # Broker successfully established this account previously.
15781582
None, # Unknown data from older MSAL. Broker might still work.
1579-
):
1583+
) and (sys.platform != "linux" or not is_ssh_cert_or_pop_request):
15801584
from .broker import _acquire_token_silently
15811585
response = _acquire_token_silently(
15821586
"https://{}/{}".format(self.authority.instance, self.authority.tenant),
@@ -1823,7 +1827,7 @@ def acquire_token_by_username_password(
18231827
"""
18241828
claims = _merge_claims_challenge_and_capabilities(
18251829
self._client_capabilities, claims_challenge)
1826-
if self._enable_broker:
1830+
if self._enable_broker and sys.platform != "linux":
18271831
from .broker import _signin_silently
18281832
response = _signin_silently(
18291833
"https://{}/{}".format(self.authority.instance, self.authority.tenant),
@@ -2134,6 +2138,10 @@ def acquire_token_interactive(
21342138
False
21352139
) and data.get("token_type") != "ssh-cert" # Work around a known issue as of PyMsalRuntime 0.8
21362140
self._validate_ssh_cert_input_data(data)
2141+
is_ssh_cert_or_pop_request = (
2142+
data.get("token_type") == "ssh-cert" or
2143+
data.get("token_type") == "pop" or
2144+
isinstance(auth_scheme, msal.auth_scheme.PopAuthScheme))
21372145
if not on_before_launching_ui:
21382146
on_before_launching_ui = lambda **kwargs: None
21392147
if _is_running_in_cloud_shell() and prompt == "none":
@@ -2142,7 +2150,7 @@ def acquire_token_interactive(
21422150
return self._acquire_token_by_cloud_shell(scopes, data=data)
21432151
claims = _merge_claims_challenge_and_capabilities(
21442152
self._client_capabilities, claims_challenge)
2145-
if self._enable_broker:
2153+
if self._enable_broker and (sys.platform != "linux" or not is_ssh_cert_or_pop_request):
21462154
if parent_window_handle is None:
21472155
raise ValueError(
21482156
"parent_window_handle is required when you opted into using broker. "
@@ -2167,7 +2175,9 @@ def acquire_token_interactive(
21672175
)
21682176
return self._process_broker_response(response, scopes, data)
21692177

2170-
if auth_scheme:
2178+
if isinstance(auth_scheme, msal.auth_scheme.PopAuthScheme) and sys.platform == "linux":
2179+
raise ValueError("POP is not supported on Linux")
2180+
elif auth_scheme:
21712181
raise ValueError(self._AUTH_SCHEME_UNSUPPORTED)
21722182
on_before_launching_ui(ui="browser")
21732183
telemetry_context = self._build_telemetry_context(

0 commit comments

Comments
 (0)