feat(quick-261016-0fm): admin language follows the stored preference

- principalFrom sets PreferredLocale from metadata admin_locale; personal
  API token principals clear it, so token clients keep the request locale
- the guarded admin group runs locale.from-principal after the backend
  guard, overriding the LocaleResolver or Accept-Language locale
- GET /lang honours a supported ?locale= and reports meta.locales
  (cabana.LangEnvelope, cabana.LangMeta)
- Docker test for the override, refusals and /lang; docs and OpenAPI
This commit is contained in:
Jakub Zych
2026-10-16 10:58:29 +02:00
parent 3d2f9d0cf6
commit f67e8915b8
15 changed files with 216 additions and 39 deletions

View File

@@ -106,6 +106,9 @@ func principalFrom(user BackendUser) *bouncer.Principal {
Backend: true,
IsSuperuser: user.IsSuperuser,
PermissionGrants: parseGrants(user.Role.Permissions),
// The admin's chosen admin language (validated on write); empty
// keeps the request locale. Personal API tokens clear it.
PreferredLocale: metadataString(user.Metadata, metadataAdminLocale),
}
if user.TokensValidAfter != nil {
principal.TokensValidAfter = *user.TokensValidAfter