-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[Key Vault] Add support for multi-tenant authentication #21290
Conversation
882eae0
to
e50dfb1
Compare
|
||
|
||
class AsyncChallengeAuthPolicy(ChallengeAuthPolicyBase, AsyncHTTPPolicy): | ||
class AsyncChallengeAuthPolicy(AsyncBearerTokenCredentialPolicy): |
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.
Could you give more context about this change?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
{AzureRecoveryServices} fixes Azure/azure-rest-api-specs#20953 (Azure#21290) * {AzureRecoveryServices} fixes Azure/azure-rest-api-specs#20953 fixes Azure/azure-rest-api-specs#20953 swagger link: https://github.com/Azure/azure-rest-api-specs/blob/main/specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2021-12-01/bms.json#L4362 example link: https://github.com/Azure/azure-rest-api-specs/blob/main/specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2021-12-01/examples/ResourceGuardProxyCRUD/PutResourceGuardProxy.json In the swagger file, there is no parameter named resourceGuardResourceId in ResourceGuardProxy_Put while in the example there is. the parameter is needed to create. * Update bms.json
Resolves #20698.
Context: now that
azure-identity
supports 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).