feat(auth-service): add /_internal/account/create for community DIDs#6
Merged
Conversation
Adds a headless, no-OTP account-creation endpoint so service callers can provision community DIDs — accounts that represent a community or group rather than a single human, and so have no inbox to receive an OTP. The endpoint mirrors the existing /_internal/otp/* and /_internal/recovery/* handlers (same x-api-key auth, allowedOrigins, and rate limiting) and reuses handleSignup() for the invite-mint + createAccount path. It is gated behind a new can_create_directly permission — NOT can_signup — because skipping the email-OTP step is a stronger capability than ordinary signup, so it is off by default. A v11 migration adds the can_create_directly column to api_clients (default 0), and create-api-client.mjs gains a --can-create-directly flag. The handle is validated identically to the OAuth signup flow via validateLocalPart (5-20 chars, single-label, ATProto-spec-valid); the caller- supplied email is treated as opaque since no mail is sent for these accounts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a headless, no-OTP account-creation endpoint (
POST /_internal/account/create) for service callers that provision accounts server-to-server (e.g. community DIDs). Gated by a new per-clientcan_create_directlypermission, off by default.scripts/create-api-client.mjsgains--can-create-directlyto grant it.This supersedes the original
feat/community-didsbranch, which was cut from an oldmainand would have reverted ~1,740 lines of already-merged work (Mastodon OAuth, profile import, thepdsadmin/CLI). This branch is that single feature commit rebased onto currentmain— net diff is 369 insertions / 6 deletions across 6 files, touching no merged work.Reviewer note — migration ordering (load-bearing): on the old branch the
can_create_directlycolumn was migration v11, which now collides with main's Mastodon-tables v11 + profile v12. It has been moved to v13 and made idempotent (guards onPRAGMA table_infobefore theALTER), matching the existing v12 Mastodon backstop. This is required: production DBs that already ran the old v11 (the column is already present on the live self.surf volume) would otherwise crash startup with "duplicate column name".Verification
pnpm buildclean (tsc --build all packages)pnpm test— 1039 passed (73 files), incl. migration + new headless-account suites(Pre-existing on
main, not addressed here: arequire()-import lint error indb-mastodon.test.tsand 5 prettier warnings — flagging so they're not attributed to this PR.)🤖 Generated with Claude Code