docs/plans/2025-12-26-token-duration-settings-design.md
Add configurable settings for access token and refresh token durations in workspace settings.
Bytebase previously supported only "access tokens" which behaved like refresh tokens (long-lived, 7 days default). The existing token_duration setting and FEATURE_SIGN_IN_FREQUENCY_CONTROL feature flag are legacy naming from this era.
This change properly separates token types with distinct settings:
Store proto (proto/store/store/setting.proto):
message WorkspaceProfileSetting {
// ... existing fields 1-3 ...
// RENAME: token_duration → refresh_token_duration (same field number 4)
google.protobuf.Duration refresh_token_duration = 4;
// NEW: access_token_duration
google.protobuf.Duration access_token_duration = 18;
// ... rest unchanged ...
}
V1 proto (proto/v1/v1/setting_service.proto):
WorkspaceProfileSetting messageSQL migration to rename existing JSON key in stored settings:
UPDATE setting
SET value = jsonb_set(
value - 'tokenDuration',
'{refreshTokenDuration}',
value->'tokenDuration'
)
WHERE name = 'WORKSPACE_PROFILE'
AND value ? 'tokenDuration';
backend/api/auth/header.go:
GetTokenDuration() → GetAccessTokenDuration()GetRefreshTokenDuration() functionFEATURE_SIGN_IN_FREQUENCY_CONTROLbackend/api/v1/auth_service.go:
GetRefreshTokenDuration()| Token Type | Default Duration |
|---|---|
| Access Token | 1 hour |
| Refresh Token | 7 days |
FEATURE_SIGN_IN_FREQUENCY_CONTROL (enterprise)proto/store/store/setting.proto)proto/v1/v1/setting_service.proto)cd proto && buf generatebackend/api/auth/header.go with new duration functionsbackend/api/v1/auth_service.go to use new functions