Repository navigation
ui: tell users who are not cluster operators that the console is not for them - #1246
Conversation
|
Thanks for opening this pull request! A SPACE maintainer will take a look. CONTRIBUTING.md explains how we review outside contributions. |
Withdrawing this approval for now. Any feedback above still stands.
…for them Every console page reads the admin API, which answers only organization admins of the cluster's managing organization. The menu nevertheless offered Overview and Sandboxes to every signed-in user and Organizations and Users to any organization admin, so a tenant admin or a member signed in to pages that failed with 403 toasts and empty tables, and Overview showed "0 organizations, 0 sandboxes". Such users now see one notice naming the account and organization they are signed in with and what the console requires, with a sign-out button, and no pages that cannot work. The menu items no longer carry role fields, which also stops antd's Menu from passing them to the DOM. Overview reports a failed request instead of a zero.
The operators-only gate decided from the signed-in user and the cluster record, and treated a missing cluster record as "not an operator". The password sign-in tolerates a failed GET /auth/v1/cluster and leaves it null, so a managing-org admin whose cluster request failed once right after signing in was told the console was not for them, with every page hidden. consoleAccess() now has three answers: operator, not an operator, and undecided for an organization admin whose cluster record is missing. The undecided case shows "Could not load cluster information" with a Retry that refetches the cluster through the auth context. Members are not operators whatever the cluster record says.
Restoring a stored session read /auth/v1/cluster with /me and discarded the token when either failed, so a reload during a cluster-read outage signed the operator out instead of reaching the Retry state that sign-in already reaches. The cluster read now falls back to "unknown" there too, and in external sign-in; only a failed /me discards the session. A failed Retry shows its error. In external sign-in without a logout URL, the operators-only notice drops its Log out button, which could only return to the same notice, and says to sign out of the provider. The overview drops answers that land after the page is left.
f45c57f to
521216d
Compare
Review — 1 findingLow
What I checked:
Verified against |
the-gigi-pplx
left a comment
There was a problem hiding this comment.
Approved. 1 non-blocking finding in the review comment above.
… out External sign-in without a logout URL can only return to /login, which the provider session signs straight back in. The cluster-operator notice already drops its Log out button for that case, but the sidebar still offered one. Show the same "sign out of <provider>" text there instead, via a tested helper shared with the notice.
|
Thanks. fc74519 replaces the sidebar Log out with the same "Sign out of " text when only the provider can end the session, using one tested helper, so the notice and the sidebar agree. |
Summary
Users who are not cluster operators now get one clear notice instead of a console full of pages that cannot load.
Every console page reads
/admin/api/v1. Its middleware answers only organization admins of the cluster's managing organization, and returns403 Caller is not a managing organization adminto everyone else. The menu nevertheless offered:So a tenant org's admin, or any member, landed on pages that showed 403 toasts and empty tables, and Overview reported "0 organizations, 0 sandboxes".
Such users now see a notice in place of the page. It names the account and organization they are signed in with, says what the console requires, and offers a sign-out button. In external sign-in without a logout URL, signing out can only return to the same notice, so neither the notice nor the sidebar has a Log out button there. Both say to sign out of the identity provider instead. No admin requests are made for them.
If the cluster record fails to load, whether at sign-in or when a stored session is restored on a page load (in password and in external sign-in), an organization admin sees "Could not load cluster information" with a Retry instead of the notice, and stays signed in. Only a failed
/meread ends a restored session. A failed Retry shows its error, and the next Retry tries again. For operators nothing changes. The menu items no longer carry role fields, which antd's Menu was passing through to the DOM as an unknownmanagingOrgAdminattribute (a React warning on every page).Overview also reports a failed request as an error instead of showing 0, and drops answers that arrive after the page is left.
Stack
Independent of the other open console PRs. It edits
ui/src/app/dashboard/page.tsx, as #1244 does; whichever merges second needs a small rebase.Validation
npm ci,npm test(84 pass, includingsrc/lib/console-access.test.mjsand the provider-only sign-out check),npx tsc --noEmitandnpm run buildinui/, on this head. The browser runs below were recorded on an earlier head of this branch; the sidebar change has unit-test coverage only.main(production build) and on this branch (the Kindspace-uiimage).main, the tenant admin and the member triggerGET /admin/api/v1/orgs -> 403andGET /admin/api/v1/sandboxes -> 403on each page.main.Visual confirmation
A tenant org's admin opening Overview, Users and Sandboxes:
main)Videos: before, after.
Severity and risk
Severity: medium. Nothing worked for these users before. The change replaces broken pages with an explanation.
Risk: low. The gate uses the same check the backend applies:
isManagingOrgAdmin, meaning roleorganization_adminand the user's org is the cluster'smanaging_org_id. If the admin API ever opens pages to tenant admins, the gate must change with it. An operator who hands the managing role to another organization (Organizations, "Make manager") sees the notice at once: the cluster record the console holds now names another managing organization, and the admin API no longer admits them either. Roll back by reverting the commits.AI assistance: Claude Code wrote the code and this description, and ran the validation; a maintainer reviews it.