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

OAuth: the authorization server, scopes on every method, and web, native and confidential clients

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/monolith:oauthr

atproto OAuth on the PDS: the authorization server, OAuth access tokens on every XRPC method with scopes, and web, native and confidential clients. Three slices, each specified by an agent that probed the reference, checked by a harness written from the spec, and built from the spec alone, then integrated on hardening and spaces.

Spec pages (new)

  • OAUTH.md, the authorization server:
    • the issuer and its metadata (RFC 8414, the protected-resource document RFC 9728);
    • PAR (RFC 9126, required);
    • DPoP (RFC 9449) with server nonces;
    • PKCE S256;
    • the authorization page and its API (sign-in, the account chooser, consent);
    • the redirect;
    • the token endpoint (authorization_code, refresh_token with rotation and reuse detection);
    • revocation;
    • OAuth tokens on XRPC;
    • errors, rate limits, durability.
  • OAUTH-SCOPES.md: which methods take an OAuth token, and what atproto, transition:generic, transition:chat.bsky, transition:email, and the granular repo:, blob:, rpc:, account: and identity: scopes allow. Every method is in one table (METHODS), and a test holds the table to the router. space: scopes are noted for later: space methods refuse DPoP tokens for now.
  • OAUTH-CLIENTS.md: client IDs (https documents, loopback for development), the client metadata document and its checks, native and web redirect rules, confidential clients with private_key_jwt (one-use jti, key rotation), silent sign-in (prompt=none), and the SSRF-safe document fetch.
  • The RFCs the pages rest on are vendored under spec/rfc/.

Where the server follows the specs rather than the reference. The reference:

  • takes a PAR without DPoP or without state;
  • takes a reused state;
  • takes a parameter given twice;
  • issues 60-minute access tokens (the server's last 15 minutes);
  • serves an authorization request without PAR;
  • takes non-200 client documents, token_endpoint_auth_signing_alg: none, and http: URIs on loopback.

The pages list each of these with the spec text. The harness holds the server to the page and doesn't compare these with the reference. Clients rely on none of them.

Server: oauth.rs (with oauth/clients), scopes.rs, and replay.rs (single-use values: DPoP jtis, client-assertion jtis and codes, durable and compacted). The signing key oauth.key is created owner-only. OAuth calls pay their own rate limits (LIMITS.md, "OAuth access tokens").

Harness

  • checks/oauth.mjs: the whole flow, driven through the authorization page's API on both sides, with every refusal compared, plus refresh, rotation, reuse and revocation.
  • checks/oauth-scopes.mjs: OAuth tokens drawn into the random steps on every method, under random scopes.
  • checks/oauth-clients.mjs: client documents served by a stub host.
  • oauth-limits.mjs: inside --limits.

Checked on this branch: plain seeds 1–3 (150–180 OAuth comparisons each), --commands 31, crash seed 21 with --firehose, --limits (OAuth checks included), --invites, the spaces run, and cargo test --workspace. The merge queue runs the full gates.

🤖 Generated with Claude Code

Approved

This pull adds atproto OAuth. That is the authorization server, OAuth access tokens with scopes on every XRPC method, and web, native and confidential clients. It comes with three new spec pages (OAUTH.md, OAUTH-SCOPES.md, OAUTH-CLIENTS.md), the vendored RFCs, server modules, and harness checks.

I did not read the whole 28k-line diff. I read the PDS.md, README.md and lib.rs changes, the Cargo manifests, the compare.mjs and env.mjs wiring, and oauth/clients/fetch.rs, oauth/dpop.rs and replay.rs. I did not read the rest of oauth.rs, scopes.rs, oauth/page.rs, oauth/client.rs or the other oauth/clients/* files, the harness check modules, or the spec pages. I also skipped the vendored RFC and atproto text, the lockfiles, and the changes to blobs.rs, compact.rs, log.rs, repo.rs, server.rs and sessions.rs. Their behaviour is not confirmed by my review.

What I found against .knotless/review.md:

  • Spec and README: The new pages are linked from spec/PDS.md. The new environment variable is listed there, and the README names the new pages and its OAuth gaps. No history or plans appear in what I read.
  • Dependencies: The new crates (percent-encoding, serde, url) are general-purpose, not atproto or MCP crates. The harness gains @atproto/oauth-client-node, which is allowed for the harness.
  • Conformance: harness/conformance.yaml is untouched, so there are no new excuses to check.
  • Code I read:
    • The DPoP proof check follows the order and the nonce, ath and jti rules the pull describes.
    • Spent values are stored as SHA-256 digests and replayed from the log.
    • The client-document fetch refuses redirects and non-public addresses (including IPv4-mapped IPv6, NAT64 and 6to4 forms), caps size and time, and keeps the development origin mapping behind an environment variable.

Two small points, neither blocking:

  • The README --limits sentence now ends a clause with "with password sessions and OAuth tokens," and the next line begins "then holds…". It reads as a fragment and could be reworded.
  • The gates run on this head was still running when I looked, so the full harness results are not yet in.
Merged as 3a9a9f8