445 446 jwt auth course management#565
Merged
Hexstar-labs merged 3 commits intoMay 29, 2026
Merged
Conversation
- Add TokenBlacklist entity for persistent token revocation - Create TokenBlacklistService with cache-backed lookup - Update JwtStrategy to check blacklist on token validation - Enhance logout endpoint to blacklist access tokens - Add token expiration cleanup capability - Supports both cache and database for fast and persistent lookups
|
@OZILSOLAR Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
[Backend] JWT Authentication & Course Management API
Overview
This PR implements JWT-based authentication with refresh tokens and a complete course management REST API with role-based access control. Both features are production-ready with comprehensive error handling, validation, and security measures.
Issues Resolved
Closes #445
Closes #446
Changes Implemented
Issue #445: JWT Authentication Middleware
JWT Strategy & Token Management
src/auth/jwt.strategy.ts): Passport JWT strategy with Bearer token extraction and token blacklist validationsrc/auth/auth.service.ts):issueTokenPair()method for atomic token generationRefresh Token Rotation
refresh()method: revokes old token before issuing new pairAuthentication Guards & Authorization
src/auth/jwt-auth.guard.ts): Protects routes requiring authenticationsrc/auth/roles.guard.ts): Enforces role-based access controlsrc/auth/roles.decorator.ts): Declarative role specification on routesToken Blacklisting System
src/auth/token-blacklist.service.ts):blacklistToken(): Adds tokens to cache (Redis) and database for persistenceisTokenBlacklisted(): Fast lookup with cache-first strategycleanupExpiredTokens(): Scheduled cleanup of expired entriesRate Limiting for Auth Endpoints
@Throttle()decorators on all auth endpoints (register, login, refresh, etc.)src/rate-limit/user-rate-limit.service.ts):Additional Auth Features
Issue #446: Course Management API
REST Endpoints
All endpoints follow RESTful conventions with proper HTTP methods and status codes:
GET /v1/courses - List all published courses
page(default: 1),limit(default: 20)search(title/description ILIKE),level(beginner/intermediate/advanced)GET /v1/courses/:id - Retrieve single course
POST /v1/courses - Create new course
CreateCourseDtoPATCH /v1/courses/:id - Update course
UpdateCourseDtoDELETE /v1/courses/:id - Delete course
isDeleted = true)Course Management Features
Pagination & Filtering (
src/courses/dto/course-query.dto.ts):Input Validation (
src/courses/dto/):CreateCourseDto: title (min 3 chars), description (min 10 chars), level, duration, KYC requirementUpdateCourseDto: all fields optional for partial updatesStripHtmlSanitizerError Handling:
Performance Optimizations:
Course Scheduling (bonus):
POST /v1/courses/:id/schedule- Schedule course for future publicationPOST /v1/courses/:id/publish- Immediately publish courseData Models
src/courses/course.entity.ts):Additional Changes
Module Imports Fix
src/app.module.ts:RemindersModuleCertificatesModulePayoutsModuleTechnical Details
Security Measures
Database Schema
token_blacklisttable: stores revoked tokens with expirationrefresh_tokenstable: stores refresh token hashes with revocation statuscoursestable: enhanced with status enum and scheduling fieldsCaching Strategy
Testing Considerations
API Documentation
GET /api/docsDeployment Notes
Breaking Changes
None. All changes are additive and backward compatible.
Migration Steps
Verification
Copy this PR message and paste it when creating the pull request on
GitHub. The message covers: