ui: Display the authenticated user by configured userIdClaim#1875
Open
marcofranssen wants to merge 1 commit into
Open
ui: Display the authenticated user by configured userIdClaim#1875marcofranssen wants to merge 1 commit into
marcofranssen wants to merge 1 commit into
Conversation
Contributor
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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