feat!: local accounts and OpenID Connect sign-in, without Supabase (multi-tenant foundation, part 2) #13

Open
claude-bot wants to merge 0 commits from feat/12-local-accounts into develop
Member

Closes #12

What

Accounts and sessions now live in the instance database, through @quatrain/auth-local. Supabase Auth is removed.

  • Password sign-in (POST /api/auth/password-login): opaque session token in the HTTP-only cookie studio-session, only its digest is stored. Refused after 5 failures in 15 minutes on a login.
  • OpenID Connect sign-in, optional (/api/auth/login, /api/auth/callback), through @quatrain/auth-oidc-client: authorization code flow with PKCE, state and nonce kept in a short-lived cookie limited to /api/auth. The first sign-in of an identity opens an account without role; an identity is never matched to an existing account by e-mail address.
  • Administration command: yarn admin account:create|list|password|roles|disable|enable|delete; tenant members are named by login.
  • Migration 0002_local_accounts.sql: the account tables. The application role may read, create and update accounts, never delete them.
  • Roles come from the instance (account:roles) and from tenant memberships, never from a provider claim. src/lib/auth-claims.ts is removed.
  • Documentation: docs/ACCOUNTS.md and docs/ACCOUNTS.fr.md; README, AGENTS.md, .env.dist and the multi-tenancy docs updated.

Breaking changes

  • PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY, SUPABASE_URL, OAUTH_CLIENT_ID and OAUTH_CLIENT_SECRET are no longer read.
  • The instance database is required to sign in. Run yarn admin migrate, then create accounts with yarn admin account:create.
  • With OIDC_ISSUER, PUBLIC_BASE_URL is required: the return address is no longer derived from the request.
  • The company claims (company_id, company_name) are gone; tenants replace them.

Other change

astro.config.mjs bundles jose with the server: bundled as a CommonJS dependency of a bundled package, it was otherwise imported as a default export and the server did not start.

Tests

58 unit tests (17 new: settings, cookies, request user, throttle, grants, and the migration checked against the DDL of the package).

Run by hand on the production build, against PostgreSQL 17 and a stand-in OpenID Connect provider: password sign-in, instance and tenant roles, refusal of another tenant (404), bearer token, sign-out (the old token is refused), throttling, full OpenID Connect flow, one account for repeated sign-ins of an identity, forged callback refused, disabled account refused.

Not included

  • Password recovery by e-mail and self-registration.
  • A shared store for the sign-in throttle: the limit applies per process.
  • The deployment manifests: an instance needs the new variables and the migration before this version is deployed.

🤖 Generated with Claude Code

Closes #12 ## What Accounts and sessions now live in the instance database, through `@quatrain/auth-local`. Supabase Auth is removed. - **Password sign-in** (`POST /api/auth/password-login`): opaque session token in the HTTP-only cookie `studio-session`, only its digest is stored. Refused after 5 failures in 15 minutes on a login. - **OpenID Connect sign-in**, optional (`/api/auth/login`, `/api/auth/callback`), through `@quatrain/auth-oidc-client`: authorization code flow with PKCE, state and nonce kept in a short-lived cookie limited to `/api/auth`. The first sign-in of an identity opens an account without role; an identity is never matched to an existing account by e-mail address. - **Administration command**: `yarn admin account:create|list|password|roles|disable|enable|delete`; tenant members are named by login. - **Migration `0002_local_accounts.sql`**: the account tables. The application role may read, create and update accounts, never delete them. - **Roles** come from the instance (`account:roles`) and from tenant memberships, never from a provider claim. `src/lib/auth-claims.ts` is removed. - **Documentation**: `docs/ACCOUNTS.md` and `docs/ACCOUNTS.fr.md`; README, `AGENTS.md`, `.env.dist` and the multi-tenancy docs updated. ## Breaking changes - `PUBLIC_SUPABASE_URL`, `PUBLIC_SUPABASE_ANON_KEY`, `SUPABASE_URL`, `OAUTH_CLIENT_ID` and `OAUTH_CLIENT_SECRET` are no longer read. - The instance database is required to sign in. Run `yarn admin migrate`, then create accounts with `yarn admin account:create`. - With `OIDC_ISSUER`, `PUBLIC_BASE_URL` is required: the return address is no longer derived from the request. - The company claims (`company_id`, `company_name`) are gone; tenants replace them. ## Other change `astro.config.mjs` bundles `jose` with the server: bundled as a CommonJS dependency of a bundled package, it was otherwise imported as a default export and the server did not start. ## Tests 58 unit tests (17 new: settings, cookies, request user, throttle, grants, and the migration checked against the DDL of the package). Run by hand on the production build, against PostgreSQL 17 and a stand-in OpenID Connect provider: password sign-in, instance and tenant roles, refusal of another tenant (404), bearer token, sign-out (the old token is refused), throttling, full OpenID Connect flow, one account for repeated sign-ins of an identity, forged callback refused, disabled account refused. ## Not included - Password recovery by e-mail and self-registration. - A shared store for the sign-in throttle: the limit applies per process. - The deployment manifests: an instance needs the new variables and the migration before this version is deployed. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Accounts and sessions now live in the instance database through
@quatrain/auth-local; Supabase Auth is removed.

- Password sign-in with an opaque session cookie (`studio-session`),
  limited per login after repeated failures.
- Optional OpenID Connect sign-in (authorization code flow with PKCE)
  through @quatrain/auth-oidc-client; the return address comes from
  PUBLIC_BASE_URL, never from the request. An identity is never matched
  to an existing account by e-mail address.
- Accounts and instance roles managed by `yarn admin account:*`; tenant
  members are named by login.
- Migration 0002 creates the account tables; the application role may
  read, create and update accounts, never delete them.
- Roles are no longer read from provider claims.

BREAKING CHANGE: the PUBLIC_SUPABASE_*, SUPABASE_URL and OAUTH_CLIENT_*
variables are no longer read. The instance database is required to sign
in, and existing users need an account (`yarn admin account:create`).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
chore(deps): add @quatrain/auth-local (#12)
All checks were successful
Build and Publish OCI Image / Build & Push ARM64 OCI Image (pull_request) Successful in 3m44s
3491754913
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
All checks were successful
Build and Publish OCI Image / Build & Push ARM64 OCI Image (pull_request) Successful in 3m44s
This branch is already included in the target branch. There is nothing to merge.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feat/12-local-accounts:feat/12-local-accounts
git switch feat/12-local-accounts

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch develop
git merge --no-ff feat/12-local-accounts
git switch feat/12-local-accounts
git rebase develop
git switch develop
git merge --ff-only feat/12-local-accounts
git switch feat/12-local-accounts
git rebase develop
git switch develop
git merge --no-ff feat/12-local-accounts
git switch develop
git merge --squash feat/12-local-accounts
git switch develop
git merge --ff-only feat/12-local-accounts
git switch develop
git merge feat/12-local-accounts
git push origin develop
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
modaka/studio!13
No description provided.