Support azure.keyvault.access-token in azure-security-keyvault-jca#47850
Merged
Support azure.keyvault.access-token in azure-security-keyvault-jca#47850
azure.keyvault.access-token in azure-security-keyvault-jca#47850Conversation
…ken property Co-authored-by: rujche <171773178+rujche@users.noreply.github.com>
Co-authored-by: rujche <171773178+rujche@users.noreply.github.com>
Co-authored-by: rujche <171773178+rujche@users.noreply.github.com>
…mprove docs Co-authored-by: rujche <171773178+rujche@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add support for bearer tokens in azure-security-keyvault-jca
Add bearer token authentication support via azure.keyvault.access-token
Jan 29, 2026
rujche
reviewed
Jan 29, 2026
...y-keyvault-jca/src/main/java/com/azure/security/keyvault/jca/KeyVaultLoadStoreParameter.java
Outdated
Show resolved
Hide resolved
…ameter Co-authored-by: rujche <171773178+rujche@users.noreply.github.com>
rujche
reviewed
Jan 29, 2026
rujche
reviewed
Jan 29, 2026
…w feedback Co-authored-by: rujche <171773178+rujche@users.noreply.github.com>
rujche
reviewed
Jan 29, 2026
...eyvault-jca/src/main/java/com/azure/security/keyvault/jca/implementation/KeyVaultClient.java
Show resolved
Hide resolved
rujche
reviewed
Jan 29, 2026
...eyvault-jca/src/main/java/com/azure/security/keyvault/jca/implementation/KeyVaultClient.java
Outdated
Show resolved
Hide resolved
…ble naming Co-authored-by: rujche <171773178+rujche@users.noreply.github.com>
Member
|
/azp run java - keyvault tests |
|
No pipelines are associated with this pull request. |
Member
azure.keyvault.access-token in azure-security-keyvault-jca
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request adds support for bearer token authentication via the new azure.keyvault.access-token system property to the Azure Key Vault JCA library. This enhancement enables users to provide pre-obtained access tokens for authentication without requiring client credentials, supporting multi-factor authentication scenarios.
Changes:
- Added bearer token authentication support with proper authentication priority: Managed Identity > Access Token > Client Credentials
- Implemented token lifecycle management where provided tokens don't auto-refresh, and expiration is handled by Azure returning authentication errors
- Consolidated and improved test coverage for Key Vault client authentication scenarios
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/keyvault/azure-security-keyvault-jca/src/main/java/com/azure/security/keyvault/jca/implementation/KeyVaultClient.java | Added providedAccessToken field and authentication priority logic in obtainAccessToken method; renamed getAccessTokenByHttpRequest to obtainAccessToken |
| sdk/keyvault/azure-security-keyvault-jca/src/main/java/com/azure/security/keyvault/jca/KeyVaultLoadStoreParameter.java | Added accessToken field and constructor parameter to support passing access tokens |
| sdk/keyvault/azure-security-keyvault-jca/src/main/java/com/azure/security/keyvault/jca/KeyVaultKeyStore.java | Updated to read azure.keyvault.access-token system property and pass to KeyVaultCertificates |
| sdk/keyvault/azure-security-keyvault-jca/src/main/java/com/azure/security/keyvault/jca/implementation/certificates/KeyVaultCertificates.java | Added accessToken parameter to constructors and updateKeyVaultClient methods |
| sdk/keyvault/azure-security-keyvault-jca/src/main/java/com/azure/security/keyvault/jca/implementation/model/AccessToken.java | Added constructor accepting accessToken and expiresIn parameters for creating AccessToken instances from provided tokens |
| sdk/keyvault/azure-security-keyvault-jca/src/test/java/com/azure/security/keyvault/jca/implementation/KeyVaultClientTest.java | Added comprehensive tests for access token authentication and authentication priority; consolidated integration tests from removed file |
| sdk/keyvault/azure-security-keyvault-jca/src/test/java/com/azure/security/keyvault/jca/KeyVaultClientTest.java | Removed duplicate test file; tests consolidated into implementation package |
| sdk/keyvault/azure-security-keyvault-jca/README.md | Added documentation for the new azure.keyvault.access-token property |
| sdk/keyvault/azure-security-keyvault-jca/CHANGELOG.md | Added feature entry describing bearer token authentication support |
...ult-jca/src/test/java/com/azure/security/keyvault/jca/implementation/KeyVaultClientTest.java
Outdated
Show resolved
Hide resolved
...ult-jca/src/test/java/com/azure/security/keyvault/jca/implementation/KeyVaultClientTest.java
Show resolved
Hide resolved
...ult-jca/src/test/java/com/azure/security/keyvault/jca/implementation/KeyVaultClientTest.java
Show resolved
Hide resolved
Netyyyy
reviewed
Jan 30, 2026
...n/java/com/azure/security/keyvault/jca/implementation/certificates/KeyVaultCertificates.java
Outdated
Show resolved
Hide resolved
Netyyyy
reviewed
Jan 30, 2026
...n/java/com/azure/security/keyvault/jca/implementation/certificates/KeyVaultCertificates.java
Outdated
Show resolved
Hide resolved
…/azure-sdk-for-java into copilot/support-bearer-tokens-auth
Netyyyy
approved these changes
Feb 2, 2026
Contributor
API Change CheckAPIView identified API level changes in this PR and created the following API reviews |
Netyyyy
approved these changes
Feb 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Implementation Complete: ****** Authentication Support
Summary
This PR adds support for bearer token authentication via the new
azure.keyvault.access-tokensystem property. This enhancement enables users to:Changes Made
Core Implementation:
providedAccessTokenfield toKeyVaultClientwith proper authentication priority logicLong.MAX_VALUE / 1000(effectively infinite) to prevent futile auto-refresh attemptsKeyVaultLoadStoreParameterto accept and pass access tokens through the main constructorKeyVaultCertificatesandKeyVaultKeyStoreto support the new authentication methodAccessTokenmodel for creating instances from provided tokensgetAccessTokenByHttpRequesttoobtainAccessTokento accurately reflect its behaviorDocumentation:
Testing:
testAccessTokenAuthentication)testAuthenticationPriority)Authentication Priority
The implementation ensures the following priority order in code:
azure.keyvault.managed-identity) - Highest priorityazure.keyvault.access-token) - Middle priorityazure.keyvault.client-id+azure.keyvault.client-secret) - Lowest priorityToken Lifecycle
Provided access tokens do not auto-refresh. The token is set with effectively infinite expiration to prevent the code from attempting to refresh it. When the actual token expires on Azure's side, authentication requests will fail with runtime exceptions, which correctly informs users they need to provide a fresh token through the
azure.keyvault.access-tokensystem property.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.