chadtmiller.com/group-host
atmosphere group host
Apps write as the group with their tokens, within scope and the member's roles
MergedThis pull lets an app write as the group with a DPoP-bound token. It adds token verification (ath, key binding, nonce, 401 challenges), the repo and space write methods, getSession, and a scope parser. Each write also checks the approving member's current roles, and the guard on the meta and members spaces matches what the host's own methods allow.
I read the resource server, the write handlers, the guard, lib.rs, the DPoP change and the store query. I read only part of the 744-line tests/tokens.rs and did not read these files:
scopes.rsoauth_scope.rsoauth.rsrepo.rstests/common/oauth.rs- the docs changes
I found no defects. check, web and lexicons pass. test, which carries the 100% coverage gate, was still running at this commit, so I can't say whether it passes.
Two small things, neither blocking:
putRecordandspace.putRecordcheck scope and roles only when the put changes something. A put of identical content succeeds for a token whose scope doesn't cover that collection. It leaks nothing beyond the caller's own input, but checking first would be more predictable.swapCommitis checked beforehost.writerather than inside it, so two concurrent writers can both pass the check.
What changes
Using a token (
oauth_resource.rs). An app calls the group's PDS methods withAuthorization: DPoP <token>and a proof that hashes the token (ath), signed by the key the token is bound to. A refusal is 401 with aWWW-Authenticate: DPoP error=…challenge and the nonce for the next proof, as RFC 9449 has it:invalid_tokenfor an unknown, lapsed, refreshed-away or Bearer token, or one proved by another key;invalid_dpop_proof;use_dpop_nonce.Writing as the group (
token_writes.rs):com.atproto.repo.createRecord,putRecord,deleteRecord,applyWrites(200 writes at most), as itsrepo:scope allows, withswapCommitandswapRecord; anduploadBlob, as itsblob:scope allows;com.atproto.space.createRecord,putRecord,deleteRecord,applyWrites, as itsspace:scope allows;com.atproto.server.getSession: which group, and whether it is switched on.A put of what is there makes no commit, and a delete of what isn't there is done.
Scopes are read as atproto's permission spec reads them (
scopes.rs, following pds.js'sscope.js).repo:C,repo?collection=…, actions;blob:andblob?accept=…, MIME patterns;space:Tandspace?type=T. A space scope's authority is the group unless the scope names one, its skey any, and with no action it grants all butread_self, whichreadimplies.The member's roles are asked at each use, as the review of the OAuth pull asked. A grant keeps its approved scope through refreshes, so each write also checks the approving member's current roles, by the rules narrowing used: repo collections by the permissions record, the group's own spaces by
group.configure, other spaces by their access records'credentialScopes, and spaces for chosen people only for those of them who holdrepo:*. A member whose roles shrink gives the app less at once.In the group's own meta and members spaces, a token writes only as the host's methods would (the prototype's
groupWrites.ts):selfand never deleted;RoleInUse).Memberships, permissions, and any space's access record change only through the host's methods.
Why
Step 6's second part: the tokens the OAuth server issues now do what they were approved for. Group tokens, app passwords and connected apps come next, then provisioning.
What changed from the prototype:
$type, not their lexicons, sovalidationStatusisunknown, as a PDS answers for a lexicon it does not know.getSessionis answered for a token; the prototype's came with app passwords.How it was checked
tests/tokens.rs:getSession, and refusing writes for a switched-off group;These port the prototype's
pds.test.tsandgroupWrites.test.tscases for writes with a token, andauthorization.test.ts's "works at the resource server".Shortcomings
com.atproto.space.getRecordand the like, for the group's own repo) still take a space credential only.clearRecordsis not taken yet.