Skip to content

feat(backend): implement SIWS message verification (#108)#272

Open
omonxooo-commits wants to merge 1 commit intoDXmakers:mainfrom
omonxooo-commits:feat/siws-backend
Open

feat(backend): implement SIWS message verification (#108)#272
omonxooo-commits wants to merge 1 commit intoDXmakers:mainfrom
omonxooo-commits:feat/siws-backend

Conversation

@omonxooo-commits
Copy link
Copy Markdown

Summary

Closes #108

Implements Sign-In With Stellar (SIWS) message verification on the backend.

Changes

  • services/siws.rs — nonce generation, canonical SIWS message builder, Stellar strkey → ed25519 pubkey decode, verify_strict signature check
  • routes/auth.rsPOST /api/v1/auth/nonce and POST /api/v1/auth/verify with one-time nonce consumption (replay-safe)
  • db.rsNonceStore (Arc<Mutex<HashMap>>) added to AppState
  • routes/mod.rs/auth router registered under /api/v1
  • Cargo.toml — added rand, hex, base32 deps
  • .env.example — added APP_DOMAIN and SESSION_SECRET

Auth flow

POST /api/v1/auth/nonce  { address }              → { nonce, issued_at }
POST /api/v1/auth/verify { address, signature }   → { token }

Security

  • Nonces consumed on first use — no replay
  • verify_strict rejects malleable signatures
  • Domain bound in signed message — prevents cross-domain phishing

- Add services/siws.rs: nonce generation, canonical message builder,
  Stellar strkey decode, ed25519 signature verification
- Add routes/auth.rs: POST /api/v1/auth/nonce and /verify endpoints
  with one-time nonce consumption (replay-safe)
- Extend AppState with in-memory NonceStore (Arc<Mutex<HashMap>>)
- Register /auth router in api_router
- Add APP_DOMAIN and SESSION_SECRET to .env.example
- Add rand, hex, base32 dependencies to Cargo.toml
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.

Backend: Implement SIWS message verification

1 participant