ui: Display the authenticated user by configured userIdClaim#1875
ui: Display the authenticated user by configured userIdClaim#1875marcofranssen wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Surfaces the authenticated user's identifier in the UI based on the configurable userIdClaim (instead of hardcoding sub), so deployments whose OIDC providers use a different claim populate the user store with the correct identity. The Helm chart now propagates controller.auth.userIdClaim into the UI deployment as KAGENT_USER_ID_CLAIM, which the new server-side helper reads.
Changes:
- Add
getUserIdClaimserver helper and exposeuserIdClaimthroughAuthContext. - In
AppInitializer, read the identity from the JWT claim and seeduseUserStore.setUserId. - Inject
KAGENT_USER_ID_CLAIMenv var into the UI Deployment from the controller auth values.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| ui/src/app/actions/auth.ts | New getUserIdClaim returning the env-configured claim (defaults to sub). |
| ui/src/contexts/AuthContext.tsx | Fetches the claim in parallel with the user and exposes it via context. |
| ui/src/components/AppInitializer.tsx | Uses the claim to extract the user identity and write it into useUserStore. |
| helm/kagent/templates/ui-deployment.yaml | Passes controller.auth.userIdClaim into the UI pod as KAGENT_USER_ID_CLAIM. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c347463 to
4cf061c
Compare
Signed-off-by: Marco Franssen <marco.franssen@gmail.com>
4cf061c to
3152ec6
Compare
EItanya
left a comment
There was a problem hiding this comment.
We already have the current user handler. Should we instead expand that to include more information? I favor backend solutions usually
Summary
KAGENT_USER_ID_CLAIMenvironment variable to the UI pod, sourced fromcontroller.auth.userIdClaiminvalues.yamlgetUserIdClaim()server action that readsKAGENT_USER_ID_CLAIM(defaults to"sub")AuthContextto fetch the configured claim name alongside the JWT and expose it asuserIdClaimAppInitializerto sync the authenticated user's identity intouserStoreusing the configured claim (e.g.email,preferred_username,sub) so the correct value is displayed in the UIMotivation
When deploying with
auth.mode: trusted-proxyandcontroller.auth.userIdClaim: email, the UI was still showing the rawsubvalue (typically an opaque ID) instead of the user's email. This was becauseuserStorewas seeded fromlocalStorageand never synchronized with the authenticated JWT claims.How it works
Test plan
controller.auth.userIdClaim: emailandauth.mode: trusted-proxy— UI should display the email from the JWTcontroller.auth.userIdClaim: preferred_username— UI should display the preferred usernameuserIdClaim(default) — UI should fall back tosubunsecuremode (no JWT) — UI should fall back to the defaultadmin@kagent.dev