fix: increase SSO authorization code max_length from 512 to 4096 (Entra ID regression)#4491
fix: increase SSO authorization code max_length from 512 to 4096 (Entra ID regression)#4491ecthelion77 wants to merge 1 commit intoIBM:mainfrom
Conversation
Entra ID (Microsoft) v2 authorization codes can exceed 1500 characters. The previous 512 limit caused HTTP 422 on SSO callback, breaking login. Fixes: string_too_long validation error on /api/v1/sso/callback Signed-off-by: Olivier Gintrand <[email protected]>
|
Hey @bogdanmariusc10 — this is a follow-up to your PR #4337 which added input validation to SSO query parameters. The Would appreciate your review since you authored the original validation constraints. The fix simply bumps |
bogdanmariusc10
left a comment
There was a problem hiding this comment.
Hello, @ecthelion77 ! Thank you for the observation and contribution!
LGTM!
🐛 Bug-fix PR
Fixes #4490
📌 Summary
The SSO callback endpoint rejects valid Microsoft Entra ID authorization codes with HTTP 422 because the
codequery parameter is limited tomax_length=512. Entra ID v2 authorization codes routinely exceed 1500 characters, completely breaking SSO login for all Azure AD / Entra ID users.This is a regression introduced when input validation constraints were added to SSO parameters.
🔁 Reproduction Steps
/api/v1/sso/callback?code=<1500+ char code>&state=...string_too_longoncodeparameterSee issue #4490 for full details and error payload.
🐞 Root Cause
In
mcpgateway/routers/sso.py, thecodeparameter hasmax_length=512:Microsoft Entra ID v2 authorization codes are 1200–2000+ characters. The 512 limit triggers a Pydantic validation error before token exchange.
💡 Fix Description
Increase
max_lengthfrom 512 to 4096 for thecodequery parameter.Change
🧪 Verification
make lintmake test📐 MCP Compliance
✅ Checklist