feat: Add the API token service

Mint, resolve, list and revoke, with the effective role capped at the
owner's and recomputed per request rather than frozen at creation.

Deleting a user deletes their tokens in the same call, so offboarding is
one action. Revoking somebody else's token answers not-found rather than
forbidden, since a 403 confirms the credential exists.

Also re-exports shared.APITokenMaxDays into server/internal/models,
following the existing ValidRole wrapper pattern, since the token
service needs it and it was never re-exported.
This commit is contained in:
mrhid6 committed 2026-08-12 14:28:10 +00:00
1 parent 33b5ec0788
commit 72e5228351
3 files changed
+270 -1

No files matched your search

+4
View File
@@ -7,3 +7,7 @@ type (
AlertSettings = shared.AlertSettings
SecretsSettings = shared.SecretsSettings
)
// APITokenMaxDays re-exports shared.APITokenMaxDays so server/internal/services
// can read the token lifetime cap without importing shared/models directly.
func APITokenMaxDays(s *Settings) int { return shared.APITokenMaxDays(s) }