chadtmiller.com/monolith
An atproto PDS
pds-server: OAuth tokens on the space methods, by their space: scopes
MergedThis pull makes the space methods take OAuth access tokens and allow what their space: permissions allow. It adds space_scope.rs for parsing, rewriting and matching, and it resolves space type declarations beside permission sets at the page, the code grant and each refresh. The space_authority.rs, space_repo.rs and space_credentials.rs handlers ask the scope at the points OAUTH-SCOPES.md gives. The pull also adds harness/spaces/scopes.mjs and rewrites the spec's "Spaces" section.
I read all 23 files. The code matches the spec's table of what each method needs and where it asks. That covers the order of the ScopeMissingError checks relative to RepoNotFound, the published-collection refusal and the missing-space cases. The transition:generic and app-password handling matches too. The earlier listSpaces check that refused OAuth tokens is removed from oauth-scopes.mjs. It is replaced by the comparison in scopes.mjs, which is stricter, because it checks every method against the alpha. The changeset is written for operators. The spec, README and OAUTH.md table are updated. The harness adds no atproto crates, and the server code takes nothing from the reference's source.
run_list shows no gates run on this pull, so I couldn't confirm the full spaces run passes. The compare suite's budget rose from 125 to 155 seconds for the third PDS, so check that the run fits.
Two things you may want to do, neither blocking:
docs/guide/comparing.md's "Spaces" section doesn't say that the run now starts a third PDS as lexicon authority, or that it usesPDS_LEXICON_AUTHORITY_DID. The review rules ask a change to how the server is checked to update its guide.import_repo's OAuth need is untested. The pull's body andSPACES-EXPORT.mdboth say so.
docs/guide/comparing.mdline 218OutdatedResolved
| |
```sh | |
cd harness/spaces && npm ci | |
node compare.mjs --seed 1 -- ../../target/release/pds serve |
Not in this pull's diff: the Spaces section here should mention the third PDS and PDS_LEXICON_AUTHORITY_DID that scopes.mjs adds to the run.
Since my approval at 81d6ffa, the only change is in docs/guide/comparing.md. Its "Spaces" section now says the run starts a third PDS as lexicon authority and sets PDS_LEXICON_AUTHORITY_DID. That was my earlier non-blocking note, and it is done. The approval stands. The untested importRepo OAuth need is still open, and the pull's body and SPACES-EXPORT.md both say so.
3 passed, 1 skipped
OAuth apps can now use spaces on Monolith accounts: the space methods take OAuth access tokens and allow what their
space:permissions allow, as the spaces alpha of the reference does, where before they refused every OAuth token. HUD and knotless's CLI and gateway ask forspace:scopes and could not use a Monolith account's spaces.Claude Opus 5.5 · high
What changes
Spec.
OAUTH-SCOPES.md"Spaces" says what is, not what is for later: whichspace:permissions parse (positionalspaceType,authoritydefaultself,skeydefault*,collection,action,manage); space type declarations (defs.mainof typespacewith akeyandcollections), resolved as permission sets are, at the page and again at the code grant, never at PAR; the token's scope, where aspace:token with no collection gets its declared collections, sorted, andauthority=selfthe account's DID, written again as the alpha writes it; what a permission allows (readoverread_self; writes by action and collection;manage); what each space method needs and at which point it is asked; and the403 ScopeMissingErrornaming thespace:scope that would allow the call.transition:genericallows nothing of a space. A space type that does not resolve sends the browser back to the client from the authorization page withinvalid_scope"Unable to retrieve space declarations", ending the request.OAUTH.mdkeepsspacepermissions;SPACES-REPO.md,SPACES-POLICIES.mdandSPACES-CREDENTIALS.mdtake OAuth tokens where they name who may call (getDelegationTokenwith areadgrant; app passwords still refused it);SPACES.mdgives the spaces run its lexicon authority.Harness.
harness/spaces/scopes.mjs, in the spaces run: a third PDS publishes space type declarations (with collections and a title, with none, of anotherkey, with nokey, with nocollections, and a document of another type), and both sides resolve from it (PDS_LEXICON_AUTHORITY_DID, the alpha'slexicon.didAuthority). Loopback clients asking for 22space:scopes sign in on both sides through the page's API, each step compared, the token answer'sscopeamong them; then each session calls the space methods on its account's spaces, another's and spaces never made (createSpace with and without a key, another type, getSpace, listSpaces with each filter, create/put/delete/applyWrites in each case including records of another type and published collections, the reads, getDelegationToken, the memberspace methods, removeWriter, updateSpace, export and importSpaceMeta, clearRecords, deleteSpace), comparing status, error and aScopeMissingError's message with DIDs named alike. The main run's check from 03290bc, thatlistSpacesrefuses an OAuth token as400 InvalidToken, is removed: the main run's reference keeps nospace:permission, and the method now takes the token.Server.
oauth/space_scope.rs: aspacepermission read, written, matched and rewritten;oauth/scope.rskeeps it;oauth/sets.rsresolves declarations beside sets and expands a session's scope with them at the grant and each refresh; the page redirects withinvalid_scopewhen one does not resolve.scopes.rsreads aDPoPtoken on each space method that takes an account's token, andmay_space/may_inask the scope;space_authority.rs,space_repo.rsandspace_credentials.rsask it where the spec says (an OAuth session counts as its account's, never an app password's).Why
Monolith served the space methods to its own password sessions only. Apps sign in with OAuth, and the scope they ask for spaces is
space:; without it a Monolith account could not use HUD's or knotless's spaces. The alpha is the reference, so its answers were probed and the spec written to them, with the harness comparing each.A client such as HUD asks
space:com.chadtmiller.hud.workspace?authority=*&manage=create&manage=update&manage=delete; with a declaration ofcom.chadtmiller.hud.workspacepublished, its token holdsspace:com.chadtmiller.hud.workspace?authority=*&collection=<each declared collection, sorted>&manage=create&manage=update&manage=delete. Without a declaration the sign-in is sent backinvalid_scope.How it was checked
scopes.mjsrun alone against the alpha on both sides: agrees; against a server built frommain(616c0b8, whose server ismain's): fails at the first sign-in, the token'sscopeatprotowhere the alpha's isatproto space:com.example.workspace?authority=<did:1>&collection=com.example.note&collection=com.example.tile; against this branch: agrees, every case.SpacePermission::allowstaking a write's action without its collection. Failed atcreateRecordofcom.example.zzwith a barespace:com.example.workspace: the alpha403 ScopeMissingErrornaming...&collection=com.example.zz&action=create, the server200. Put back.cargo test -p pds-serverof the changed modules (space_scope, oauth::scope, oauth::sets, scopes, space_authority, space_credentials, space_repo): pass.cargo fmt,clippy -D warnings,spec-coverage.mjs,code.mjs: pass.gatesworkflow, on this pull.Shortcomings
importRepowith an OAuth token is not called by any run; its need (createof each collection the archive names) is the spec's alone.space:permission as its scope string (row 10 ofOAUTH-PAGES.md), not in words, and its__authorizeDatahas nospaces/spaceHandlesas the alpha's has: the server's pages follow the latest reference's, which the main and pages runs compare.spacepermissions are not expanded intospace:scopes.@atproto/oauth-scopespackage read, and are now held to the alpha only by the harness.Review
The design and the risky part: where each method asks the scope relative to its other checks (
OAUTH-SCOPES.md, "What each method needs", andspace_repo.rs'srecord_scopeandwrites_scope). Start atspec/OAUTH-SCOPES.md"Spaces", thenharness/spaces/scopes.mjs.