The Social Login for cavu.games and cavu.page
README.md

cavu-pds #

The cavu account server: vlpds at https://account.cavu.social, hosting *.cavu.social handles, deployed as the Fly app cavu-pds in the cavu org.

It's the OAuth sign-in server for cavu.games and cavu.page accounts, and it stores large blobs (up to 1 GiB) so cavu.games can distribute games over atproto.

How sign-in works #

Each cavu site has its own sign-in page with one field (handle or email) and a "Sign in with Google" button:

  • A handle goes through standard atproto OAuth to whichever PDS hosts it. A bare name with no dot (chris) means chris.cavu.social.
  • An email starts OAuth at https://account.cavu.social with the email as login_hint. Only cavu.social accounts can sign in by email, since atproto can't find a PDS from an email address.
  • Google starts OAuth at https://account.cavu.social and adds provider=google to the authorize URL, which skips the sign-in page and goes straight to Google. A new Google identity gets the sign-up form, with a random handle filled in that the person can change.

Google is a vlpds sign-in provider (upstream's OpenID Connect support, see upstream/docs/operations/sign-in-providers.md), configured at runtime, not in fly.toml.

Build #

vlpds is built from source. upstream is a submodule pinned to a main commit (there are no release tags), and patches/*.patch is a git am series on top.

scripts/prepare.sh        # .build = upstream + patches, one commit each
# edit and commit in .build, then:
scripts/save-patches.sh   # export .build's commits back to patches/
cd .build && cargo test --test all

To bump vlpds, check out a newer commit in upstream, run scripts/prepare.sh, and fix any patch that no longer applies. If git am can't 3-way merge (it needs the blobs the patch was made against), apply the series on the old base in .build and git rebase it onto the new one instead.

Each patch is written so it could go upstream: behavior behind a flag or config, defaults matching upstream, and tests in tests/all/.

Patches #

  • 0001 first-party clients. VLPDS_FIRST_PARTY_CLIENTS lists cavu.games' and cavu.page's OAuth client_ids. Their tokens are trusted like a password session for account security, with a sign-in in the last VLPDS_FIRST_PARTY_REAUTH_SECS needed to change how an account signs in. From poasters.club.

  • 0002 passkey related origins. VLPDS_PASSKEY_RELATED_ORIGINS, served at /.well-known/webauthn. From poasters.club; unset here for now.

  • 0003 bare names and email hints. A sign-in identifier with no dot is a handle under the primary domain (chris is chris.cavu.social), on the OAuth page, in login_hint and in createSession. login_hint may be an account's email. No flag: bare names never resolved before.

  • 0004 suggested sign-up handles. VLPDS_SUGGEST_SIGNUP_HANDLE fills in sign-up forms (the OAuth page's and a sign-in provider's) with a random available handle like brave-otter-42, which the person can keep or change before the account is created.

  • 0005 provider= on the authorize URL. /oauth/authorize?…&provider=google skips the sign-in page and goes straight to that sign-in provider, for sites with their own "Sign in with Google" button.

  • 0006 Profile page. /account/profile in the account app edits app.bsky.actor.profile (display name, bio, photo, banner) with standard XRPC calls. UI only.

  • 0007 controlled accounts. VLPDS_CONTROLLED_ACCOUNTS: accounts with controller DIDs instead of a password and an email (game characters, NPCs). A controller creates them (vlpds.account.createControlledAccount, up to VLPDS_CONTROLLED_ACCOUNTS_PER_CONTROLLER, overridable per controller in the console) and makes a character password: an app password with characters (and optional collection scopes) that signs in as those characters with a plain createSession(characterHandle, password), never as the controller and never for account or identity changes. The operator converts existing accounts with vlpds.admin.setAccountControllers (removePassword drops a stopgap password). PLC and deletion codes go to the controller's email. Account app: a Characters page. Blob usage is not pooled with the controller's quota. Details: docs/operations/controlled-accounts.md in the patched tree.

  • 0008 confirm sign-up. VLPDS_CONFIRM_SIGNUP asks "Create a new account?" before an OAuth sign-in leads to one, naming the app (its client_name): a sign-in provider identity no account uses (Create a new account / Use an existing account, back to the sign-in page for the same request), or an email or handle here with no account, as login_hint or typed on the sign-in page (Create a new account, prefilled / Try a different email or handle). prompt=create skips it. It tells the visitor an email has no account here, which createAccount already reveals; off by default upstream.

  • 0009 sign-up methods. VLPDS_SIGNUP_METHODS makes the OAuth sign-up page offer, in order, Continue with Google (each sign-in provider whose signup is open or invite), Create with a passkey (handle and email, no password) and Or use a password (the old form, folded away only where a passkey can be made, so it's the whole page without JavaScript or WebAuthn). Continue with … from this page skips 0008's question for a new identity and just signs in a linked one. The passkey runs every createAccount check first, then mints the DID ahead (a discoverable passkey's user handle is the DID; key held as a reserved key, PLC genesis op kept unsent on the request) and asks the browser for the passkey; the account is created only after the passkey verifies, with it as the only way in (no password, like a provider signup). Cancel, Back or a failed ceremony creates nothing. Off by default upstream; the account app's /account/signup is unchanged.

  • 0010 login_hint on the authorize URL. /oauth/authorize?…&login_hint= sets the hint when the pushed request didn't, checked as PAR's is (0003) and kept on the request. @atproto/oauth-client-browser overwrites login_hint in the PAR, so cavu.page can append it to the authorize URL instead of patching the PAR body.

  • 0011–0012 theming (upstream-first). Operator theming from upstream-patches/theming/ (the copy for submitting upstream), carried here until it lands: a runtime theme (vlpds.admin.putTheme, vlpds admin theme, the console's System > Theme) with a name, logo, favicon, light/dark colors, a font from a fixed list and home/terms/privacy/support links, rendered on every OAuth page (including 0008's "Create a new account?" and 0009's sign-up methods and "Save your passkey", the theme's stylesheet hash joining the CSP next to the sign-up script's), the account app (0006's Profile and 0007's Characters included), /migrate, the landing page and account email. 0011 is the server, docs and tests; 0012 the UI. Our theme is theme/cavu-theme.json with theme/cavu-logo.png and theme/cavu-favicon.png; VLPDS_ADMIN_TOKEN=… theme/apply.sh http://localhost:2583 (through fly proxy) puts it. Details: docs/operations/theming.md in the patched tree.

  • 0013 confirm the email before the account. VLPDS_REQUIRE_EMAIL_CONFIRMATION creates an account only once its email is confirmed. A password or passkey sign-up on the OAuth page (and a Google sign-up whose email Google didn't vouch for, or that the person changed) becomes a pending sign-up after every createAccount check: its DID minted ahead with a reserved key and an unsent PLC genesis op (as 0009's passkey does), its handle and email held, the password hashed; no account, repo, firehose event or PLC op yet. "Check your email" takes the mailed 6-digit code (or the mail's link, in any browser, whose page has one Confirm button) and then the account is created, email confirmed, and the OAuth flow goes on to consent. Resend (a minute apart), Use a different email (keeps the handle), five wrong codes cancel it, 24 hours lapse it (handle, email and key released); a refused mail (spent mail budget) keeps it with "We couldn't send the email right now". Plain com.atproto.server.createAccount sign-ups are refused (migrations with service auth, the admin token, vlpds.admin.createAccount and createControlledAccount still work); the account app's /account/signup uses vlpds.account.startSignup/confirmSignup. Buckets signup-pending-ip (5/h) and signup-mail-address (5/day). Details: docs/operations/email-and-moderation.md#confirming-the-email-before-the-account in the patched tree.

  • 0014 space scopes on app passwords. With --spaces, a scoped app password may carry concrete space: scopes (an authority DID or *, not self; collections listed on a grant that writes). They're the only way an app password, a character password or a remote controller's session reaches space data; unscoped app passwords and password sessions still get none. Without --spaces a space: scope is refused like any unknown scope. Details: the scoped app passwords section of docs/oauth-2fa.md in the patched tree.

  • 0015 app passwords from an app. VLPDS_APP_DIRECTORY (here https://atstore.fyi) adds "Only what the app asks for" to the account page's app password form: search the directory, pick the app, and the password gets the scope from the app's OAuth client metadata. The directory only knows the app's website, so vlpds.account.getAppScopes probes it for client metadata (the listing URL, then ATStore's list of well-known paths on its origin and its api. host), loading each candidate as an OAuth client would. include: permission sets are expanded into concrete scopes there and then, a snapshot, since app passwords still refuse include:. Anything an app password can't carry is shown as left out. ?clientId= covers apps that aren't listed. No app icons: the account page's CSP only allows its own images. Details: the "Starting from an app" section of docs/oauth-2fa.md in the patched tree.

  • 0016 characters are full accounts. Replaces 0007's character passwords: a character gets ordinary app passwords of its own, made by its controller through a session of it (the character's page in the account app), and a game signs it in with createSession(characterHandle, appPassword) like any account. Nothing about a character's sign-in lives on the controller's account any more, so characters keep working when the controller migrates to another PDS. Part of cavu-pds-5on (character sign-in for owners here and elsewhere).

  • 0017 "Acting as" switcher. Top left of the account app, once you have characters: pick yourself or a character and every page acts as that account (through createControlledSession, kept beside your own session in the tab). A character's pages leave out what it can't have (Characters, email, two-factor, passkeys, sign-in methods, password); its Security page is its app passwords. Deleting a character isn't offered yet.

  • 0018 OAuth sign-in as a character. A character's owner signs in on the OAuth page and the app gets the character: a login_hint naming one of the owner's characters goes straight to its consent, one naming the owner skips the chooser, otherwise Continue as lists the owner and its characters. Before the owner signs in a character looks like any account (same page, same error, same Argon2 cost via a throwaway hash for passwordless accounts). The token is the character's and never names the owner; detaching the owner, or its password change, ends the character's app sessions at the next refresh.

  • 0019 owners on other servers. A character's owner hosted elsewhere (e.g. after migrating away) signs in at its own server, with account.cavu.social as an atproto OAuth client (/oauth/owner/client-metadata.json, scope atproto account:email). The sign-in page swaps the password field for Continue at once the typed handle turns out to live elsewhere. Back here the owner picks one of its characters (it has no account here to use itself), and its confirmed email is kept for its characters' mail.

  • 0020 account app for owners on other servers. The account app's sign-in offers Continue at for a handle hosted elsewhere; back here, vlpds.account.createOwnerSession gives a two-hour owner session that can only list the owner's characters and open full sessions of them. The app works as the first character, and the switcher lists only characters.

  • 0021 recovery key at sign-up. VLPDS_SIGNUP_RECOVERY_KEY: after an OAuth sign-up makes the account (password, passkey, Google or the emailed code), before consent, "Protect your identity" offers a recovery key made in the browser. The page's own script (no libraries, checked against @noble/curves in ui/test/rkKeygen.test.ts) makes a secp256k1 key and shows the private key once, with Copy and Download (DID, handle, public key, private key as multikey and hex, the formats goat and PDS MOOver's restore read). Only the did:key is posted; the server puts it first in the DID's rotation keys with one op signed by its own key, allowed once for 30 minutes to the device that made the account, no emailed code. "Not now" changes nothing. Signing in on the account page itself (no app waiting for a redirect) goes to the same "Protect your identity" step first when the account has no key of its own ahead of the server's ("Not now" skips it at sign-in for 30 days in that browser). The Security page warns at the top until there is one, and shows your key with Replace (one op, one emailed code; the old key can still undo it for 72 hours), all in place, no dialogs. Keys there are only made in the browser: pasting or removing your own keys is for tools like PDS MOOver. The key file is the same as at sign-up. No "save to password manager": on this origin a saved key would be offered as the account password on the sign-in form. Details: "A recovery key at sign-up" in docs/keys-security.md in the patched tree.

  • 0022 Spaces rows from the alpha patches. The first deploy on upstream's Spaces (vlpds dba483f, after 0015/0017/0023 were dropped) reads what those patches stored. Accounts' #atproto_kem key was kem_key: {wrapped, pubkey, published}, upstream's is wrapped_kem_key/kem_pubkey (same wrap and multikey): the startup KEM backfill moves it over instead of making a new key (which would change every syncer's MAC secret), and publishes one the patches hadn't. sD rows' nextAt reads as retryAt. The binary space rows, keys and sS policies were already the same. Drop it once every account's kem_key has moved (the backfill logs "kem key kept from the Spaces alpha patches").

  • 0023 Spaces, the November 12 alpha. Brings Spaces to the reference's November 12 alpha (0.0.0-spaces-alpha-20261112204144, bluesky-social/atproto d4def6e9f): MACs as RFC 9421 HTTP signatures (Accept-Signature) over an HPKE-exported secret, getSpaceCredential renamed authorizeSpaceSync and carrying syncer registrations (notify, confirmed with confirmRegistration; registerNotify is gone), notifySpaceUpdate to syncers (repoWrite, repoRemoved, spaceDeleted, registrationExpired), listWriters, putMembers/removeMembers, checkAccess, and the error and field renames. Stored data: new sG/sY rows, a removed flag on sW (so no rollback past it once a writer is removed); the Nov 5 sN/sD rows are dropped and syncers re-register. It breaks the Nov 5 wire, so it deploys with the cavu apps' move to the Nov 12 SDK. Upstream PR branch: spaces-november-12 on chris-pardy/vlpds, also on its main.

0003–0021 are written for upstream: each is one feature with its own tests, off by default where behavior changes. The upstream PR branch for theming (0011–0012) is theming on chris-pardy/vlpds, on vlpds main without the cavu patches. The Spaces alphas through November 5 (carried here as patches until vlpds dba483f) are upstream now; November 12 is 0023. Sign-in with Google itself is upstream's sign-in providers, so poasters.club's linked sign-ins patches aren't carried here.

prompt=create (open the sign-up form) is already upstream.

Deploy #

scripts/deploy.sh
fly logs --app cavu-pds
fly proxy 2583 --app cavu-pds   # console: http://localhost:2583/admin (VLPDS_ADMIN_TOKEN)

Caddy listens on 8080 behind Fly's edge and returns 404 for the operator paths (/admin, /xrpc/vlpds.admin.*, /metrics, /internal/*). vlpds listens on [::]:2583, reachable only over the private network.

Spaces (VLPDS_SPACES, AT Protocol permissioned data) is on: cavu.page's reading groups and other cavu features need it. It's an alpha that changes weekly, so bump upstream often, and once space data exists never roll back to a vlpds build from before Spaces. Checks: vlpds admin check-space <did> <space> and the vlpds_space_* metrics (upstream/docs/spaces/operating.md).

Tiny profile: one node, one shard, a 60 s lease, on a shared-cpu-2x with 2 GB. Never run two machines. Everything durable is in the Tigris bucket cavu-pds under the prefix pds.

Storage limits #

Sign-up is open, so the per-account storage quota (VLPDS_BLOB_QUOTA_GB, 2 GB) is what stops it from being free file hosting. Raise it per publisher in the console. Single blobs can be up to 1 GiB (VLPDS_MAX_BLOB_MB).