Fixed inconsistent teams claim structure in Auth tokens#2191
Merged
crivetimihai merged 2 commits intomainfrom Jan 20, 2026
Merged
Fixed inconsistent teams claim structure in Auth tokens#2191crivetimihai merged 2 commits intomainfrom
crivetimihai merged 2 commits intomainfrom
Conversation
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Add tests to verify that login tokens emit teams as List[str] (team IDs only) to match /tokens behavior. This prevents regression of issue #1486 where UUID team IDs were incorrectly cast to int. Tests added: - test_create_access_token_teams_are_list_of_strings - test_create_access_token_admin_omits_teams Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
1957d73 to
87a5691
Compare
Member
Review NotesThe fix is correct and tests pass. Added a regression test to prevent this issue from recurring. Follow-up RecommendationFor full consistency, # Current (dict format):
token_data["teams"] = [{"id": team.id, "name": team.name, "slug": team.slug, ...} for team in teams]
# Recommended (string IDs only, matching /tokens and /auth/login):
token_data["teams"] = [team.id for team in teams]This isn't blocking because:
Consider addressing this in a separate PR for complete alignment across all token generation paths. Created: Align SSO service teams claim format with /tokens and /auth/login #2233 |
crivetimihai
approved these changes
Jan 20, 2026
This was referenced Jan 20, 2026
kcostell06
pushed a commit
to kcostell06/mcp-context-forge
that referenced
this pull request
Feb 24, 2026
* token generation consistency Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com> * test: Add regression test for teams claim format in login tokens Add tests to verify that login tokens emit teams as List[str] (team IDs only) to match /tokens behavior. This prevents regression of issue IBM#1486 where UUID team IDs were incorrectly cast to int. Tests added: - test_create_access_token_teams_are_list_of_strings - test_create_access_token_admin_omits_teams Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> --------- Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com> Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> Co-authored-by: Mihai Criveti <crivetimihai@gmail.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.
🐛 Bug-fix PR
📌 Summary
Closes #1486 (Details: #1486 (comment))
Refactored the
/auth/logintoken generation to align the teams claim structure with the/tokensendpoint. Previously, login tokens returned teams as a list of dictionaries, while API tokens returned them as a list of strings (IDs). This change ensures consistency across all token types by standardizing on a list of team IDs.🔁 Reproduction Steps
POST /tokens. Inspect the JWT: teams is ["team_id_1", "team_id_2"].POST /auth/login. Inspect the JWT: teams was [{"id": ..., "name": ...}].🐞 Root Cause
Two issues were identified in
mcpgateway/routers/email_auth.pywithin create_access_token:💡 Fix Description
Modified
mcpgateway/routers/email_auth.py:🧪 Verification
make lintmake testmake coverage📐 MCP Compliance (if relevant)
✅ Checklist
make black isort pre-commit)