Skip to content

Support token type in bearer auth policy#7175

Open
rohitsinghal4u wants to merge 1 commit into
mainfrom
rohit/msi-token-binding-core-cpp
Open

Support token type in bearer auth policy#7175
rohitsinghal4u wants to merge 1 commit into
mainfrom
rohit/msi-token-binding-core-cpp

Conversation

@rohitsinghal4u

Copy link
Copy Markdown

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.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 BearerTokenAuthenticationPolicy to emit Authorization: <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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants