-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[Core] Add workaround for cross-tenant authentication with Track 2 SDKs #16797
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 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -198,14 +198,11 @@ def _get_mgmt_service_client(cli_ctx, | |
| # https://github.com/Azure/azure-sdk-for-python/issues/8313 | ||
| # As a temporary workaround, manually add external tokens to 'x-ms-authorization-auxiliary' header. | ||
| # https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/authenticate-multi-tenant | ||
| if aux_subscriptions or aux_tenants: | ||
| if getattr(cred, "_external_tenant_token_retriever", None): | ||
| _, _, _, external_tenant_tokens = cred.get_all_tokens(*resource_to_scopes(resource)) | ||
|
||
|
|
||
| # external_tenant_tokens can be [] if no external tenant is involved. | ||
| if external_tenant_tokens: | ||
| # Hard-code scheme to 'Bearer' as _BearerTokenCredentialPolicyBase._update_headers does. | ||
| client_kwargs['headers']['x-ms-authorization-auxiliary'] = \ | ||
| ', '.join("Bearer {}".format(t[1]) for t in external_tenant_tokens) | ||
| # Hard-code scheme to 'Bearer' as _BearerTokenCredentialPolicyBase._update_headers does. | ||
| client_kwargs['headers']['x-ms-authorization-auxiliary'] = \ | ||
| ', '.join("Bearer {}".format(t[1]) for t in external_tenant_tokens) | ||
|
Member
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. Is there a pipeline support?
Member
Author
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. I will make a new policy and add it to the pipeline in the future, utilizing Azure/azure-sdk-for-python#17340. |
||
|
|
||
| if subscription_bound: | ||
| client = client_type(cred, subscription_id, **client_kwargs) | ||
|
|
||
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.
CLIError is deprecated.
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.
This error is difficult to classify.