-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Added code to handle claims in authentication challenges #41814
Conversation
API change check API changes are not detected in this pull request. |
...java/com/azure/security/keyvault/administration/implementation/KeyVaultCredentialPolicy.java
Outdated
Show resolved
Hide resolved
...java/com/azure/security/keyvault/administration/implementation/KeyVaultCredentialPolicy.java
Outdated
Show resolved
Hide resolved
…en is revoked immediately after acquiring it for the first time.
…all. Added async functionality for CAE.
...n/src/test/java/com/azure/security/keyvault/administration/KeyVaultCredentialPolicyTest.java
Outdated
Show resolved
Hide resolved
...n/src/test/java/com/azure/security/keyvault/administration/KeyVaultCredentialPolicyTest.java
Outdated
Show resolved
Hide resolved
...-secrets/src/test/java/com/azure/security/keyvault/secrets/KeyVaultCredentialPolicyTest.java
Outdated
Show resolved
Hide resolved
...c/main/java/com/azure/security/keyvault/secrets/implementation/KeyVaultCredentialPolicy.java
Outdated
Show resolved
Hide resolved
...-secrets/src/test/java/com/azure/security/keyvault/secrets/KeyVaultCredentialPolicyTest.java
Outdated
Show resolved
Hide resolved
…p if the client received multiple consecutive 401 unauthorized requests without claims.
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 only looked at the first KeyVaultCredentialPolicy
as I assumed they're all the same. If they are all the same, does anything get done to make sure they don't skew in design over time?
...java/com/azure/security/keyvault/administration/implementation/KeyVaultCredentialPolicy.java
Outdated
Show resolved
Hide resolved
...java/com/azure/security/keyvault/administration/implementation/KeyVaultCredentialPolicy.java
Outdated
Show resolved
Hide resolved
...java/com/azure/security/keyvault/administration/implementation/KeyVaultCredentialPolicy.java
Outdated
Show resolved
Hide resolved
...java/com/azure/security/keyvault/administration/implementation/KeyVaultCredentialPolicy.java
Outdated
Show resolved
Hide resolved
...java/com/azure/security/keyvault/administration/implementation/KeyVaultCredentialPolicy.java
Outdated
Show resolved
Hide resolved
...java/com/azure/security/keyvault/administration/implementation/KeyVaultCredentialPolicy.java
Outdated
Show resolved
Hide resolved
...n/src/test/java/com/azure/security/keyvault/administration/KeyVaultCredentialPolicyTest.java
Show resolved
Hide resolved
...n/src/test/java/com/azure/security/keyvault/administration/KeyVaultCredentialPolicyTest.java
Outdated
Show resolved
Hide resolved
Unfortunately, we don't have a shared Key Vault package that we could put the policy into, and I don't feel that comfortable adding it onto Azure Core as is. Maybe I could come up with a better name for it and with some tweaks we can make it reusable for other cases (Tables uses a very similar authentication challenge system). |
### Packages impacted by this PR - `@azure/keyvault-common` - Downstream Key Vault packages ### Issues associated with this PR - Private ### Describe the problem that is addressed by this PR In future, the Key Vault service will be adding support for Continuous Access Evaluation (CAE). This PR adds the necessary support to the SDK's challenge-based authentication policy to enable this feature. After the initial challenge, with CAE enabled, any future request may result in a 401 response, even if the access token used is valid. This PR adds a new policy that handles this CAE challenge alongside the normal challenge. The new policy replaces the existing use of Core's `bearerTokenAuthenticationPolicy`, which is no longer suitable for this use case since it cannot handle a CAE challenge that comes immediately after a regular challenge. ### Are there test cases added in this PR? _(If not, why?)_ Yes, added test cases with mock requests and responses to cover a number of different scenarios, ensuring the policy is doing the right thing. I also manually tested against a test resource provided by the Key Vault team which returns a CAE challenge in response to any authorized request to the vault, and got the expected result (a normal challenge handled successfully, followed by a CAE challenge handled successfully, followed by another CAE challenge which the policy does not handle). ### Provide a list of related PRs _(if any)_ - Java PR for same feature: Azure/azure-sdk-for-java#41814
An access token can be revoked at any point by the service, after which the service will return a 401 Unauthorized response with a WWW-Authenticate header. This header will include claims for the client to decode and include in a subsequent auth request.
If everything goes right, the client will be provided a new and valid access token.