Skip to content

yeasin-riyad/NodeJs-Security-2026

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

🔐 Node.js Security Project (Production Ready Backend)

A complete, real-world backend focused on securing a Node.js application for production and deployment.
This project demonstrates how to build a robust authentication system and protect it against common vulnerabilities.


🚀 Live Backend

🌐 API Base URL:
https://your-backend.onrender.com

📡 Health Check:
https://your-backend.onrender.com/api/health


📌 Overview

This project is a hands-on implementation of modern backend security practices using:

  • Node.js
  • Express.js
  • MongoDB
  • TypeScript

The goal is to go beyond basic authentication and build a secure, production-ready backend.


🛡️ Security Features Implemented

🔐 Authentication & Authorization

  • JWT-based authentication (Access + Refresh Token)
  • Secure cookie handling (httpOnly, secure, sameSite)
  • Token rotation & refresh flow
  • Role-Based Access Control (RBAC)

🍪 Cookie Security

  • HTTP-only cookies (prevents XSS access)
  • Secure cookies (HTTPS only)
  • SameSite protection for cross-site requests

🧾 CSRF Protection

  • CSRF token generation
  • Double Submit Cookie Pattern
  • Custom header validation (x-csrf-token)

🌍 CORS Protection

  • Allowlist-based origin control
  • Credentials enabled for secure cookie sharing
  • Prevents unauthorized cross-origin access

🚦 Rate Limiting

  • Global API rate limiting
  • Strict limits on authentication endpoints
  • Prevents brute-force attacks

🧪 Input Validation

  • Schema validation using Zod
  • Sanitization of user inputs
  • Prevents malformed or malicious data

🛑 NoSQL Injection Protection

  • Input filtering and validation
  • Safe query handling in MongoDB

🧱 Express Security Best Practices

  • Security headers using Helmet
  • Disable x-powered-by
  • Structured error handling

🔑 Environment Security

  • Sensitive data stored in .env
  • No secrets exposed in codebase
  • Configurable production environment

About

Secure Node.js API with JWT, cookies, CSRF protection, rate limiting, RBAC, and NoSQL injection defense.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors