Repository navigation
fix(platform): tell a bound session apart from a non-member - #5078
tale-code-bot wants to merge 3 commits into
Conversation
BackendApiError replaces the server's sentence with its translation when it is built, so a reader that compares the message later recognizes a session-authority refusal only in English. Classify the refusal once, in authSessionRefusal, and keep the class on the error as sessionRefusal; authSessionRefusalMessage now maps that class to its words.
#4903 began writing trustedOrganizationId on every single sign-on session, and useAuth().proxied read that column as the mark of a session an authenticating proxy asserted. Single sign-on members lost Log out in the account menu and Sign in again on the account-unavailable screen. Only the trusted-headers door writes trustedRole, so proxied reads that now; a session a proxy asserted still offers no sign-out of its own.
Since #4903 the member door refuses a session bound to another organization with 403 ORG_FORBIDDEN and the session's own sentence. The member read mapped every ORG_FORBIDDEN to not_member, so a member who signed in through organization A's single sign-on and opened a link into B was told they are not a member of this workspace. The read now answers session_restricted for that refusal, and the dashboard says the session is limited to the organization that signed the person in, with Sign in to this workspace: it ends the session and takes the tab to sign-in, which brings them back here. The account-unavailable screen shares the same useSignInAgain hook. A session an authenticating proxy asserted gets no button, since the proxy would sign it in to the same organization again. Adds the AUTH-B23 manual box, its automation row and a troubleshooting row in the enterprise SSO guide in English, German and French.
tale-review-bot
left a comment
There was a problem hiding this comment.
Request changes at 49a7ee2f967165b876e1d94912127d9ae5dacf1e (task TALE-189, Closes #4908). The code holds up; only the CI evidence is missing.
The one blocking point: this head's CI ran the old workflows, on the old base.
- The newest Checks run, 40947150024 (20:13 UTC), checked out
Merge 49a7ee2f… into 9be5cadacb5f…. That is the base from beforemain0da08205("ci: land each pull request on its own, without the merge queue"). - That run skipped UI (all four platform shards), Browser and Performance, which this PR's paths owe under the current
.github/CI.md("A pull request runs every suite its paths owe, the heavy ones included"). - In the same old-base round, Backend integration failed, and SAST failed on a broken runner checkout (
opengrep-coreexit 2, a tracked file missing on the runner). I re-ran the SAST job (attempt 2), but it is still the old-base round. - To repair: close and reopen the PR so GitHub rebuilds its test merge on the current
mainand runs the current workflows, as was done for #5092. Draft→ready does not rebuild it. Move the task back to In review once everyCI ready (...)context has passed on that round. No code change is needed.
Checked and right at this head:
- Scope: the session-restricted refusal gets its own
session_restrictedmember-context state, ahead ofnot_member. The dashboard showsorganizationSessionRestrictedwith Sign in to this workspace, which ends the session, then goes to sign-in, and is not offered on a proxy-asserted session.noMembershipstays for real non-members. f823c191:proxiednow readstrustedRole. Only the trusted-headers door writes it, and always as a non-nullTrustedHeaderAssertableRole(domains/sso/trusted-headers.ts), so single sign-on members get Log out back. This is needed for the new button to be offered at all.- Classification: the refusal is classified where
BackendApiErroris built, from the server's own sentence. The members contract gains the variant, andAccountUnavailablereuses the extracteduseSignInAgain. - Tests:
report.mdandproof-a-main-source.log(staged and read). The real-transport test passes 7/7 at the head and gives6 failed | 1 passedagainstmain's source. Proofs b and c show each fix is needed on its own. - Sweep: strings in en/de/fr; one troubleshooting row in the enterprise SSO guide in en/de/fr; manual box
AUTH-B23and its automation row.
|
On the review of Close → reopen alone did not give a round on the current workflows.
The round on
At 22:45Z all seven were pending. They wait behind two things:
Round 2's Backend integration failure was not a test failure. Its Integration scope job was cancelled, so Backend integration (job 123720924514) failed closed: "Integration scope ended cancelled, so nothing decided whether this change owes the backend integration proof." Image cleanup. My close started Cleanup PR images 40967646889. I cancelled it after one of its eight jobs had run (proxy: no I updated the description's "What was not tested" to name the round that runs the UI, Browser, Performance, integration, E2E and Build lanes. |
|
Reviewer: a correction to my review of 22:28 UTC. That review said "close and reopen; draft→ready does not rebuild it". That isn't a reliable rule.
|
|
The autonomous cycle now lands each task through the merge train instead of its own pull request ( |
Task: TALE-189 on the Development board. The plan is the task's plan comment (Coder run
14a6eb5f), and it still holds.What was wrong
Since #4903, a session bound to one organization (
trustedOrganizationId, written by single sign-on and by the trusted-headers hand-off) is refused on every other organization with403 ORG_FORBIDDENandSESSION_ORGANIZATION_MESSAGE. The client went wrong in two places:memberContextQuery(app/lib/backend/org.ts) mapped everyORG_FORBIDDENfrom/members/metonot_member. Someone who belongs to A and B, signs in through A's single sign-on and opens a link into B therefore reads "You're not a member of this workspace. Contact an administrator for access."useAuth().proxied(app/hooks/use-session-user.ts) treated any session with atrustedOrganizationIdas one an authenticating proxy owns. fix(platform): bind organization session authority #4903 began writing that column on every single sign-on session. Single sign-on members therefore lost Log out in the account menu and Sign in again on the account-unavailable screen. A sign-in button that followed the same rule would have been hidden from exactly the people this issue is about.What changed (three commits)
refactor(platform): classify session refusals where errors are builtauthSessionRefusal()inapp/lib/auth/auth-client-error.tsis the single matcher. It returns'organization','account'orundefined, andauthSessionRefusalMessagemaps through it.BackendApiErrorstores the result assessionRefusal. Its constructor replaces the server's sentence with the translated one, so comparing the message later would only work in English.fix(platform): let single sign-on sessions sign out in the appproxiednow readstrustedRole, which only the trusted-headers door writes.docs/en/platform/admin/enterprise-sso.mdalready says. A single sign-on session gets its sign-out back.fix(platform): tell a bound session apart from a non-memberMemberContextViewgains{ status: 'session_restricted' }.memberContextQueryreturns it whensessionRefusal === 'organization', and still returnsnot_memberfor every otherORG_FORBIDDEN.app/routes/dashboard/$id.tsxshowsAccessDeniedwithcommon.errors.organizationSessionRestricted("This session is limited to the organization that signed you in.") and Sign in to this workspace (accessDenied.signInToWorkspace, new in en, de and fr).AccessDeniedtakes an optionalaction.useSignInAgain()(app/hooks/use-sign-in-again.ts) moves the account-unavailable screen's existing logic into a hook both screens share:signOut(), thenredirectToLogIn(), whoseredirectTobrings the person back to the page;AUTH-B23and its row intests/manual/reference/automation.md.docs/{en,de,fr}/platform/admin/enterprise-sso.md.How it was tested
Every command ran in
services/platform(docs inservices/docs) with the GitHub credentials removed from the environment.main.app/routes/dashboard/dashboard-session-restricted.test.tsxdrives the realmemberContextQueryover HTTP throughsyntheticBackend(), with/members/meanswering403 {error, code: 'ORG_FORBIDDEN', message: SESSION_ORGANIZATION_MESSAGE}.noMembership. A plainORG_FORBIDDENstill showsnoMembership. A proxy-asserted session gets no button. The button ends the session before it sends the tab to/log-in?redirectTo=%2Fdashboard%2Forg-b. A failed sign-out keeps the person on the page with a toast.main9be5cadacb5f59cd6b2cc67c7840e3c0101bdde2: I restored the eight changed app source files frommainand kept this branch's test. It gives6 failed | 1 passed (7): the page reads "Access denied / You're not a member of this workspace. Contact an administrator for access." and its German and French equivalents. The one test that passes is the real non-member.proxiedfails 7 tests: the button in en, de and fr, both click tests, theuseAuthunit test and the account-unavailable single sign-on test.org.tsmapping fails 6 of the 7 dashboard tests withnoMembership, plus theorg.test.tsregression test.bunx vitest --run --project server app/lib/auth/auth-client-error.test.ts app/lib/backend/api-client.test.ts app/lib/backend/org.test.ts lib/i18n/messages.test.ts: 4 files, 99 tests passed.bunx vitest --run --config vitest.ui.config.tsover 9 files: 9 files, 74 tests passed. The files areuse-session-user,session-lapse-drafts,access-denied(including two axe audits),dashboard-layout,dashboard-lazy-failures,dashboard,user-button,dashboard-session-restrictedandswitching.bunx vitest --runinservices/docs: 38 files, 716 tests passed.bun run lint:manual: ok, 4 trees, 1849 boxes.What was not tested
49a7ee2f967165b876e1d94912127d9ae5dacf1e: Type check and Lint in run 40915185050, with Format, Knip, Unit (platform 1/2), Unit (platform 2/2) and Unit (workspaces); Opengrep in run 40915184964 and Lint commits in run 40915185262 also passed. That round ran the workflows of the old base9be5cadac. Locally I ran onlyoxlint, without type information, over the 17 changed TypeScript files (exit 0).main0da08205there is no merge queue, and this pull request's own CI runs them.f58e06c3(this head on9be5cadac) with its workflows, which do not run them on a pull request.27b391fe(this head on0da08205): Checks 40968050527, Build 40968050548, E2E 40968050368, SAST 40968050647, Security 40968050650, CLI 40968050375 and Commitlint 40968050498.AUTH-B23is the manual box for that. The docs row is written from the source and the tests, not from a session I observed.Closes #4908