Support token type in bearer auth policy#7175
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.
Pull request overview
This PR extends Azure::Core::Credentials::AccessToken with an optional TokenType field and updates BearerTokenAuthenticationPolicy to use that value as the Authorization header scheme (defaulting to Bearer when empty), enabling future PoP/MSI token binding scenarios while keeping existing behavior unchanged by default.
Changes:
- Added
AccessToken::TokenType(empty =>"Bearer"). - Updated
BearerTokenAuthenticationPolicyto emitAuthorization: <TokenType> <Token>when provided. - Added a unit test validating the non-default token type behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| sdk/core/azure-core/inc/azure/core/credentials/credentials.hpp | Adds AccessToken::TokenType to carry an auth scheme/token type for Authorization header construction. |
| sdk/core/azure-core/src/http/bearer_token_authentication_policy.cpp | Uses TokenType (or defaults to Bearer) when setting the authorization header. |
| sdk/core/azure-core/test/ut/bearer_token_authentication_policy_test.cpp | Adds coverage for emitting Authorization with a non-default token type. |
Comment on lines
+40
to
45
| /** | ||
| * @brief Token type used in the Authorization header. Empty means "Bearer". | ||
| * | ||
| */ | ||
| std::string TokenType; | ||
| }; |
Comment on lines
+83
to
85
| request.SetHeader( | ||
| "authorization", (token.TokenType.empty() ? "Bearer" : token.TokenType) + " " + token.Token); | ||
| } |
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.
Adds an optional AccessToken TokenType field and updates BearerTokenAuthenticationPolicy to use it 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- Not run locally: no C++ compiler is installed on this machine (cl, g++, clang++ unavailable).\n- CMake and Ninja were installed successfully.