zds refuses rpc?lxm=…&aud=… scopes with invalid_scope
What happens
When an OAuth client asks for an rpc permission with its method written as a parameter, zds refuses the whole sign-in. The scope:
rpc?lxm=*&aud=did:web:api.bsky.app%23bsky_appview
fails at PAR with:
{"error":"invalid_scope","error_description":"Unsupported scope"}
The sign-in fails even when the client metadata declares the scope. We hit this with HUD (https://hud.place): a user on a zds PDS couldn't sign in. HUD asked for rpc?lxm=*&aud=<service> for each of five services.
Why it should be accepted
The atproto permission spec (https://atproto.com/specs/permission) uses this exact string twice: as the example of calling any method of one service, under rpc, and in its list of syntactically and semantically valid scope strings:
rpc?lxm=*&aud=did:web:api.example.com%23svc_appview
lxm is rpc's positional parameter, and the spec says a positional parameter can be written as a key/value pair instead (account:repo?action=manage is account?action=manage&attr=repo). So rpc?lxm=*&aud=X and rpc:*?aud=X are the same permission.
The reference implementation agrees. @atproto/oauth-scopes 0.5.14 parses both to {"lxm":["*"],"aud":"did:web:api.bsky.app#bsky_appview"}, and both allow app.bsky.feed.getFeed to that audience.
Where (zds v0.14.21, c1df24a)
- Validation:
isGranularScopeinsrc/atproto/oauth.zigaccepts therepo?andspace?parameter forms, but notrpc?,blob?,account?oridentity?. Those fall through to"Unsupported scope"invalidateScope. - Enforcement:
rpcAllowsinsrc/internal/scopes.zigskips any scope that doesn't start withrpc:, andrpcMethodMatchesreads the method only from afterrpc:. So even if (1) were fixed,rpc?lxm=…&aud=…would grant nothing.
Suggested fix
- Accept the parameter form of every resource in
isGranularScope:rpc?,blob?,account?andidentity?, asrepo?andspace?already are. - Where a permission is matched, read its positional parameter from the query when it isn't given positionally:
lxmforrpc,acceptforblob,attrforaccount/identity. The query may repeatlxm(andaccept), since these are arrays. - Test that
rpc?lxm=*&aud=did:web:api.bsky.app%23bsky_appviewpasses PAR and allows the same calls asrpc:*?aud=did:web:api.bsky.app%23bsky_appview.
Workaround for clients
Write the method positionally: rpc:*?aud=<service>. zds accepts it, and so do the reference PDS and others.