Skip to content

Backend: Add wallet-signature-based auth for campaign creation/management #302

@CelestinaBeing

Description

@CelestinaBeing

Summary

Write operations (POST/PUT/DELETE campaigns) are protected by API key auth, but there is no way for a wallet-owning campaign creator to authenticate using their Stellar key pair. On mainnet, campaign creation should be permissioned by wallet signature — not a shared API key — so only the campaign operator (who controls the admin key for the linked contract) can manage their campaign.

Problem

Current auth model:

  • API key is a shared secret, not tied to any individual identity
  • No way to verify that the caller owns the admin key of the referenced campaign contract
  • A leaked API key grants full write access to all campaigns

Acceptance Criteria

  • Add a challenge-response signature auth flow:
    1. GET /api/v1/auth/challenge returns a time-limited nonce (60s TTL) for a given wallet address
    2. Client signs the nonce with Freighter using the wallet's keypair
    3. POST /api/v1/auth/verify validates the signature against the public key, returns a short-lived JWT (15 min) or session token
  • Protect POST/PUT/DELETE campaign routes with either API key OR wallet JWT
  • Store challenge nonces in Redis (or in-memory with TTL) — not in SQLite
  • Add wallet address to audit log entries when wallet auth is used
  • Add unit tests for challenge generation, signature verification (using @stellar/stellar-sdk), and token issuance
  • Document the auth flow in backend/openapi.yaml and backend/README.md

References

  • backend/src/middleware/apiKeyAuth.js
  • backend/src/index.js — route registration
  • frontend/src/stellar.js — wallet signing

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions