Skip to content

feat(user_worker): SIWE auth handlers (unit 2)#5

Merged
kingwingfly-claude merged 1 commit into
devfrom
feat/user-system-u2-auth
Jul 5, 2026
Merged

feat(user_worker): SIWE auth handlers (unit 2)#5
kingwingfly-claude merged 1 commit into
devfrom
feat/user-system-u2-auth

Conversation

@kingwingfly-claude

Copy link
Copy Markdown
Collaborator

Implements user_worker/src/auth.rs: nonce issuance (KV, TTL, single-use), full SIWE verify chain (domain/version/chain-id, issued-at freshness, expiration, nonce, ecrecover match), D1 user upsert + ban check, DO free-grant init, HS256 ue_session cookie; logout and /me.

Runtime auth depends on unit 1's siwe.rs (PR #2) landing — compile gate + tests were the local verification.

Part of the SIWE user-system batch (scaffold 69457f8).

🤖 Generated with Claude Code

Unit 2 of the SIWE user system. Replaces the auth.rs stub:

- nonce: uuid v4 stored in NONCES KV under "nonce:{nonce}" with
  NONCE_TTL_SECS, returned as Json(NonceResp).
- verify: parses the EIP-4361 message (400 on parse error); checks
  domain, version "1", chain id (401); issued-at freshness within
  SIWE_MAX_AGE_SECS and optional expiration-time (401); single-use
  nonce via KV get+delete (401 on unknown/expired); recovered EIP-191
  signer must match the claimed address (401); upserts the user row in
  D1 and rejects banned accounts (403); do_init's the UserAccount DO;
  signs the ue_session cookie and returns the checksummed address.
- logout: clears the session cookie.
- me: verified session -> DO /status as Json(StatusResp), else 401.

All failures return Json(ApiError); internal errors are logged with
console_error and mapped to 500, matching gateway_worker idioms.

Note: siwe.rs is a stub implemented by a parallel unit, so runtime auth
cannot be exercised locally yet — cargo check + existing unit tests are
the local verification gate.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@kingwingfly-claude kingwingfly-claude merged commit fde7be3 into dev Jul 5, 2026
@kingwingfly-claude kingwingfly-claude deleted the feat/user-system-u2-auth branch July 5, 2026 05:36
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.

1 participant