Skip to content

feat: configurable token TTL via request field and env var#135

Merged
farovictor merged 1 commit intomainfrom
feat/configurable-token-ttl
Apr 6, 2026
Merged

feat: configurable token TTL via request field and env var#135
farovictor merged 1 commit intomainfrom
feat/configurable-token-ttl

Conversation

@farovictor
Copy link
Copy Markdown
Owner

Summary

  • BIFROST_TOKEN_TTL env var sets the server-wide default token lifetime (any Go duration string, e.g. 1h, 30m); defaults to 24h — no breaking change
  • POST /v1/users accepts optional "ttl" field to override per-request
  • POST /v1/token/refresh accepts optional JSON body {"ttl":"..."} to override per-request
  • Invalid duration strings return 400 Bad Request

Use 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 given
  • TestCreateUser_CustomTTL — token expires in ~30m when "ttl":"30m"
  • TestCreateUser_InvalidTTL — 400 on bad duration string
  • TestRefreshToken_DefaultTTL — refreshed token expires in ~24h
  • TestRefreshToken_CustomTTL — refreshed token expires in ~15m when "ttl":"15m"
  • TestRefreshToken_InvalidTTL — 400 on bad duration string

🤖 Generated with Claude Code

- 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>
@farovictor farovictor self-assigned this Apr 6, 2026
@farovictor farovictor merged commit 9a7cd2c into main Apr 6, 2026
8 checks passed
@farovictor farovictor deleted the feat/configurable-token-ttl branch April 6, 2026 22:05
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