OSAC-3373: extend SessionContext with tenantId - #111
Conversation
|
@rawagner: This pull request references OSAC-3373 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
Warning Review limit reached
Next review available in: 47 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository: osac-project/coderabbit/.coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
WalkthroughThe change extracts ChangesTenant ID propagation
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant IDToken
participant GetLoginInfo
participant useOIDCLogin
participant SessionProvider
participant ShellMasthead
IDToken->>GetLoginInfo: provide organization claim
GetLoginInfo->>useOIDCLogin: return TenantID in login response
useOIDCLogin->>SessionProvider: provide tenantId
SessionProvider->>ShellMasthead: expose tenantId through session
ShellMasthead-->>ShellMasthead: render translated tenant label when tenantId exists
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 11✅ Passed checks (11 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@libs/ui-components/src/hooks/use-session.test.tsx`:
- Around line 16-18: Update the role expectation in the useSession test to match
SessionProvider’s preserved value, changing the expected role from “tenant-user”
to “tenantUser”; leave the tenantId and username assertions unchanged.
In `@proxy/auth/userinfo.go`:
- Around line 78-80: The for loop iterating over orgMap with a return statement
on the first iteration is non-deterministic because Go maps do not preserve
iteration order. Replace this arbitrary selection with a deterministic approach:
either validate that orgMap contains exactly one organization key before
selecting it, or derive the tenant ID from an explicit claim value in the input
instead of iterating the map. This ensures the same tenant is consistently
returned across all requests.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: osac-project/coderabbit/.coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 86642dd9-2dfa-4d57-b0c9-8a68ecedc246
📒 Files selected for processing (8)
apps/app-frontend/src/App.tsxapps/app-frontend/src/hooks/oidc-login.tsxapps/app-frontend/src/shell/ShellMasthead.tsxlibs/i18n/locales/en/translation.jsonlibs/ui-components/src/hooks/use-session.test.tsxlibs/ui-components/src/hooks/use-session.tsxproxy/auth/handler.goproxy/auth/userinfo.go
2a99512 to
b0545a3
Compare
| <Title headingLevel="h4" size="lg"> | ||
| Red Hat OSAC | ||
| </Title> | ||
| {tenantId && <div>{t('Tenant: {{ tenantId }}', { tenantId })}</div>} |
There was a problem hiding this comment.
maybe here can use SubtleContent instead of the div?
There was a problem hiding this comment.
good idea. Replaced with SubtleContent
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@proxy/auth/userinfo.go`:
- Around line 69-74: Update TenantIdFromToken and the JWT parsing flow in
jwtClaims to cryptographically validate the token before reading organization,
including signature, issuer, audience, expiry, and nbf checks. Preserve the
existing empty-string result for invalid or unverifiable tokens, and only return
the organization key after validation succeeds.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: osac-project/coderabbit/.coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 5b8aad52-cba9-44f7-b8ed-ceda7df7e808
📒 Files selected for processing (8)
apps/app-frontend/src/App.tsxapps/app-frontend/src/hooks/oidc-login.tsxapps/app-frontend/src/shell/ShellMasthead.tsxlibs/i18n/locales/en/translation.jsonlibs/ui-components/src/hooks/use-session.test.tsxlibs/ui-components/src/hooks/use-session.tsxproxy/auth/handler.goproxy/auth/userinfo.go
Extract tenantId from the Keycloak organization claim and wire it through the Go proxy login info endpoint to the React session context. - Add TenantIdFromToken reading the Keycloak organization claim - Include tenantId in /api/login/info response - Add tenantId to SessionContextValue and SessionProvider - Update useOIDCLogin to track and return tenantId - Add unit tests for useSession with tenantId - Show tenant in Masthead Signed-off-by: Rastislav Wagner <rawagner@redhat.com> Assisted-by: Claude Code <noreply@anthropic.com>
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ElayAharoni, rawagner The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Extract tenantId from the Keycloak organization claim and wire it through the Go proxy login info endpoint to the React session context.
Assisted-by: Claude Code noreply@anthropic.com
Summary by CodeRabbit
New Features
Bug Fixes
Tests