[Key Vault] Add support for multi-tenant authentication#21290
[Key Vault] Add support for multi-tenant authentication#21290mccoyp merged 15 commits intoAzure:mainfrom
Conversation
882eae0 to
e50dfb1
Compare
|
|
||
|
|
||
| class AsyncChallengeAuthPolicy(ChallengeAuthPolicyBase, AsyncHTTPPolicy): | ||
| class AsyncChallengeAuthPolicy(AsyncBearerTokenCredentialPolicy): |
There was a problem hiding this comment.
Could you give more context about this change?
There was a problem hiding this comment.
Just updated the PR description with more context!
...yvault-administration/azure/keyvault/administration/_internal/async_challenge_auth_policy.py
Outdated
Show resolved
Hide resolved
...ault/azure-keyvault-administration/azure/keyvault/administration/_internal/http_challenge.py
Outdated
Show resolved
Hide resolved
sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_shared/async_challenge_auth_policy.py
Outdated
Show resolved
Hide resolved
...yvault-administration/azure/keyvault/administration/_internal/async_challenge_auth_policy.py
Outdated
Show resolved
Hide resolved
...yvault-administration/azure/keyvault/administration/_internal/async_challenge_auth_policy.py
Outdated
Show resolved
Hide resolved
...ure-keyvault-certificates/azure/keyvault/certificates/_shared/async_challenge_auth_policy.py
Outdated
Show resolved
Hide resolved
...yvault-administration/azure/keyvault/administration/_internal/async_challenge_auth_policy.py
Outdated
Show resolved
Hide resolved
| """policy for handling HTTP authentication challenges""" | ||
|
|
||
| def __init__(self, credential: "AsyncTokenCredential", **kwargs: "Any") -> None: | ||
| def __init__(self, credential: "AsyncTokenCredential", *scopes: str, **kwargs: "Any") -> None: |
There was a problem hiding this comment.
I added an __init__ back in because _need_new_token made me realize that we shouldn't add any dependencies on private parent class fields. I had been referencing self._credential and self._token from the parent class before
|
|
||
| @property | ||
| def _need_new_token(self) -> bool: | ||
| # pylint:disable=invalid-overridden-method |
There was a problem hiding this comment.
I debated internally a bit over adding this override as a property. I suppressed this warning because the situation in azure-core is likely unintentional, where _need_new_token is a property for BearerTokenCredentialPolicy but a method for AsyncBearerTokenCredentialPolicy. Assuming that will be changed in the future, we can remove this suppression, but I figured that makes more sense than re-implementing the property/method pattern here for the sake of consistency
...ure-keyvault-administration/azure/keyvault/administration/_internal/challenge_auth_policy.py
Outdated
Show resolved
Hide resolved
…into add_webpubsub_tests * 'main' of https://github.com/Azure/azure-sdk-for-python: [Key Vault] Add support for multi-tenant authentication (Azure#21290) [webpubsub] regen with hub as a client parameter (Azure#21688) update automatic close mechanism (Azure#21580) [Test Proxy] Add fixture to automatically start/stop Docker container (Azure#21538) Update Monitor Query API ref link (Azure#21683) Migration Guide from Azure-loganalytics (Azure#21674) Update docs for Web PubSub GA (Azure#21659) Update CHANGELOG.md (Azure#21681) Increment version for formrecognizer releases (Azure#21678) Increment version for videoanalyzer releases (Azure#21455) Increment version for cognitivelanguage releases (Azure#21566) Increment version for storage releases (Azure#21652) Increment version for communication releases (Azure#21667) raise decode error instead of ContentDecodingError (Azure#19433) Update CHANGELOG.md (Azure#21679) resolve mac agent failure (Azure#21677) Re-add get-codeowners.ps1 (Azure#21676) [SchemaRegistry] remove schema prefix in params (Azure#21675) Validate python docs packages using docker (Azure#21657) update git helper (Azure#21670)
Resolves #20698.
Context: now that
azure-identitysupports providing a tenant ID to token requests, we can allow Key Vault clients to make use of tenant discovery. This updates the challenge authentication policy to parse out the tenant ID provided in a challenge and authenticate requests with that tenant. Based off of work Charles did in his fork of the repo, this also updates the challenge auth policy to inherit fromazure-core's BearerTokenCredentialPolicy instead of re-implementing the wheel. As a result, doing so also requiresazure-core>= 1.15.0 (see changelog).