FortifyAuth is a high-integrity, production-grade identity platform and authentication service. It transforms a documentation-heavy prototype into a fully functional, secure, and modular backend engine designed for high availability and resilient security.
- 🔐 Advanced Cryptography: Password hashing using Argon2id (OWASP-recommended) with memory-hard and parallel-processing parameters.
- 🔄 Dual-Tier Token Engine: Stateless JWT Access Tokens paired with opaque, database-backed Refresh Tokens.
- 🚨 Breach Detection: Automatic Refresh Token Rotation with a built-in "nuclear option" that invalidates all user sessions upon detection of token reuse/replay attacks.
- 🛡️ Multi-Layered Security:
- RBAC: Role-Based Access Control (USER, ADMIN, MODERATOR).
- Rate Limiting: Granular, in-memory sliding window protection for critical authentication paths.
- Sanitization: Global input sterilization using DOMPurify to neutralize XSS vectors.
- Hardened Headers: Full Helmet.js integration with custom CSP and HSTS policies.
- 📧 Transactional Mail: Integrated flows for email verification and password recovery via SMTP (Resend/Nodemailer).
- 📋 Audit & Observability: Comprehensive logging of security events, login history, and administrative changes using Winston.
- 📖 Interactive Documentation: Live Swagger/OpenAPI explorer and a built-in React-based technical blueprint UI.
- Runtime: Node.js (ES Modules)
- Framework: Express.js
- Language: TypeScript
- ORM: Prisma
- Database: PostgreSQL
- Validation: Zod
- Security: Argon2, JsonWebToken, Helmet, DOMPurify
- Documentation: Swagger UI, Vite (Frontend UI)
- Deployment: Render (Native Node.js Runtime)
src/
├── config/ # Environment and service configurations
├── controllers/ # Request handlers (API interface)
├── services/ # Core business logic & security orchestration
├── repositories/ # Data access layer (Prisma interactions)
├── middlewares/ # Security, Auth, Rate-limiting, and Error filters
├── routes/ # API endpoint definitions (versioned)
├── validators/ # Zod schema definitions for input validation
├── utils/ # Hashing, logging, and shared utility functions
├── docs/ # Swagger config and technical specifications
├── app.ts # Express application setup
└── server.ts # Server entry point and DB connection logic
- Node.js (v18+)
- PostgreSQL instance
-
Clone the repository:
git clone https://github.com/your-username/fortify-auth.git cd fortify-auth -
Install dependencies:
npm install
-
Configure Environment: Create a
.envfile based on.env.example:cp .env.example .env
Required fields:
DATABASE_URL,JWT_ACCESS_SECRET,JWT_REFRESH_SECRET,SMTP_HOST,SMTP_PASS. -
Initialize Database:
npx prisma migrate dev
-
Run in Development:
# Start backend (auto-reload) npm run server:dev # Start frontend (vite dev) npm run dev
The project uses a dual build pipeline:
- Frontend: Vite compiles assets into
dist/client. - Backend: esbuild bundles the server into
dist/server.js.
npm run build- Create a Web Service on Render.
- Connect your repository.
- Set Build Command:
npm install && npm run build - Set Start Command:
npm start - Add your Environment Variables in the Render dashboard.
The project includes an integration test suite using Jest and Supertest with Prisma mocking.
npm testOnce the server is running, you can access the interactive documentation at:
- Technical Blueprints (React UI):
http://localhost:3000/ - Swagger/OpenAPI Explorer:
http://localhost:3000/api/docs
Distributed under the MIT License. See LICENSE for more information.