Skip to content

Add email magic link login#26

Merged
dahlia merged 9 commits into
fedify-dev:mainfrom
2chanhaeng:main
Jul 22, 2026
Merged

Add email magic link login#26
dahlia merged 9 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
Comment thread packages/graphql/src/index.ts

@sij411 sij411 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's 6 char code, adding rate-limiting might be good?

Comment thread packages/models/drizzle/20260716000333_email_auth/migration.sql
@2chanhaeng

Copy link
Copy Markdown
Member Author

Since it's 6 char code, adding rate-limiting might be good?

Many sites use 4 to 6 characters (based on my experience).

Co-authored-by: Hong Minhee <hong@minhee.org>

@dodok8 dodok8 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to integrate with solid-relay to get some work done, but there’s no command to actually create the schema SDL file, so I can’t integrate it. If a query has been created, I hope this PR will include a command to generate the SDL file from the query.

@dahlia

dahlia commented Jul 22, 2026

Copy link
Copy Markdown
Member

@dodok8 Okay, but we will work on it from a separate pull request!

2chanhaeng and others added 3 commits July 22, 2026 16:21
Co-authored-by: Hong Minhee <hong@minhee.org>
Co-authored-by: Hong Minhee <hong@minhee.org>
Co-authored-by: Hong Minhee <hong@minhee.org>
@dahlia
dahlia enabled auto-merge July 22, 2026 07:23
@dahlia
dahlia merged commit ade4953 into fedify-dev:main Jul 22, 2026
4 checks passed
@github-project-automation github-project-automation Bot moved this from In progress to Done in NLnet NGI0 Commons Fund (2026) Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

Add Email Magic Link Login

4 participants