Skip to content

feat: secure wallet endpoints with JWT authentication - #165

Open
davedumto wants to merge 2 commits into
Harmonia-Development:mainfrom
davedumto:feat/secure-wallet-endpoints-jwt
Open

feat: secure wallet endpoints with JWT authentication#165
davedumto wants to merge 2 commits into
Harmonia-Development:mainfrom
davedumto:feat/secure-wallet-endpoints-jwt

Conversation

@davedumto

Copy link
Copy Markdown
Contributor

closes #136

Summary

Apply JWT authentication to the wallet endpoints in services/stellar-wallet, as specified in the issue.

Changes

  • src/index.ts: Mount jwtMiddleware on /wallet/* so every wallet endpoint requires a valid JWT.
  • src/routes/wallet.ts: Add jwtMiddleware to POST /wallet/create explicitly (matches the per-route pattern already used by /wallet/send and /wallet/transactions/:user_id) and reject mismatched JWT vs. body user_id with HTTP 403 { error: 'Forbidden' }. Missing/invalid tokens continue to return HTTP 401 from jwtMiddleware.
  • tests/routes/wallet.test.ts: Add tests for the new POST /wallet/create access control:
    • missing/invalid JWT -> 401
    • valid JWT with mismatched user_id -> 403
    • valid JWT with matching user_id -> 201 (existing case)
      The existing 400/500 tests are updated to set AUTH_USER_ID to match the request body so they still exercise the post-auth branches.

Verification

Locally in services/stellar-wallet:

  • npx tsc --noEmit clean
  • npm run lint clean
  • npx prettier --check . clean
  • NODE_ENV=test npx jest --no-coverage -> 107/107 passing (27/27 in wallet.test.ts)

CI is the source of truth on this repo.

Notes

  • This branch is named feat/secure-wallet-endpoints-jwt because the originally-specified feat/secure-wallet-endpoints branch name already exists on my fork from a prior closed PR (Feat/secure wallet endpoints #156). The commit message is the lowercase feat: style required by the issue.
  • JWT scheme reuses the existing jwtMiddleware from src/auth/jwt.ts (added in implement jwt authentication #159) - no new auth framework introduced.

davedumto and others added 2 commits May 30, 2026 12:28
Apply jwtMiddleware to all /wallet/* routes via index.ts and add it
explicitly to POST /wallet/create. Reject mismatched JWT/body user_id
with HTTP 403 on /wallet/create. Add tests covering missing JWT (401),
mismatched user_id (403), and the existing happy-path cases now that
JWT identity is asserted.
stellar contract build requires overflow-checks to be enabled in the release
profile to prevent silent integer overflow in Soroban contracts. Added the
missing [profile.release] section to kyc-kyb-contract/Cargo.toml.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

Secure Wallet Endpoints with JWT Authentication [wallet - service]

1 participant