chadtmiller.com/group-host
atmosphere group host
Apps signed in as a group call other services through the host
MergedThis pull adds atproto-proxy forwarding for apps signed in as a group, plus getServiceAuth and rpc: / transition:* scope checks. It also adds narrowing for other apps' permission sets, which are resolved over DNS-over-HTTPS and the publisher's PDS.
I read proxy.rs, permission_sets.rs, scopes.rs, oauth_scope.rs, authorization.rs and the routing change in lib.rs. I did not read the tests, docs, config.rs, oauth.rs, mcp.rs, provision.rs or rbac.rs. I ran no checks.
What I checked and found sound:
- Local routes win over the proxy catch-all.
- The scope and
repo:*check runs before the DID is resolved or any service is contacted. - The outbound JWT's
audis the bare DID, and itslxmand one-minute expiry are right. Authorizationis never forwarded.- Self-proxying and the protected and admin method lists are refused.
- Include scopes are limited to the publisher's own namespace, and a set that is not a
permission-setis rejected.
Three minor notes, none blocking:
- A failed DoH or PDS lookup is cached as "missing" for ten minutes (
permission_set). A transient outage therefore withholds a set at approval until the cache entry lapses. get_authorizationresolves everyinclude:scope in a request one after another. An unauthenticated caller can send many distinct NSIDs and trigger as many outbound lookups, bounded only by the 1000-entry cache. A cap on the number of includes resolved per request would help.Permissions::rpctestschat.bsky.case-sensitively, whileprivilegedlowercases first. A scope named with different casing would behave differently on the two paths.
The change since my approval is small. It narrows Permissions::rpc in scopes.rs so each rpc: scope on a token names one method. The rpc:?lxm=… multi-method form is no longer matched there.
I think this is safe. Narrowing keeps each rpc:M as its own scope and tokens are concrete, so the multi-method form shouldn't reach a token. The new doc comment says so. The */* rule is unchanged: a wildcard audience with a wildcard method still doesn't match. My earlier approval stands.
I did not run any checks. My three earlier minor notes aren't addressed in this diff. They weren't blocking.
8 passed, 1 skipped
What changes
Proxying. An app signed in as a group (OAuth token or app-password session) can now call other services through the host, as through any account's PDS. A call to a method the host doesn't serve, carrying
atproto-proxy: <did>#<service>, is sent on to the endpoint that service id names in the DID's document. The host signs service auth with the group's key (issthe group,audthe service's bare DID,lxmthe method, lapsing in a minute) and streams the answer back. It forwards the method, path, query, a POST's body (up toBLOB_UPLOAD_LIMIT), and the headers the reference PDS forwards (accept-encoding,accept-language,atproto-accept-labelers,x-bsky-topics,x-atproto-*, and a body'scontent-type/content-encoding). It passes back the status, thecontent-*headers,atproto-repo-rev,atproto-content-labelersandretry-after. Failures come back as the reference PDS gives them: the service's error name and message, with a 500 turned into 502UpstreamFailure. Each call is logged with its method, service and status, never a token or a body. Without the header, an unknown method still gets 501MethodNotImplemented. A method the host serves is always answered by the host.getServiceAuth.
com.atproto.server.getServiceAuthtakesaud(a DID ordid#service, used as given),lxmandexp, with the reference PDS's limits (BadExpiration: within an hour for a method, a minute for none). It refuses protected methods.Scope. A token needs
rpc:<lxm>?aud=<did>#<svc>(with*for either, but not both),transition:generic(anything butchat.bsky.*) ortransition:chat.bsky(chat). Without it the call fails 403ScopeMissingErrorMissing required scope "rpc:…", as the reference PDS answers. The approving member must still holdrepo:*at each call (Forbidden). An app-password session follows the reference PDS's access-token rules: it may call anything but chat andcreateAccount, unless the password may use chat (InvalidToken"Bad token method"). Methods for managing an account directly (getSession,createAppPassword,updateHandle, … and everycom.atproto.admin.*) are never proxied (InvalidToken) and never get service auth (InvalidRequest). The host refuses its own DID and any endpoint atPUBLIC_URL, such as a group's own#atproto_pds. Unresolvable DIDs and unknown service ids getInvalidRequest. A service gets the same public-address pinning as client metadata, so a private address or a non-https URL is refused with 502UpstreamFailure.Narrowing. For roles holding
repo:*(the same rule as making an app password), approval now keepstransition:genericandtransition:chat.bsky. It also keeps other apps' permission sets (include:<nsid>?aud=…, such associal.grain.authFull). A set is resolved as atproto publishes lexicons: the_lexicon.<authority>TXT record is read from the newDNS_OVER_HTTPS(Cloudflare's JSON endpoint by default), then the DID it names gives the PDS that holdscom.atproto.lexicon.schema/<nsid>. That record is read at a public address and kept for ten minutes. A set'srepoandrpcpermissions within its namespace are kept asrepo:Candrpc:Mare.rpctakes the include'saudthroughinheritAud. The set is kept whole when the roles grant every part, and is otherwise cut down to the parts they grant. Tokens stay concrete: the set becomes its scopes at approval. The approval page labels another app's set with its lexicon'stitleanddetail. CORS now allowsatproto-proxyandatproto-accept-labelers.Docs:
signing-in.md(new "Calling other services as the group", narrowing, app passwords),api.md,config.md, design README.Why
A group on groups.grain.social could sign in to next.grain.social, but every
social.grain.*call came back 501MethodNotImplemented(production, 01:31:58Z). The host was a PDS that couldn't proxy. Grain's apps ask fortransition:genericorinclude:social.grain.authFull?aud=did:web:grain.social%23grain_appview, and the host withheld both, so proxying also needed narrowing to keep them.On proxying, I followed the reference PDS's current behaviour. The scope check sees
did#service, the outbound JWT'saudis the bare DID, local routes take precedence over the header, and the protected/privileged method lists match. A missing scope is refused with the reference'sScopeMissingErrorrather than the host's ownScopeMissing, because apps written against a PDS read that name.For the
_lexiconrecord, the host has no DNS resolver. A configurable DNS-over-HTTPS service followsHANDLE_RESOLVERS' precedent of asking an HTTP service for DNS. It adds no dependency, and tests can fake it.How it was checked
tests/proxy.rsruns against a fake Grain AppView, a fake DoH service and a fake lexicon PDS:iss,aud,lxm,exp). The query, body and forwarded headers arrive, and the answer comes back with its headers.retry-after, 404 non-JSON, 418).transition:*and chat are checked, including a member who losesrepo:*.#atproto_pds), an unresolvable DID, an unknown service, an unreachable service, and a private address and non-https URL on an https host.The
oauth_scopetest now expectstransition:genericfor admins, and theconfigtests coverDNS_OVER_HTTPS. Locally,cargo test -p group-hostpasses, apart from the tests that need the harness's node packages (not installed in this worktree).cargo clippy -D warningsandjust docsare clean. Coverage and the harness tests are left to CI.Shortcomings
spacepermissions grant a group's session nothing yet.BLOB_UPLOAD_LIMIT) before being sent on. Only the answer is streamed.DNS_OVER_HTTPSis Cloudflare's: operators who'd rather not depend on it set their own.Review
Start at
crates/group-host/src/proxy.rs, thenpermission_sets.rsand the narrowing change inoauth_scope.rs.