Repository navigation
FIX: honor tenant_id in AzureAuth - #3787
Open
Parinith (parinith-web) wants to merge 3 commits into
Open
Parinith (parinith-web) wants to merge 3 commits into
Parinith (parinith-web) wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The Azure tenant-ID forwarding change has no active review issues.
No open issues 🎉
What changed in this PR
Fixes #3788 by making AzureAuth forward a non-empty tenant_id when requesting an Azure access token, while preserving default behavior when no tenant is specified.
Changes:
- Passes the configured tenant ID to
DefaultAzureCredential.get_token. - Clarifies the
tenant_idparameter documentation. - Adds mock-based tests for tenant forwarding and omission.
| File | Description |
|---|---|
tests/unit/auth/test_azure_auth.py |
Adds tests for token requests with and without a tenant ID. |
pyrit/auth/azure_auth.py |
Forwards the tenant ID during token acquisition and clarifies its documented behavior. |
Review effort: Balanced
This branch has not been deployed
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.
Fixes #3788
Description
AzureAuthaccepted atenant_idargument and stored it asself._tenant_id, but never used it, so tokens were always requested for the default tenant. This is inconsistent withget_access_token_from_azure_cli, which does honortenant_id.DefaultAzureCredentialrejects atenant_idconstructor argument (it raisesTypeError), but itsget_tokenmethod acceptstenant_idand forwards it to each credential in the chain.AzureAuth._set_default_tokennow passestenant_idtoget_tokenwhen it is non-empty. Whentenant_idis empty (the default), the call is unchanged, so existing behavior is not affected. Thetenant_iddocstring is also clarified.This is not a breaking change.
Tests and Documentation
test_get_token_forwards_tenant_idandtest_get_token_omits_tenant_id_when_not_setintests/unit/auth/test_azure_auth.py. The first fails on the old code and passes with the fix.pytest tests/unit/auth/test_azure_auth.pypasses locally (36 passed, 4 skipped).