feat: add JWT auth guard with Stellar signature verification (Closes #6) - #21
Merged
Merged
Conversation
…oopfinance#6) Create auth module with Stellar wallet-based authentication: Auth flow: 1. GET /api/auth/nonce?address=G... — returns challenge message 2. Client signs message with Stellar private key 3. POST /api/auth/login — verifies signature, issues JWT 4. Subsequent write requests include Authorization: Bearer <jwt> Files created (src/modules/auth/): - auth.service.ts — nonce generation, signature verification via Stellar Keypair, JWT issuance, in-memory nonce store with TTL - auth.controller.ts — GET /api/auth/nonce, POST /api/auth/login - jwt.strategy.ts — Passport JWT strategy (Bearer token extraction) - jwt-auth.guard.ts — NestJS guard wrapping Passport auth - auth.module.ts — JwtModule + PassportModule async config Write endpoints now protected with @UseGuards(JwtAuthGuard): - POST /api/groups - POST /api/loans - PATCH /api/loans/:id/status - POST /api/governance/proposals - POST /api/groups/:groupId/members Read endpoints (GET) remain public. Swagger docs updated with @ApiBearerAuth on protected routes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/claim
Summary
Add JWT authentication guard with Stellar wallet-based signature verification. Write endpoints are now protected; read endpoints remain public.
Closes #6
Authentication Flow
Files Created
src/modules/auth/auth.service.tsKeypair.verify()signature check, JWT issuance, in-memory nonce store (5min TTL, auto-purge)auth.controller.tsGET /api/auth/nonce,POST /api/auth/loginjwt.strategy.tsjwt-auth.guard.tsAuthGuard('jwt')wrapperauth.module.tsJwtModule.registerAsync+PassportModuleProtected Endpoints
POST/api/groupsPOST/api/loansPATCH/api/loans/:id/statusPOST/api/governance/proposalsPOST/api/groups/:groupId/membersAll
GETendpoints remain publicly accessible.Design Decisions
JWT_EXPIRES_INenv var (default24h).JWT_SECRETenv var.@ApiBearerAuth(): Added to all protected routes for Swagger documentation.Verification
nest build: Auth module files compile with zero errorsstellar.service.tsandgroups.service.tsare unrelated to this PR