Skip to content

[M2.2e-fix] Fix expired-session sign-out and stop hiding one-time secrets on a timer - #98

Merged
samuelmbabhazi merged 2 commits into
mainfrom
fix/m2.2-web-session-and-recovery-codes
Nov 5, 2026
Merged

samuelmbabhazi merged 2 commits into
mainfrom
fix/m2.2-web-session-and-recovery-codes

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

Task

Review follow-up for #64, #66 and #68 (M2.2e1b, M2.2e2b, M2.2e3a). Refs #21

What changed

Session state (session-store.ts)

  • Sign-out on an expired or revoked session: the server answers 401, which now clears the local session instead of keeping "Signed in as …" with an error that every retry repeats.
  • A successful login always updates the session, even if its form was left before the response arrived. The server has already set the session cookie, so the UI no longer claims the user is signed out while the next reload is authenticated. Form side effects (navigation) remain guarded by the mutation runner.
  • A login that fails while it superseded a pending session check re-runs the check, so the account page no longer stays on "Checking your session…" until reload.

One-time secrets (mfa-form-store.ts, token-form-store.ts)

  • Recovery codes and newly created API tokens are no longer hidden by a fixed 10-minute timer. They stay until the user acknowledges them, leaves the page or rotates the session.
  • The provisioning seed keeps its timer, which follows the real server expiry.
  • Panel texts and SPEC updated.

Why

How it was tested

  • New and updated unit tests: 401 sign-out clears the session; a failed login that superseded a pending check settles the state; recovery codes and API tokens are still displayed after an hour without acknowledgement.
  • nx run-many -t lint typecheck test build -p web in a clean worktree: 11 files, 52 tests pass; production build passes.
  • Browser acceptance could not run: GitHub Actions is blocked by the account spending limit. CI must pass before merge.

Security considerations

  • Secrets stay in memory longer only while the account page is open and only until acknowledgement. Departure, session rotation and acknowledgement still clear them, and they still never serialize out of the stores.
  • The signed-out state after a 401 matches the server state.

Checklist

  • Lint, typecheck, tests and build pass locally
  • Tests added and updated
  • No new shell invocation and no new secret exposure path
  • Audit events: not applicable (client only)
  • SPEC updated
  • CI green (blocked by billing)

@samuelmbabhazi
samuelmbabhazi force-pushed the fix/m2.2-web-session-and-recovery-codes branch from e25f187 to c6557df Compare November 5, 2026 13:55
@samuelmbabhazi
samuelmbabhazi merged commit 5b39f88 into main Nov 5, 2026
2 of 11 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the fix/m2.2-web-session-and-recovery-codes branch November 5, 2026 13:55
samuelmbabhazi added a commit that referenced this pull request Nov 7, 2026
…t found (#190)

## What changed

**`tenant.browser.spec.ts`**, real production assets, API, PostgreSQL
and Chromium (PLAN M2.3f2):

- Another organization's URLs answer 404 on every screen and show none
of its data.
- Role changes apply on the next request, for membership, a project
role, and their removal.
- An application is validated and created in the browser under the CSP.
- A second tab deploys and the first sees it through the live stream.
This is the first automated test of that stream over real HTTP.
- No WCAG A or AA violation on any workspace screen, and no uncaught
error or CSP violation on any of them.
- The audit export downloads under the CSP.
- Scoped tokens from the picker work as real bearers, and a revoked
project token gets 401.

**Product defects this found, fixed here:**

- During a rate-limit wait, submit buttons stayed enabled and clicking
them did nothing. They are now disabled on every form using
`MutationRunner`.
- Checkboxes were under the WCAG 2.5.8 minimum of 24px.
- Row buttons on members and roles all had the same accessible name.
They now name the person.

**The browser suite had gone stale with CI off**, and is repaired:

- Sign-in lands on organizations since #168; the helpers still expected
account security.
- Two tests still expected one-time secrets to hide on a timer, which
#98 deliberately removed.

**Harness:**

- The browser fixture now uses the restricted runtime role, as
production does; tenant commands refuse a role that can bypass row
security.
- `SHIPKEEP_DISPOSABLE_DATABASE_URL` opts in to a database that is safe
to wipe, where Docker is out of reach.

## How it was tested

Full browser suite: 16 of 16 pass, on Chromium with a local PostgreSQL
18.4 rather than the pinned 17. After that run, a small simplification
to the audit test's CSP check was verified by rerunning
`tenant.browser.spec.ts` (8 of 8).

## Not covered

- Lighthouse, so the M2.6 score is still open. axe is a related but
different check.
- Server removal in a browser: it needs an enrolled node.
- A deployment past `queued`: the fixture runs no worker, and there is
no real Docker or server.

## Security considerations

`SHIPKEEP_DISPOSABLE_DATABASE_URL` is read only by test code and only
for isolated databases, and that database is wiped. Production code is
unaffected apart from the UI fixes above.

## Checklist

- [x] Browser tests pass locally
- [x] No new shell invocation, no new secret exposure path
- [x] No new state change
- [x] PLAN updated

Signed-off-by: review <[email protected]>
Co-authored-by: review <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant