feat: configurable token TTL via request field and env var#135
Merged
farovictor merged 1 commit intomainfrom Apr 6, 2026
Merged
feat: configurable token TTL via request field and env var#135farovictor merged 1 commit intomainfrom
farovictor merged 1 commit intomainfrom
Conversation
- config.TokenTTL() reads BIFROST_TOKEN_TTL (Go duration string), defaults to 24h
- POST /v1/users accepts optional "ttl" field (e.g. "30m", "1h")
- POST /v1/token/refresh accepts optional JSON body {"ttl":"..."}
- POST /v1/setup uses config.TokenTTL() (no per-request override needed for bootstrap)
- Invalid TTL strings return 400 Bad Request
- 6 tests: default TTL, custom TTL, and invalid TTL for both endpoints
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.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.
Summary
BIFROST_TOKEN_TTLenv var sets the server-wide default token lifetime (any Go duration string, e.g.1h,30m); defaults to24h— no breaking changePOST /v1/usersaccepts optional"ttl"field to override per-requestPOST /v1/token/refreshaccepts optional JSON body{"ttl":"..."}to override per-request400 Bad RequestUse case
CI/CD pipelines and ephemeral environments can request very short-lived management tokens without having to wait for a 24h expiry or run a separate invalidation step.
Test plan
TestCreateUser_DefaultTTL— token expires in ~24h when no ttl givenTestCreateUser_CustomTTL— token expires in ~30m when"ttl":"30m"TestCreateUser_InvalidTTL— 400 on bad duration stringTestRefreshToken_DefaultTTL— refreshed token expires in ~24hTestRefreshToken_CustomTTL— refreshed token expires in ~15m when"ttl":"15m"TestRefreshToken_InvalidTTL— 400 on bad duration string🤖 Generated with Claude Code