Repository navigation
FIX: Use the ai.azure.com audience for Azure AI identity auth - #4786
Merged
Behnam (behnam-o) merged 2 commits intoDec 1, 2026
Merged
Behnam (behnam-o) merged 2 commits into
Behnam (behnam-o) merged 2 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the endpoint-based Azure authentication scope change.
No open issues 🎉
What changed in this PR
Fixes Azure identity authentication for Foundry project endpoints by selecting the required https://ai.azure.com/.default scope while preserving the Cognitive Services scope for other endpoints.
Changes:
- Selects the token audience using the parsed endpoint hostname and project path.
- Adds parameterized tests for project endpoints, case variations, other hosts, and empty input.
| File | Description |
|---|---|
tests/unit/auth/test_azure_auth.py |
Tests endpoint-based audience selection and fallback behavior. |
pyrit/auth/azure_auth.py |
Adds Foundry project scope selection and updates its documentation. |
Review effort: Balanced
Bashir Partovi (bashirpartovi)
approved these changes
Dec 1, 2026
Bashir Partovi (bashirpartovi)
left a comment
Contributor
There was a problem hiding this comment.
LGTM
…peech Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Description
Identity auth requested a
https://cognitiveservices.azure.comtoken. AI Foundry project endpoints (*.services.ai.azure.com/api/projects/...) reject it with a 401 and accept onlyhttps://ai.azure.com.get_default_azure_scopenow returnshttps://ai.azure.com/.default, which Azure OpenAI, Foundry resource and project endpoints, and Content Safety all accept (Azure OpenAI v1 docs).