feat(store): add token lifetime limit and tokens.manage permission

The built-in Admin role gains tokens.manage.

Refs #48

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 00:55:14 +01:00
1 parent d7d4821e3e
commit da128c5081
8 files changed
+69 -19

No files matched your search

+6
View File
@@ -25,3 +25,9 @@ SELECT * FROM api_tokens WHERE id = $1;
-- name: DeleteAPIToken :execrows
DELETE FROM api_tokens WHERE id = $1;
-- name: ClampAPITokenExpiry :execrows
-- Shortens tokens that would outlive a newly set maximum lifetime.
UPDATE api_tokens SET expires_at = now() + make_interval(days => sqlc.arg(max_days)::int)
WHERE org_id = sqlc.arg(org_id)
AND (expires_at IS NULL OR expires_at > now() + make_interval(days => sqlc.arg(max_days)::int));
+1 -1
View File
@@ -15,6 +15,6 @@ SELECT * FROM orgs ORDER BY name;
DELETE FROM orgs WHERE id = $1;
-- name: UpdateOrgPolicy :one
UPDATE orgs SET require_totp = $2, require_sso = $3, updated_at = now()
UPDATE orgs SET require_totp = $2, require_sso = $3, api_token_max_days = $4, updated_at = now()
WHERE id = $1
RETURNING *;