Skip to content

luismrfonseca/authentication-module-nestjs

Repository files navigation

NestJS Authentication Module

Overview

A production-ready, secure authentication system built with NestJS, TypeORM, and PostgreSQL. Features include JWT authentication, refresh token rotation, session management, 2FA (TOTP), Google OAuth, and security hardening.

Features

  • Secure Authentication: Bcrypt password hashing and JWT-based access control.
  • Token Management: Short-lived Access Tokens and secure, rotating Refresh Tokens.
  • Session Tracking: Monitor and revoke active user sessions.
  • User Features: Self-service Forgot/Reset Password flows (User-friendly email mock).
  • Two-Factor Authentication (2FA): TOTP integration (Google Authenticator) with QR code generation.
  • Federated Login: Google OAuth 2.0 integration.
  • Security Hardening:
    • Rate Limiting (Throttling) against brute-force attacks.
    • Helmet for secure HTTP headers.
    • Global Input Validation.

Tech Stack

  • Framework: NestJS
  • Database: PostgreSQL (via Docker)
  • ORM: TypeORM
  • Caching: Redis (via Docker)
  • Documentation: Swagger (OpenAPI)

Getting Started

Prerequisites

  • Node.js (v16+)
  • Docker & Docker Compose

Installation

  1. Clone the repository.
  2. Install dependencies:
    npm install
  3. Start Infrastructure (Postgres & Redis):
    docker-compose up -d
  4. Start the Application:
    npm run start

Documentation

  • API Docs (Swagger): Visit http://localhost:3000/api
  • Postman Collection: Import postman_collection.json for testing.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published