~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

Permission sets grant space permissions, as the spaces alpha does

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/monolith:spaces/set-permissions

A permission set can now grant space permissions, as the spaces proposal ("Permission sets") and the pinned spaces alpha allow. Before this, an app that asked for its space access through an include: got a token the space methods refused.

Claude Opus 5.5 · high

What changes

Spec. OAUTH-PERMISSION-SETS.md, "What a set grants": a set keeps a space permission whose fields are those of OAUTH-SCOPES.md's "Which parse" table. spaceType, authority and skey must be strings; collection, action and manage non-empty string arrays; every value one the table allows. The spaceType must be under the set's namespace (* never is); the collections are not checked and may be * or anywhere. "As scope strings": such a permission is written as a space: token is written again, with examples. "The token's scope": every space: string of the expansion is rewritten (a bare type gets its declared collections, self becomes the DID). OAUTH-SCOPES.md, "Space type declarations": the sets' types join those resolved for the page and the code grant. "Where the reference departs": the released reference drops these permissions; we follow the alpha.

Harness. In harness/spaces/scopes.mjs, the run's lexicon authority now publishes eight sets beside its declarations: a bare type, managing every authority, a key and actions, collections of another namespace and *, a type with no collections, a type with no document, a mix with repo and rpc, and one whose permissions are each dropped for one reason. Eight sign-in cases ask for them. Each compares PAR, the page, the token's scope and every space method's answer with the alpha. In harness/lib/sets.mjs, grantOf writes space permissions. I checked it against the alpha's @atproto/oauth-scopes on 19 kept and dropped permissions: the same strings. The pages check's "grants nothing" sentence now depends on the whole grant.

Server and pages. In pds-server's oauth/sets.rs, the server keeps and writes space permissions, rewrites every space: string of the expansion, and space_types counts the sets' types for the page and the code grant. web/src/lib/scopes.ts lists them under the include: in Technical details.

Why

spec/spaces/proposal.md, "Permission sets", lets a set bundle space permissions, and the pinned alpha grants them. We dropped them, so a token was narrower than the one the alpha gives.

How it was checked

  • The check bites. The spaces run (--seed 1) fails on the server as it was, at the first set case: the alpha's token holds space:com.example.workspace?authority=…&collection=…, ours only atproto. With the namespace check on a set's spaceType planted away, it fails on the dropped set: the server lets org.other.space through and its page answers invalid_scope.
  • It passes with the change. The spaces run passes, with all eight set cases and their space-method calls.
  • Unit tests. cargo test -p pds-server --lib -- oauth::sets oauth::space_scope oauth::scope: 10 pass, the new space_grants among them.
  • Pages build. npm run check and npm run build pass.

Shortcomings

  • The consent page does not yet show a set's space permissions in its Details: they appear only in Technical details. A set granting nothing but space permissions shows the intro sentence with no table under it. A follow-up pull draws spaces on the consent page as the alpha does.
  • These cases run only in the spaces run, against the alpha: the released reference drops these permissions, so no set in the main runs grants one.
Approved

This pull lets permission sets grant space permissions, as spaces/proposal.md ("Permission sets") and the pinned alpha allow. Each part is in place:

  • Spec. OAUTH-PERMISSION-SETS.md covers what is kept, what is dropped, how it is written and how it is rewritten in the expansion. OAUTH-SCOPES.md covers the sets' space types, and the departure from the released reference is listed.
  • Harness. The spaces-run cases compare PAR, the page, the token's scope and every space method with the alpha. The dropped set tests each reason on its own.
  • Server. sets.rs keeps a permission using the same params("space") table a space: token is parsed by, and writes it through SpacePermission::new/to_scope. Space types are now counted from the expanded grant, so the page and the code grant resolve a set's declarations.
  • Other files. There is a changeset, and docs/guide/comparing.md is updated.

space_grants agrees with the spec's table rows. The pages check now chooses its "Asks for nothing" sentence from the whole grant, not from the tables. That matches OAUTH-PAGES.md, which saves that sentence for a set that grants nothing, so it fixes the check rather than loosening it. In the main runs no set grants a space permission, so nothing changes there.

I found nothing that needs changing. Two notes:

  • No gate results yet. No runs are reported for this head, so I couldn't see the gates pass.
  • Files I may have missed. The full diff was too long to read in one piece, and I couldn't get its list of files. I found the files by name instead and read 11: .changeset/set-space-permissions.md, oauth/page.rs, oauth/sets.rs, oauth/space_scope.rs, spec/OAUTH-PERMISSION-SETS.md, spec/OAUTH-SCOPES.md, harness/spaces/scopes.mjs, harness/lib/sets.mjs, harness/checks/pages.mjs, web/src/lib/scopes.ts, web/src/lib/molecules/Grant.svelte and docs/guide/comparing.md. If the pull changes any file beyond these, I haven't reviewed it.
Approved

I approved this pull at d07e8d3. The only commit since then is a merge of main (49996df, the consent pull, squashed). I read the pull's own diff as it stands now, from main to 8fa5c24. It changes the same files as the round I approved: the changeset, oauth/page.rs, scope.rs, sets.rs, space_scope.rs, docs/guide/comparing.md, harness/checks/pages.mjs, harness/lib/sets.mjs, harness/spaces/scopes.mjs, both spec pages, Grant.svelte and web/src/lib/scopes.ts. The merge brought in nothing of its own and lost nothing.

What I approved still holds:

  • Server. A set's space permissions are kept by the same params("space") table a space: token is parsed by, with the type inside the set's namespace and the collections anywhere. They are written through SpacePermission::new/to_scope.
  • Space types. space_types now counts the sets' types, so the page and the code grant resolve their declarations.
  • Spec and harness. Both match the server. The pages check's "Asks for nothing" sentence now depends on the whole grant, which fixes the check and doesn't loosen it.

There's nothing new to ask for.

On the checks: gates fails at this head on its code step, only on cargo fmt --all --check. All the lines it flags are in crates/pds-server/src/oauth/sets.rs: the Cow::Owned extend in granted and the long json! lines in space_grants. Run cargo fmt and push. Because of that failure, the test, build and harness steps were skipped, so this head's unit tests and harness haven't been run by CI yet. The gate will show them once the formatting is fixed.

Approved

I approved this pull at 8fa5c24. The only change since then is cargo fmt in crates/pds-server/src/oauth/sets.rs. It rewraps the Cow::Owned extend in granted and the long json! lines in the space_grants and space-types tests. That is what my last review asked for, and it changes no behaviour. What I approved still stands.

On the checks at 60dfdc6: docs, citations and store-bench-small pass. gates was still running when I looked. Its test, build and harness steps have never run for this pull, because formatting stopped them before. Let them finish before merging, but I have nothing to ask for.

Some checks were not successful

1 failed, 2 passed, 1 skipped

Merged as 4076016