Skip to content
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

rename use_operating_system_account to use_default_broker_account #34833

Merged
merged 2 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/identity/azure-identity-broker/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Features Added

- `InteractiveBrowserBrokerCredential` now supports a `use_operating_system_account` property to enable the use of the currently logged in operating system account for authentication rather than prompting for a credential.
- `InteractiveBrowserBrokerCredential` now supports a `use_default_broker_account` property to enable the use of the currently logged in operating system account for authentication rather than prompting for a credential.
- Added `enable_support_logging` as a keyword argument to `InteractiveBrowserBrokerCredential`. This allows additional support logging which may contain PII.

### Breaking Changes
Expand Down
8 changes: 8 additions & 0 deletions sdk/identity/azure-identity-broker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ Microsoft Entra applications rely on redirect URIs to determine where to send th
ms-appx-web://Microsoft.AAD.BrokerPlugin/{client_id}
```

## Use the default account for sign-in

When this option is specified the credential will attempt to silently use the default broker account. If using the default account fails, the credential will fall back to interactive authentication.
xiangyan99 marked this conversation as resolved.
Show resolved Hide resolved

```
cred = new InteractiveBrowserBrokerCredential(use_default_broker_account=True)
```

## Examples

### Authenticate with `InteractiveBrowserBrokerCredential`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class InteractiveBrowserBrokerCredential(_InteractiveBrowserCredential):
:keyword int timeout: seconds to wait for the user to complete authentication. Defaults to 300 (5 minutes).
:keyword int parent_window_handle: If your app is a GUI app running on a modern Windows system, you are required to
also provide its window handle so that the sign in UI window will properly pop up on top of your window.
:keyword bool use_operating_system_account: Whether to authenticate with the currently signed in user instead of
:keyword bool use_default_broker_account: Whether to authenticate with the currently signed in user instead of
prompting the user with a login dialog. Defaults to False.
:keyword bool enable_msa_passthrough: Determines whether Microsoft Account (MSA) passthrough is enabled. Note, this
is only needed for select legacy first-party applications. Defaults to False.
Expand All @@ -57,7 +57,7 @@ class InteractiveBrowserBrokerCredential(_InteractiveBrowserCredential):
def __init__(self, **kwargs: Any) -> None:
self._parent_window_handle = kwargs.pop("parent_window_handle", None)
self._enable_msa_passthrough = kwargs.pop("enable_msa_passthrough", False)
self._use_operating_system_account = kwargs.pop("use_operating_system_account", False)
self._use_default_broker_account = kwargs.pop("use_default_broker_account", False)
super().__init__(**kwargs)

@wrap_exceptions
Expand All @@ -67,7 +67,7 @@ def _request_token(self, *scopes: str, **kwargs: Any) -> Dict:
app = self._get_app(**kwargs)
port = self._parsed_url.port if self._parsed_url else None

if self._use_operating_system_account:
if self._use_default_broker_account:
try:
result = app.acquire_token_interactive(
scopes=scopes,
Expand Down
2 changes: 1 addition & 1 deletion sdk/identity/azure-identity-broker/tests/test_broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_interactive_browser_broker_cred_signed_in_account():
with patch("msal.broker._signin_silently", Mock(return_value="token")) as mock_signin_silently:
try:
cred = InteractiveBrowserBrokerCredential(
parent_window_handle="window_handle", use_operating_system_account=True
parent_window_handle="window_handle", use_default_broker_account=True
)
cred.get_token("scope")
except Exception: # msal raises TypeError which is expected. We are not testing msal here.
Expand Down