Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ KRATER_WEAVE_CLIENT_SECRET=
KRATER_WEAVE_API_BASE_URL=
KRATER_WEAVE_STUB_USERS_FILE=

# Krater's role keys on its Weave app, and the group slugs Krater falls back to when Weave sends no
# `roles` field at all. The defaults match the Weave setup in docs/weave-integration.md. There is no
# member role: everyone Weave lets use Krater is a Ganymede member.
# Krater's patch in Weave and its role keys there (the `patches` claim), Krater's legacy role keys on its
# Weave app, and the group slugs Krater falls back to when Weave sends no `roles` field at all. Krater
# holds the union of the patch roles and the app roles. The defaults match the Weave setup in
# docs/weave-integration.md. There is no member role: everyone Weave lets use Krater is a Ganymede member.
# KRATER_WEAVE_PATCH=ganymede
# KRATER_WEAVE_PATCH_ROLE_REVIEWER=krater:reviewer
# KRATER_WEAVE_PATCH_ROLE_ADMIN=krater:admin
# KRATER_WEAVE_ROLE_REVIEWER=reviewer
# KRATER_WEAVE_ROLE_ADMIN=admin
# KRATER_WEAVE_GROUP_REVIEWER=krater-reviewers
Expand Down
13 changes: 8 additions & 5 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,21 @@ tests/ mirrors krater/ layout
- **Primary keys are UUIDs** (`uuid.uuid4`), safe to show in URLs.
- **Every Patchwork member is a Ganymede member.** Whoever Weave lets use the Krater app (it signs them in, or its
directory returns them) holds `ganymede:member`; there is no member role in Weave.
- **Weave owns roles.** Krater's role keys in Weave are `reviewer` and `admin`, sent in the `roles` claim and in
directory records. Only when the `roles` field is absent does Krater fall back to the group slugs `krater-reviewers`
and `krater-admins`. `krater.weave.roles` is the one place that maps them to Krater's internal names
`ganymede:reviewer`, `ganymede:admin` (and adds `ganymede:member`); nothing else knows the keys or slugs.
- **Weave owns roles.** Krater's roles in Weave are the patch role keys `krater:reviewer` and `krater:admin` in the
patch `ganymede`, sent in the `patches` claim and in directory records. During the move from app roles, Krater also
reads its legacy app role keys `reviewer` and `admin` from the `roles` claim (and, only when `roles` is absent, the
group slugs `krater-reviewers` and `krater-admins`), and holds the union of both. A malformed `patches` value counts
as no patch role. `krater.weave.roles` is the one place that maps them to Krater's internal names
`ganymede:reviewer`, `ganymede:admin` (and adds `ganymede:member`); nothing else knows the keys, slugs or patch
slug. See `docs/weave-integration.md` "Patch roles" for the deploy order and the follow-up.
Every state-changing action (`fresh_actor`, the Slack click path) re-checks Weave's directory by `sub` through
`krater.services.users.authorize`, and fails closed if Weave is down. `users.roles_cached` is for display only.
Krater has no role tables, no admin users page and no disable switch: those are done in Weave.
- **Weave owns member data.** Krater stores a member's Patchwork ID (`users.weave_sub`), never their name, email or
other personal details: read those from Weave when needed (`krater.services.people`) and record who acted by
Patchwork ID (`docs/weave-integration.md` "Member data").
- **All Weave access goes through `krater.weave`.** Nothing else imports httpx for Weave or knows Weave's URLs.
Krater asks for `openid profile email groups roles slack`, and calls the directory with a client_credentials token
Krater asks for `openid profile email groups roles slack patches`, and calls the directory with a client_credentials token
of its own app (scope `directory`). Its token for Quilt (scope `quilt`) comes from `WeaveClient.quilt_token`, and
its token for Stash (scope `stash`) from `WeaveClient.stash_token`.
- **All Vast access goes through `krater.vast`**, and only from the worker: the organization's Vast key never
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ The full stack (Postgres, a one-shot migration, the portal and the worker) also
`docker compose up --build`.

Every Patchwork member Weave lets use Krater is a member and can submit a proposal. Weave owns the other roles: a
Weave admin gives people or groups Krater's app roles `reviewer` and `admin`, and Krater reads them at sign-in and re-checks them with Weave's directory API before every action. In stub mode (the default for
Weave admin gives people or groups the Ganymede patch roles `krater:reviewer` and `krater:admin` (during the move,
Krater's old app roles `reviewer` and `admin` count too), and Krater reads them at sign-in and re-checks them with Weave's directory API before every action. In stub mode (the default for
development) the fixture users in `krater/weave/stub_users.json` carry their roles. See `docs/weave-integration.md`.

5 changes: 4 additions & 1 deletion docs/SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Three roles:
A "logged in but can't submit" tier and a public/anonymous tier are still deferred. The gallery itself is public.

**Authentication** is OIDC against Weave (Authorization Code + PKCE; Weave enforces PKCE). Krater asks for the scopes
`openid profile email groups roles slack`. All Weave access goes through one adapter module (`WeaveClient`) so Weave
`openid profile email groups roles slack patches`. All Weave access goes through one adapter module (`WeaveClient`) so Weave
changes don't spread through the app. The contract is in [weave-integration.md](weave-integration.md).

**Weave owns roles** (maintainer decision, Oct 7, 2026). Krater never stores a role as its own source of truth:
Expand All @@ -76,6 +76,9 @@ changes don't spread through the app. The contract is in [weave-integration.md](
- The `roles` field is the source of truth. Only when Weave sends no `roles` field at all (absent, not empty) does Krater
fall back to group slugs linked to the Krater app: `krater-reviewers` and `krater-admins`. The keys and slugs are
settings (`KRATER_WEAVE_ROLE_*`, `KRATER_WEAVE_GROUP_*`).
- Weave is moving these roles to the Ganymede patch (weave#288): the patch role keys `krater:reviewer` and
`krater:admin` in the `patches` claim (settings `KRATER_WEAVE_PATCH`, `KRATER_WEAVE_PATCH_ROLE_*`). During the move
Krater holds the union of the patch roles and the app roles (`docs/weave-integration.md` "Patch roles").
- Inside Krater the roles keep the names `ganymede:member`, `ganymede:reviewer` and `ganymede:admin`, so review snapshots
and approval policies read the same. `krater.weave` translates at the boundary. Later tiers
(`ganymede:reviewer:<tier>`) will need a matching Weave role key.
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/production.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ Production runs `hosts/weft/krater-production.nix` with compute off, and ships b
- **Ports 80 and 443** open to the internet. Let's Encrypt needs port 80 to issue certificates.
- **Weave** (production Weave, not staging), following [weave-integration.md](../weave-integration.md):
- Krater's app has redirect URI `https://<KRATER_DOMAIN>/auth/callback` and scopes
`openid profile email groups roles slack directory`.
`openid profile email groups roles slack patches directory`.
- A Weave superadmin creates the roles `reviewer` and `admin` on it, and gives you `admin`. Members need no role.
- **Slack:** the app's interactivity URL is `https://<KRATER_DOMAIN>/slack/interactions` ([slack-setup.md](slack-setup.md)).
- **Vast** (compute on only): the production API key, in a file only root can read, mounted into the worker alone
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/staging.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ At `http://localhost:3000/admin/oauth_applications`, create a **confidential** a
`docs/weave-integration.md` "Setting up Weave for Krater"):

- Redirect URI: `http://localhost:8000/auth/callback`
- Scopes: `openid profile email groups roles slack directory`. Krater uses `directory` for its own client_credentials
- Scopes: `openid profile email groups roles slack patches directory`. Krater uses `directory` for its own client_credentials
token; without it the directory API answers 403.
- Note the client id/secret for `KRATER_WEAVE_CLIENT_ID`/`KRATER_WEAVE_CLIENT_SECRET`.

Expand Down
Loading
Loading