Repository navigation
fix(abstractions): validate allowed hosts and access token provider in BaseBearerTokenAuthenticationProvider - #867
Merged
Vincent Biret (baywet) merged 2 commits intoNov 9, 2026
Conversation
Contributor
Author
|
While testing URL template expansion and authentication flows against edge-case payloads, I noticed a few discrepancies in
All 229 unit tests pass cleanly alongside static typing and formatting checks. When you have a moment, please take a look. Thanks! |
This was referenced Nov 7, 2026
Vincent Biret (baywet)
requested changes
Nov 9, 2026
…n BaseBearerTokenAuthenticationProvider Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
…rovider allowed hosts and provider validation Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
Hardik K (hardikkaurani)
force-pushed
the
fix/uri-normalization-and-bearer-auth-validation
branch
from
November 9, 2026 20:15
f520525 to
e3675d9
Compare
|
Contributor
Author
|
Vincent Biret (@baywet) Re-scoped this PR exclusively to the As requested, I've moved the parameter collection sanitization and ISO duration component validation changes over to a separate PR: #883. |
Vincent Biret (baywet)
approved these changes
Nov 9, 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.



Overview
In accordance with Kiota's architectural specification across languages (.NET, Go, Java, TypeScript),
BaseBearerTokenAuthenticationProvider.authenticate_requestmust verify whether the target URI's host is approved by the access token provider'sAllowedHostsValidator.As requested by maintainer Vincent Biret (@baywet) in #867 (comment), this PR has been scoped exclusively to the
BaseBearerTokenAuthenticationProviderchanges. The parameter collection sanitization and ISO duration validation changes have been moved to a separate PR: #883.Problems Addressed
Unchecked Request Host in
authenticate_request:authenticate_requestwas retrieving tokens and populating theAuthorizationheader regardless of whetherrequest.urlbelonged to an approved host.authenticate_requestto validateis_url_host_valid(request.url)before acquiring tokens or modifying headers, preventing credentials from leaking to unapproved hosts.Null
access_token_providerin__init__:BaseBearerTokenAuthenticationProvider.__init__to raiseValueError("Access token provider cannot be null")ifaccess_token_provideris null.Changes
packages/abstractions/kiota_abstractions/authentication/base_bearer_token_authentication_provider.py:access_token_providerin__init__.request.urlhost is not in allowed hosts before attempting token retrieval.packages/abstractions/tests/authentication/test_base_bearer_token_authentication.py:Verification
pytest: 216 passed.mypy kiota_abstractions: clean (no issues in 48 source files).