Skip to content

feat(config): make JWT expiration configurable via environment variable#135

Merged
appleboy merged 1 commit intomainfrom
worktree-auth
Mar 28, 2026
Merged

feat(config): make JWT expiration configurable via environment variable#135
appleboy merged 1 commit intomainfrom
worktree-auth

Conversation

@appleboy
Copy link
Copy Markdown
Member

Summary

  • Replace hardcoded 1-hour JWTExpiration with configurable JWT_EXPIRATION env var (supports 5m, 1h, 30s etc.)
  • Add startup validation to reject zero or negative duration values
  • Prerequisite for future stateless JWT validation mode (short-lived access tokens)

Changes

  • internal/config/config.go: Use getEnvDuration("JWT_EXPIRATION", time.Hour) instead of hardcoded time.Hour; add validation in Validate()
  • internal/config/config_test.go: Add JWTExpiration to all existing test configs; add new tests for env var parsing, default value, and validation

Test plan

  • make test — all config tests pass
  • make lint — 0 issues
  • Verify JWT_EXPIRATION=5m ./bin/authgate server uses 5-minute token expiry
  • Verify unset JWT_EXPIRATION defaults to 1 hour

🤖 Generated with Claude Code

- Replace hardcoded 1-hour JWT expiration with configurable JWT_EXPIRATION env var
- Add validation to reject zero or negative duration values at startup
- Add tests for env var parsing, default value, and validation rules
- Update existing config tests to include JWTExpiration field

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@appleboy appleboy merged commit af2221c into main Mar 28, 2026
17 checks passed
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