Skip to content

Add email magic link login#26

Open
2chanhaeng wants to merge 4 commits into
fedify-dev:mainfrom
2chanhaeng:main
Open

Add email magic link login#26
2chanhaeng wants to merge 4 commits into
fedify-dev:mainfrom
2chanhaeng:main

Conversation

@2chanhaeng

Copy link
Copy Markdown
Member

Resolves #23. A user requests a login link by email.

Model

  • login_tokens: accountId, tokenHash (unique, lookup key), codeHash, created, expires (default 15 minutes), consumed.
  • sessions: accountId, tokenHash (unique), created, expires (default 1 month).

GraphQL API

  • loginByEmail(email: Email!, verifyUrl: String): SendMail — emails a login token/code; verifyUrl. Always returns token to prevent account enumeration — deviates from the proposed LoginSuccess | AccountNotFoundError union for the same reason.
  • completeLoginChallenge(token: UUID!, code: String!): Sessionnull on a bad/expired/consumed token or wrong code; accessToken exposed only here.
  • revokeSession(session: UUID!): LogoutSuccess — always revoke: true.
  • viewer: Account — the authenticated account, or null.

Implementation

  • New tables login_tokens and sessions with migration email_auth; secrets stored as SHA-256 digests only, constant-time code comparison.
  • Mail via Upyo (@upyo/core/smtp/mock); falls back to MockTransport with a warning when no mailer is configured.
  • CLI: --smtp-url/-s and --seed options.
  • auth.test.ts covers the full flow end to end against PGlite.

Out of scope (per issue): frontend/BFF, sign-up, PassKey, rate limiting, UI.

AI Disclosure

Developed with AI agents from Claude Code (claude-opus-4-8, claude-fable-5) and Codex (gpt-5-6-sol), per AI_POLICY.md; commits carry Assisted-by: trailers. All AI-assisted code was manually reviewed and verified locally. I requested questions, reviews, translations, etc. from the AI agent, and prohibited it from directly writing or modifying source code. Code modifications were made directly by a human.

Assisted-by: Claude Code:claude-opus-4-8
Assisted-by: Claude Code:claude-fable-5
Assisted-by: Codex:gpt-5-6-sol
Assisted-by: Claude Code:claude-opus-4-8
Assisted-by: Claude Code:claude-fable-5
Assisted-by: Codex:gpt-5-6-sol
Assisted-by: Claude Code:claude-opus-4-8
Assisted-by: Claude Code:claude-fable-5
Assisted-by: Codex:gpt-5-6-sol
@2chanhaeng
2chanhaeng requested review from dahlia, dodok8 and sij411 July 16, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Email Magic Link Login

1 participant