Skip to content

A negative token_lifetime must still mint an expired auth token - #12

Merged
dickhardt merged 1 commit into
mainfrom
fix/negative-token-lifetime
Sep 9, 2026
Merged

dickhardt merged 1 commit into
mainfrom
fix/negative-token-lifetime

Conversation

@dickhardt

Copy link
Copy Markdown
Member

Found while bumping aauth-proxy from mockin 2.0.0 to 3.x.

issueAuthToken clamps the lifetime so an auth token never outlives the token the agent presented (-11 §Auth Token Structure), and floors the result at 1s so a nearly-expired presented token cannot produce a negative lifetime. That floor also catches the token_lifetime mock switch when it is set negative — which is how a resource-side suite mints an already-expired auth token to drive its challenge-on-401 path. It got a token valid for one second instead, the challenge never fired, and two aauth-proxy component tests failed with a 200 where they expected a 401.

The floor now applies only when the configured lifetime is positive. A deliberately negative one passes through untouched.

One regression test in test/aauth/token.identity.spec.js. It mints the person token before setting the switch — token_lifetime shapes the person token too, and an expired presented token is a different (and correct) 400.

233 passing.

Note: 3.1.0 (require_capabilities) went to main as a direct push rather than a PR. My mistake — flagged to Dick.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CRdau7tgZa1tPVzUdyNrHc

The presented-token clamp (never outlive the token the agent presented)
floors the lifetime at 1s so a nearly-expired presented token cannot produce
a negative one. That floor also caught the mock switch a resource-side suite
uses to mint an ALREADY-expired auth token and drive its challenge-on-401
path: token_lifetime: -60 issued a token valid for one second, the challenge
never fired, and the suite failed with a 200 where it expected a 401.

Apply the floor only when the configured lifetime is positive.

233 passing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CRdau7tgZa1tPVzUdyNrHc
@dickhardt
dickhardt merged commit 9e5603b into main Sep 9, 2026
2 checks passed
@dickhardt
dickhardt deleted the fix/negative-token-lifetime branch September 9, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant