Repository navigation
feat(auth): pick a lab at sign-in and switch labs - #24
Conversation
…witchOrganization)
- ORG_REQUIRED errors carry extensions.organizations ({ code, name }; only the
labs whose account matched the password, no ids).
- Query myOrganizations: every lab the signed-in person can work in, the
current one marked.
- Mutation switchOrganization(orgCode, device): moves the session to the
person's account in another lab without the password (auth-kit 1.5.0).
The old session ends; same device rule as refreshSession; audited in both
labs. New error code ORG_UNAVAILABLE.
- kits.json points auth-kit at its unreleased branch commit; package.json and
the lockfile move to auth-kit 1.5.0 once it is published.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018jBohk4otGVRjt3Y1cF1N2
|
The Cause.
Which PR has the fix. auth-kit 1.5.0 is in mgpl-diagnostics/auth-kit#13. It isn't on GitHub Packages yet, so the lockfile can't move to it from here. Evidence. Locally, with that branch built (
Next steps. After auth-kit#13 is merged and 1.5.0 is published:
I'll do those steps once the release exists. Generated by Claude Code |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018jBohk4otGVRjt3Y1cF1N2
|
With auth-kit 1.5.0 the auth-kit part is now green. The run has one failure left out of 320 checks: CI installs Generated by Claude Code |
Brings the myOrganizations and switchOrganization operations, so the client-operations check passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018jBohk4otGVRjt3Y1cF1N2
|
With client 1.5.0, both new operations are found now. The one failure left is the other direction of the contract check: Since 1.4.0, the client has carried the partner-lab import operations ( Merge order: #23 first (it pins client 1.4.0), then I rebase this branch onto Generated by Claude Code |
Conflicts in kits.json, package files, errors.ts and llms-full.txt: kept both sides (report-reader and db-kit 2.1.1 from main; auth-kit 1.5.0, client 1.5.0 and ORG_UNAVAILABLE from this branch). Generated files regenerated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018jBohk4otGVRjt3Y1cF1N2
…dates) (#26) <!-- claude-projects-attribution: {"github_login":"BackStacked"} --> _Requested by **Himanshu** · [project thread](https://claude.ai/code/project/chan_016JXeBZ2UxSi4N5VU2C26fQ?thread=cmsg_016JXeBZ2UxSi4N5VU2C26fQU57JpX29saJ5azzjf6zEWH)_ ## What **Images per release.** `.github/workflows/release.yml`: a `v*` tag (admin-only) or a manual run on `main` checks the tag equals `package.json`, builds `ghcr.io/mgpl-diagnostics/api` for linux/amd64 and arm64 (tags `1.2.3`, `1.2`, `1` from 1.0, `latest`; kits read with the workflow token as a build secret) and creates the GitHub release with generated notes. **Easy hosting.** `docker-compose.yml` now pulls the released api and dashboard images (`MGPL_API_VERSION` / `MGPL_DASHBOARD_VERSION`, default `latest`) and adds the dashboard. nginx serves both on one origin: `/graphql` and `/health` → api replicas, the rest → dashboard, so `TRUST_PROXY=1` stays right and there is no CORS. Building from a checkout moved to `docker-compose.build.yml`. **Update notices.** New query `systemUpdates(dashboardVersion, refresh)` (permission `settings:manage`: owner and admin) compares this api's version and the dashboard's with the newest published GitHub releases of both repos, and returns the changelog in between plus the update steps. One GET per repo per `UPDATE_CHECK_INTERVAL_MS` (6 h) per process, "refresh" at most once a minute, last good answer kept on failure; `UPDATE_CHECK=false` makes no outbound call. Feed data is typed and capped; non-https links dropped; pre-releases and drafts ignored. New module `system` (schema, controller, service), no change to existing modules. **Fix.** `health.version` read `../../package.json` relative to the bundled chunk, so production images answered `0.0.0`; `src/version.ts` now reads the right file in both `tsx` and `dist`. Docs: new `docs/18-updates.md` (images, hosting, updating, releasing, the check), config table, `.env.example`, 12/17 updated. `schema.graphql`, API reference and `llms-full.txt` regenerated. ## Merge order `@mgpl-diagnostics/client` 1.6.0 (mgpl-diagnostics/client PR) has the `systemUpdates` operation, which the "every root field has a client operation" check needs, so this PR bumps the client to `^1.6.0`. Client main already includes the operations of #23 and #24, so: merge **#24 and #23**, then **client 1.6.0** (tag it), then this. `kits.json`/`package.json`/lock will conflict with #24 on the client line; take `1.6.0`, then `npm install` to refresh the lock and `npm run schema && npm run docs:reference && npm run llms`. ## Tests `TEST_BACKENDS=pg npm test` with kits built from local checkouts: 16 new `[updates]` checks pass (versions, changelog window, cache, refresh limit, unknown dashboard version, UNAUTHENTICATED, FORBIDDEN for front desk, 403 feed, `UPDATE_CHECK=false`, repo validation). The one failure is the client-contract check against today's main, which lacks #23/#24's fields (goes away in the merge order above). `docker compose config` passes for both compose files; `nginx -t` passes; nginx routing checked with stub containers. The image build itself runs for the first time in CI on the first tag. ## After merging - First release only: GitHub → org → Packages → `api` → change visibility to Public (or `docker login ghcr.io` on servers). - One-click updates are not included (the api never gets the Docker socket); asked in the project thread. --- _Generated by [Claude Code](https://claude.ai/code/session_018jBohmSXdQwAG8EmEBKYkQ)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
One person (one email) can have an account in several labs. This lets the dashboard show a pick list at sign-in and switch labs once signed in. The owner chose switching without asking for the password again.
Changes
ORG_REQUIREDnow carriesextensions.organizations, a list of[{ code, name }].myOrganizations: [OrganizationChoice!]!returns{ code, name, current }for every lab the person can work in.switchOrganization(orgCode: String!, device: DeviceInput): LoginResult!, built on auth-kitswitchOrganization.orgIdarguments) holds.ORG_UNAVAILABLE, so codes can't be probed.refreshSessionapplies.ORG_UNAVAILABLE. It is inERROR_CODESand docs/05-errors.md.schema.graphql, docs/04 and llms-full.txt are regenerated.Why this is a draft
It needs auth-kit 1.5.0 (mgpl-diagnostics/auth-kit#13).
kits.jsonpoints auth-kit at that branch's commit fornpm run kits.package.jsonandpackage-lock.jsonstill pin the published auth-kit, so CI'snpm ci+ typecheck will fail until 1.5.0 is published.npm install @mgpl-diagnostics/auth-kit@1.5.0, setkits.jsontov1.5.0, and mark this ready.Tests
I ran
KITS_SRC=.. npm run kits, thennpm run typecheck, thenTEST_BACKENDS=pg npm test. The result was 127 passed and 1 failed.myOrganizationsfor a two-lab and a one-lab person;ORG_UNAVAILABLEfor the current lab, an unknown code, or a lab without an account;UNAUTHENTICATED;INVALID_TOKENand ends the session.mainalready selects partner-lab fields (provenance,externalReports, …) that apimaindoesn't serve yet. With client 1.5.0 the "every field has a client operation" check passes.Generated by Claude Code