fix(auth): handle Azure AD v1 tokens in OAuth claim validation#4159
Open
ecthelion77 wants to merge 1 commit intoIBM:mainfrom
Open
fix(auth): handle Azure AD v1 tokens in OAuth claim validation#4159ecthelion77 wants to merge 1 commit intoIBM:mainfrom
ecthelion77 wants to merge 1 commit intoIBM:mainfrom
Conversation
Contributor
Author
|
Suggested labels: |
466d542 to
c6137c4
Compare
db09914 to
6b22ba2
Compare
…idation Signed-off-by: Olivier Gintrand <olivier.gintrand@forterro.com>
6b22ba2 to
de02c9e
Compare
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.
🐛 Bug-fix PR
🔗 Issue
Closes #4158
📌 Summary
The token claim validation introduced in #3941 produces false-positive blocking errors for Azure AD tokens, preventing valid OAuth gateways from fetching tools. Three issues are fixed:
Audience: Azure AD v1 tokens use
client_id(GUID) as audience when scopes use{client_id}/.default. The validator now acceptsclient_idandapi://{client_id}as valid audiences alongside the configuredresource.Issuer: Azure AD v1 tokens use
iss=https://sts.windows.net/{tenant}/while v2 useshttps://login.microsoftonline.com/{tenant}/v2.0. Same tenant, different URL. The validator now detects Entra v1/v2 duality and accepts both when the tenant ID matches.Scopes: OIDC meta-scopes (
openid,offline_access,profile,email) and Azure AD/.defaultscopes are request-time directives that never appear in the access tokenscpclaim. The validator now skips them from the missing-scope check.🔁 Reproduction Steps
authorization_codegrant)["{client_id}/.default", "openid", "offline_access"]🐞 Root Cause
_validate_audience()did not considerclient_idas a valid audience._validate_issuer()did not handle Azure AD v1/v2 issuer URL duality._validate_scopes()treated OIDC meta-scopes and/.defaultas required token claims.💡 Fix Description
_validate_audience(): build a set of acceptable audiences includingclient_idandapi://{client_id}_validate_issuer(): extract tenant from v1 (sts.windows.net/{tenant}) and v2 (login.microsoftonline.com/{tenant}/v2.0) URLs, accept both if tenant matches_validate_scopes(): skipopenid,offline_access,profile,email, and any scope ending with/.default🧪 Verification
make lintmake testmake coverage📐 MCP Compliance
✅ Checklist
token_validation_service.py)