Honor access token type in bearer auth policy#49542
Open
rohitsinghal4u wants to merge 1 commit into
Open
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
⚠️ Not ready to approve
The new null/empty token-type fallback branch is not currently covered by tests, leaving the defaulting behavior unverified.
Pull request overview
Updates BearerTokenAuthenticationPolicy in azure-core to honor AccessToken.getTokenType() when forming the Authorization header, enabling non-Bearer schemes (e.g., Pop) while retaining Bearer as the default behavior.
Changes:
- Use
AccessToken(includingtokenType) when setting theAuthorizationheader in both async and sync flows. - Add new unit tests asserting that a non-default token type (e.g.,
Pop) is used in theAuthorizationheader.
File summaries
| File | Description |
|---|---|
| sdk/core/azure-core/src/main/java/com/azure/core/http/policy/BearerTokenAuthenticationPolicy.java | Switch header construction to incorporate AccessToken.getTokenType() with a fallback to Bearer. |
| sdk/core/azure-core/src/test/java/com/azure/core/http/policy/BearerTokenAuthenticationPolicyTests.java | Add async and sync tests validating that tokenType is reflected in the Authorization header. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 1
Note
Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.
| } | ||
| assertEquals("Pop token", authorizationHeader.get()); | ||
| } | ||
|
|
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.
Updates BearerTokenAuthenticationPolicy to use AccessToken.getTokenType() when setting the Authorization header. This is a Core prerequisite for PoP/MSI token binding flows while preserving Bearer as the default.\n\nValidation:\n- mvn -pl sdk/core/azure-core -Dtest=BearerTokenAuthenticationPolicyTests test -DskipCheckStyle=true -DskipRevapi=true -Dgpg.skip=true -q