Skip to content

425 SECURITYFEATURE Make JWT Token Expiration Mandatory when REQUIRE_TOKEN_EXPIRATION=true#632

Merged
madhav165 merged 5 commits intoIBM:mainfrom
Nayana-R-Gowda:425-SECURITYFEATURE
Jul 29, 2025
Merged

425 SECURITYFEATURE Make JWT Token Expiration Mandatory when REQUIRE_TOKEN_EXPIRATION=true#632
madhav165 merged 5 commits intoIBM:mainfrom
Nayana-R-Gowda:425-SECURITYFEATURE

Conversation

@Nayana-R-Gowda
Copy link
Copy Markdown
Collaborator

@Nayana-R-Gowda Nayana-R-Gowda commented Jul 29, 2025

📌 Summary

What problem does this PR fix and why?
This PR ensures that JWT tokens must include an expiration claim (exp) when the REQUIRE_TOKEN_EXPIRATION setting is set to true

💡 Fix Description

How did you solve it? Key design points.
Added a REQUIRE_TOKEN_EXPIRATION config flag to enforce or warn on missing exp claims in JWTs.
Updated verify_jwt_token to reject or log based on this setting, and enhanced CLI to warn on non-expiring tokens.
Ensures security compliance while allowing flexibility for automation use cases.

🧪 Verification

Check Command Status
Lint suite make lint pass
Unit tests make test pass

📐 MCP Compliance (if relevant)

  • Matches current MCP spec
  • No breaking change to MCP clients

✅ Checklist

  • Code formatted (make black isort pre-commit)
  • No secrets/credentials committed

Signed-off-by: NAYANAR <nayana.r5@ibm.com>
Signed-off-by: NAYANAR <nayana.r5@ibm.com>
Signed-off-by: NAYANAR <nayana.r5@ibm.com>
@madhav165 madhav165 linked an issue Jul 29, 2025 that may be closed by this pull request
14 tasks
Copy link
Copy Markdown
Collaborator

@madhav165 madhav165 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Nayana-R-Gowda This test seems to be failing

Test 2: Strict mode

export REQUIRE_TOKEN_EXPIRATION=true
curl -H "Authorization: Bearer $NO_EXP_TOKEN" http://localhost:4444/version

This is returning data instead of returning 401. Please check.

@madhav165 madhav165 added the bug Something isn't working label Jul 29, 2025
@madhav165 madhav165 added this to the Release 0.5.0 milestone Jul 29, 2025
@crivetimihai crivetimihai changed the title 425 SECURITYFEATURE 425 SECURITYFEATURE Make JWT Token Expiration Mandatory when REQUIRE_TOKEN_EXPIRATION=true Jul 29, 2025
Copy link
Copy Markdown
Collaborator

@madhav165 madhav165 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test 2 seems to be working fine after setting export REQUIRE_TOKEN_EXPIRATION=false before running the gateway

Signed-off-by: NAYANAR <nayana.r5@ibm.com>
@madhav165 madhav165 merged commit a5e04a7 into IBM:main Jul 29, 2025
36 checks passed
vk-playground pushed a commit to vk-playground/mcp-context-forge that referenced this pull request Sep 14, 2025
make test smoketest doctest passed

Signed-off-by: Madhav Kandukuri <madhav165@users.noreply.github.com>
vk-playground pushed a commit to vk-playground/mcp-context-forge that referenced this pull request Sep 14, 2025
vk-playground pushed a commit to vk-playground/mcp-context-forge that referenced this pull request Sep 16, 2025
make test smoketest doctest passed
Signed-off-by: Vicky Kuo <vicky.kuo@ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE][SECURITY]: Make JWT token expiration mandatory

3 participants