feat: extract Keycloak roles + role-based post-login routing #102
Labels
No labels
domain:backend
domain:devops
domain:frontend
No milestone
No project
No assignees
1 participant
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ldraney/pal-e-app#102
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Type
Feature
Lineage
Depends on dual auth middleware on pal-e-api (backend must accept JWT first). Part of pal-e-app "app definition" compliance.
Repo
forgejo_admin/pal-e-productionUser Story
As a pal-e-app user, I want to be routed to a view appropriate to my role after login so that I land on the most relevant page, not the generic landing page.
Context
pal-e-app has Keycloak (realm
pal-e, clientpal-e-docs-app, PKCE) but never extractsrealm_access.rolesfrom the token. The only identity info used ispreferred_usernamedisplayed in the nav bar. All authenticated users see the same UI. westside-app already does role-based routing — admin→/admin, coach→/coach, player→/my-players. pal-e-app needs the same pattern.File Targets
Files the agent should modify or create:
src/lib/keycloak.ts— addgetUserRoles(),hasRole(),getUserEmail(),getUserSub(),getRoleRedirectPath()src/routes/+layout.svelte— add post-login redirect based on role, show role badge in navsrc/lib/stores/user.ts(new) — reactive store with{ sub, email, name, roles, isAdmin }Files the agent should NOT touch:
src/routes/notes/— identity-aware views are a separate ticketsrc/routes/dashboard/— personalization is a separate ticketAcceptance Criteria
getUserRoles()returns roles array from Keycloak tokenTest Expectations
npm run buildConstraints
src/lib/keycloak.js(role extraction, redirect paths)check-ssosilent init patternpal-erealm may not exist yet — handle empty roles gracefully (default to /notes)Checklist
npm run build)Related
pal-e-app— project this affectsdefinition-app— the app definition driving this work