Skip to content

Commit ca02e89

Browse files
authored
Added the basic client scope so tokens carry a sub claim (#8)
Keycloak 19+ moved the sub claim into the built-in basic client scope, which the realm never defined (it only had groups/profile/email), so issued tokens had no subject and the backend rejected every authenticated call with "No authenticated user". Define the basic scope (sub + auth_time), make it a realm default and assign it to schuly-app.
1 parent 2682966 commit ca02e89

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

realms/schuly-realm.json

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,30 @@
2222
{ "name": "Teacher", "realmRoles": ["Teacher"] },
2323
{ "name": "Administrator", "realmRoles": ["Administrator"] }
2424
],
25-
"defaultDefaultClientScopes": ["groups", "profile", "email"],
25+
"defaultDefaultClientScopes": ["basic", "groups", "profile", "email"],
2626
"clientScopes": [
27+
{
28+
"name": "basic",
29+
"protocol": "openid-connect",
30+
"description": "OIDC basic claims (sub, auth_time). Required so tokens carry a subject.",
31+
"attributes": { "include.in.token.scope": "false", "display.on.consent.screen": "false" },
32+
"protocolMappers": [
33+
{
34+
"name": "sub",
35+
"protocol": "openid-connect",
36+
"protocolMapper": "oidc-sub-mapper",
37+
"consentRequired": false,
38+
"config": { "access.token.claim": "true", "introspection.token.claim": "true" }
39+
},
40+
{
41+
"name": "auth_time",
42+
"protocol": "openid-connect",
43+
"protocolMapper": "oidc-usersessionmodel-note-mapper",
44+
"consentRequired": false,
45+
"config": { "user.session.note": "AUTH_TIME", "claim.name": "auth_time", "jsonType.label": "long", "id.token.claim": "true", "access.token.claim": "true" }
46+
}
47+
]
48+
},
2749
{
2850
"name": "groups",
2951
"protocol": "openid-connect",
@@ -124,7 +146,7 @@
124146
"redirectUris": ["schulytest://callback", "schuly://callback"],
125147
"webOrigins": ["+"],
126148
"attributes": { "pkce.code.challenge.method": "S256" },
127-
"defaultClientScopes": ["groups", "profile", "email"],
149+
"defaultClientScopes": ["basic", "groups", "profile", "email"],
128150
"optionalClientScopes": ["offline_access"]
129151
}
130152
],

0 commit comments

Comments
 (0)