Wire Kratos session tokenizer template (todo §3); plainpages JWT (sub/email/roles), 10m TTL, Jsonnet claims mapper reading metadata_admin

This commit is contained in:
2026-06-17 12:02:21 +02:00
parent 0313f48112
commit 95c759d773
5 changed files with 49 additions and 4 deletions

View File

@@ -0,0 +1,16 @@
// Session→JWT claims mapper for the `plainpages` tokenizer (§4). Kratos exposes the
// session as `session`; `sub` is set from the identity id (subject_source: id) and
// can't be overridden here. roles come from metadata_admin — the per-login projection
// of Keto roles the app refreshes at login; absent on a fresh identity ⇒ empty list.
local session = std.extVar('session');
local meta =
if std.objectHas(session.identity, 'metadata_admin') && session.identity.metadata_admin != null
then session.identity.metadata_admin
else {};
{
claims: {
email: session.identity.traits.email,
roles: if std.objectHas(meta, 'roles') then meta.roles else [],
},
}