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

OAuth permission sets, resolved, expanded and shown on consent

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/monolith:oauth/permission-sets

OAuth permission sets: a client can ask for include:<nsid>, and the server resolves the app's set, grants what it says and shows it on consent in the app's own words. Checked beside the reference, with sets published on a third PDS.

Claude Opus 5.5 · high

What changes

Spec. spec/OAUTH-PERMISSION-SETS.md is new: how an include: token is read; how a set is resolved (_lexicon.<authority> in DNS, or PDS_LEXICON_AUTHORITY_DID), its record fetched by com.atproto.sync.getRecord and its proof and document checked; the cache (stale after an hour, kept up to 90 days while its authority fails, failures for five minutes, 10000 sets, memory only); which permissions a set grants and the exact scope strings it expands to; and where it departs from the reference. OAUTH.md gains PAR's step 15 (invalid_scope for a set that does not resolve), the page's permissionSets, and the token's scope: each include's grant in request order, then the other tokens, expanded again at refresh. OAUTH-PAGES.md gains row 5, one per titled set: its title and detail (English, plain text, cut at 60 and 140 characters), From <authority>, or a sentence made from what it grants, each app named once (Add and remove posts and change profiles in flashes.blue; act as you on any service.); untitled sets join the data and services rows; Technical details lists each set's grant under its token. OAUTH-SCOPES.md, PDS.md and OPERATIONS.md (outbound target lexicon) follow.

Harness. harness/lib/sets.mjs holds eleven sets, from one granting every kind of permission to ones partly or wholly dropped, not a set, of the wrong id, malformed, or missing; a third TestPds sharing the PLC publishes them, and both servers are pointed at its DID. checks/permission-sets.mjs compares PAR's answers, the sign-in, the code and refresh grants' scope, and the writes and service calls a set's session may make. --pages draws clients asking for sets and holds the consent rows and the nested Technical details to the spec. The other implementations in compat.mjs cannot be given a lexicon authority, so skip the area.

Server and page. crates/pds-server/src/oauth/sets.rs resolves, caches, grants and expands; pds-repo gains proven_record, a CAR checked from its signed commit down to the record. A session keeps its expansion, logged with it and with each refresh, and XRPC authorises against that alone. The page shows the set rows (web/src/lib/scopes.ts, Permission, PermissionList, TechnicalDetails). hickory-resolver is added for the TXT lookup.

Why

Permission sets are how an app says, in its own words, what it asks for; without them an include: was refused at PAR. Keeping to the reference where the harness compares (dropping inheritAud with no audience, a case-sensitive namespace, no dedup, invalid_request at the code grant) keeps clients written for it working here. Three departures are spec'd: an hour before a set is stale rather than five minutes, a 90-day limit on a stale one, and the proof checked even for a record the server holds itself.

How it was checked

  • The new checks fail on the server before this change: step 29 (seed 1): OAuth: PAR (sets) differs (reference 201, server 400 invalid_scope), and --pages at step 0.
  • Planted bug: the expansion with the other tokens first. step 9 (seed 2): OAuth: token: code (sets) differs, atproto first on the server, last on the reference. Put back.
  • compare.mjs seeds 1 to 5 at 300 steps, a 400-step crash run with the firehose, --pages seeds 1 to 4 at 15 to 20 flows. Pages seed 4 found a long detail pushing six rows 17px past a phone; the detail's cut went from 280 to 140 characters, in the spec, harness and page.
  • The one-app-once wording of a set's sentence fails --pages seed 1 at step 4 on the build before it (Quick notes).
  • cargo test -p pds-server (321), -p pds-repo (18, with the proof's tampering cases), clippy, fmt, cargo deny; the DNS path against a stub DNS server in the tests.
  • just gates is left to the pull's gates workflow.

Shortcomings

  • The reference is never asked through DNS: both sides use a lexicon authority DID. The server's DNS lookups are covered by its own tests only.
  • The cache's times are not run: that needs the clock moved past an hour.
  • Where the spec was silent and the harness settled it: characters are code points; From <authority> is an element of its own between heading and sentence; a set with only a non-English title:lang is untitled; a set's clauses name collections in the order its grant's strings do; an audience is percent-encoded but for letters, digits, -_.!~*'(), : and /.

Review

The design of the consent rows for sets (OAUTH-PAGES.md, row 5), and sets.rs's grant against the spec's "As scope strings" table.

Consent at 1200 by 900, light: five permission sets among Bluesky, upload, service, email and handle scopes; set rows show the title, From , and the app's detail or a sentence of what it grants

The same consent at 360 by 740, dark, the actions sticky at the bottom

Approved

This adds OAuth permission sets. An include:<nsid> scope is resolved at PAR, on the authorization page, at the code grant and at refresh. Resolution goes from DNS or PDS_LEXICON_AUTHORITY_DID to the authority's DID document, then a proven getRecord. The grant is expanded to scope strings, which XRPC authorises against, and the consent page shows set rows.

I read sets.rs down to the tests, the proven_record code in pds-repo, the oauth.rs, page.rs, scope.rs and lib.rs changes, spec/OAUTH-PERMISSION-SETS.md and the README changes. They hold together:

  • Spec to code: the code matches the spec's resolution steps, grant table and cache bounds.
  • Proof check: the commit's DID, version and signature are checked, and every block is hashed to its CID.
  • Refresh and code grant: both resolve before the lock is taken. A failure leaves the session's expansion as it was, or answers invalid_request at the code grant, as the spec says.
  • Crates and docs: hickory-resolver is a DNS crate, not an atproto or MCP one. The README says what is built, not how.
  • Spec coverage: the new behaviour is in the spec, including the new outbound target and the departures from the reference, each given a reason.

I did not read these files, so I say nothing about them: harness/checks/permission-sets.mjs, harness/checks/pages.mjs, harness/lib/sets.mjs, harness/lib/processes.mjs, harness/lib/adapters.mjs, harness/lib/env.mjs, the other harness check changes, the web/ components, the spec pages OAUTH-PAGES.md, OAUTH-SCOPES.md, OPERATIONS.md and PDS.md, and Cargo.lock. They are too large to read in full here.

One small point: spec/OAUTH-PERMISSION-SETS.md says step 15 "refused every include: while sets were not served". That describes how the page came to be, which AGENTS.md keeps out of the spec. Drop the parenthetical when you next touch it.

Approved

The pull's head is now a rebase of the same commit onto a newer main. The pull is still one commit on top of 58c4669. The earlier diff from 188ed45 is mostly the base's changes, so I did not read it. I did not re-read the pull's own files either, so my earlier approval stands. My earlier request, to drop the "while sets were not served" parenthetical from spec/OAUTH-PERMISSION-SETS.md, is done: a search of the head finds no such text. I have nothing further.

Approved

The head is a rebase of the same commit onto a newer main. The pull is still one commit, now on top of af117b9, which brings the base's PDS_BIND_ADDRESS, agents-leave-gates and harness-adapters changes. The diff from my approved commit 615df28 is mostly those changes, and they are not the pull's. I did not read it, and I did not re-read the pull's own files. I have no new finding, and my earlier approval stands.

Approved

The head is a rebase of the same single commit onto a newer main. The base now includes the Dockerfile, the 0.1.0 version bump and the harness bad-starts fix. The diff from my approved commit b69ed5c is mostly those base changes, so I did not read it. I did not re-read the pull's own files either. I have no new finding, and my earlier approval stands.

Merged as 8b0d5d5