-
Notifications
You must be signed in to change notification settings - Fork 205
allow_broker becomes conditional per platform #510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -450,7 +450,7 @@ def __init__( | |
This factor would become mandatory | ||
if a tenant's admin enables a corresponding Conditional Access (CA) policy. | ||
The broker's presence allows Microsoft identity platform | ||
to have higher confidence that the tokens are being issued to your device, | ||
to have more confidence that the tokens are being issued to your device, | ||
and that is more secure. | ||
|
||
An additional benefit of broker is, | ||
|
@@ -459,29 +459,24 @@ def __init__( | |
so that your broker-enabled apps (even a CLI) | ||
could automatically SSO from a previously established signed-in session. | ||
|
||
This parameter defaults to None, which means MSAL will not utilize a broker. | ||
If this parameter is set to True, | ||
MSAL will use the broker whenever possible, | ||
and automatically fall back to non-broker behavior. | ||
That also means your app does not need to enable broker conditionally, | ||
you can always set allow_broker to True, | ||
as long as your app meets the following prerequisite: | ||
This parameter defaults to None, which means MSAL will not utilize a broker, | ||
and your end users will have the traditional browser-based login experience. | ||
|
||
* Installed optional dependency, e.g. ``pip install msal[broker]>=1.20,<2``. | ||
(Note that broker is currently only available on Windows 10+) | ||
You can set it to True, based on the OS platform. | ||
Currently, MSAL supports broker on Windows 10+, and errors out on others. | ||
So, for example, you can do ``allow_broker = sys.platform=="win32"``. | ||
|
||
* Register a new redirect_uri for your desktop app as: | ||
``ms-appx-web://Microsoft.AAD.BrokerPlugin/your_client_id`` | ||
|
||
* Tested your app in following scenarios: | ||
In order to allow broker, your app must also meet the following prerequisite: | ||
|
||
* Windows 10+ | ||
* Install optional dependency, e.g. ``pip install msal[broker]>=1.20,<2``. | ||
|
||
* PublicClientApplication's following methods:: | ||
acquire_token_interactive(), acquire_token_by_username_password(), | ||
acquire_token_silent() (or acquire_token_silent_with_error()). | ||
* Register a new redirect_uri for your desktop app as: | ||
``ms-appx-web://Microsoft.AAD.BrokerPlugin/your_client_id`` | ||
|
||
* AAD and MSA accounts (i.e. Non-ADFS, non-B2C) | ||
* Test your app with AAD and MSA accounts (i.e. Non-ADFS, non-B2C) | ||
in PublicClientApplication's following methods: | ||
acquire_token_interactive(), acquire_token_by_username_password(), | ||
acquire_token_silent() (or acquire_token_silent_with_error()). | ||
|
||
New in version 1.20.0. | ||
""" | ||
|
@@ -549,6 +544,9 @@ def __init__( | |
) | ||
else: | ||
raise | ||
|
||
if allow_broker and sys.platform != "win32": | ||
raise ValueError("allow_broker=True is only supported on Windows") | ||
Comment on lines
+548
to
+549
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personally, I think this check defeats the purpose of the word "allow". If an error is raised, it should be called That being said, I prefer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is indeed a naming dilemma, unfortunately.
Even with the newly found No.2, the No.1 still applies. So, there is no good name here. Ideas are welcome, although we may not actually change it at this point, because it has been shipped in MSAL Python 1.20. |
||
is_confidential_app = bool( | ||
isinstance(self, ConfidentialClientApplication) or self.client_credential) | ||
if is_confidential_app and allow_broker: | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am curious what if I set
allow_broker
on Windows 7? As this won't trigger error.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Windows 7, it will indeed proceed and silently fallback to browser. This is considered OK, because we foresee no broker for Windows 7.