Skip to content

โœจ Open-source repo for contributing to the Strict Authentication Service โ€“ built with Node.js, Prisma, and production-grade security principles. ๐Ÿ›ก๏ธ Enforce session expiry, device lock, rate limiting, and auto-logout policies. Help extend it with token rotation, audit trails, or distributed lock mechanisms.

Notifications You must be signed in to change notification settings

YatharthKumarSaxena/Strict-Auth-Service_OpenSource

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

2 Commits
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ Strict Auth Service โ€“ Open Contribution Repo

Hey there! Iโ€™m Yatharth Kumar Saxena, and over the last 30 days, I hand-crafted a zero-compromise authentication system for modern production use cases โ€” featuring secure login, strict device binding, rate limiters, and complete audit logging. After 296 commits and 4500+ lines of code, I'm opening it up for the world. Letโ€™s build together.


๐Ÿ“‘ Table of Contents


๐Ÿ“– Introduction

This is the open-source counterpart to my private Strict Authentication Service. While the original repository was focused on internal implementation and experimentation, this one is about collaboration, innovation, and collective engineering.

โ€œSystem fails. Design survives.โ€ โ€” YKS


๐Ÿ” Core Highlights

This isnโ€™t just login/signup โ€” itโ€™s a full-blown auth engine with enterprise readiness.

  • ๐Ÿ”‘ JWT-based stateless sessions (access & refresh)
  • ๐Ÿ” Admin-only protected routes (with ADMxxxxx prefix)
  • ๐Ÿ“ต Strict device policy: Only one device per user, one user per device
  • โฑ๏ธ Request tracking (requestCount, lastRequestAt) per device
  • ๐Ÿ” Auto-expiry & re-allocation of device slots if inactive
  • ๐Ÿ”„ Full logout (DB + cookies + logs)
  • ๐Ÿงพ Structured audit logging (with SYSTEM, USER, ADMIN)
  • ๐Ÿšซ Rate limiting for login/signup/change-password
  • ๐Ÿ“œ Cookie & header-based token response (double fallback)
  • โš ๏ธ Dynamic field validation (regex + length-based)

๐Ÿงฉ Current Architecture

Design Principles:
โ˜‘๏ธ SOLID ยท โ˜‘๏ธ DRY ยท โ˜‘๏ธ KISS ยท โ˜‘๏ธ YAGNI

Patterns in Play:
๐Ÿงฑ Singleton ยท ๐Ÿญ Factory ยท ๐Ÿงฌ Strategy ยท ๐Ÿ”— Chain of Responsibility

This system is modular, testable, and microservice-ready โ€” designed with scalability and readability in mind.

๐Ÿง  Session Management Note:

  • A user can only stay logged in from one device at a time.
  • If they log in from another device, the previous session is invalidated.
  • Each device is uniquely tied to only one user at any point in time.

๐Ÿ—‚๏ธ Folder Structure

Total files: 60+ (excluding node_modules)

๐Ÿ“ Folder ๐Ÿท๏ธ Description
configs/ โœ… Application configs (env, auth, cookie, token, HTTP codes, regex, etc.)
controllers/ ๐ŸŽฎ Express route handlers โ€” directly handle incoming HTTP requests
middlewares/ ๐Ÿ›ก๏ธ Role guards, device parsers, rate-limiters, access control checks
rate-limiters/ ๐Ÿ“Š Route-based in-memory limiter logic and dynamic Prisma-based limiter service
services/ ๐Ÿง  Core business logic โ€” login, registration, ID generation, validation, logout
utils/ ๐Ÿงฐ Helper utilities โ€” logs, token, cookie, validators, device utils, etc.
clients/ ๐Ÿ›ข๏ธ Prisma clients โ€” handles public.prisma and private.prisma connections
routers/ ๐ŸŒ Route layer โ€” Express router-level mappings for all APIs
cron-jobs/ โฑ๏ธ Time-based background jobs (e.g., cleanup, expiry, stale sessions)
internal/ ๐Ÿ›ฐ๏ธ Internal API call handlers (service-to-service calls if extended later)
README.md ๐Ÿงญ You are here โ€” full repo structure, purpose, and setup instructions

Each module has its own README.md inside the folder for context and usage.


๐Ÿง‘โ€๐Ÿ’ป Open Contribution Areas

Hereโ€™s what weโ€™re actively looking to build or improve:

1. ๐Ÿ“ฒ OTP Verification Workflow

  • After sign-up, users remain isActive: false until OTP verification.
  • Implement 6-digit OTP with a 30s expiry & retry logic.
  • Ideal: Plug this as a strategy module or plug-in service.

2. ๐Ÿ”‘ Forgot Password API

  • One-time token/email flow.
  • TTL-based token expiry or OTP-based verification.
  • Ensure rate limit + log tracking.

3. ๐Ÿ“ˆ Advanced Logging Integration

  • Plug in winston or pino.
  • Add traceIDs, log rotation, and transport options.

4. โšก Performance Boosting

  • In-memory cache for device/user lookups.
  • Graceful shutdown handling.
  • Add Prometheus metrics integration (optional).

5. ๐Ÿงผ Bug Fixes, Cleanup, Refactors

  • Strict validator improvements
  • Mongoose index improvements (e.g., TTL)
  • Controller decoupling or route modularization

๐Ÿ›‘ Must follow design principles & architecture style.


๐Ÿค How to Contribute

  1. Fork โžœ clone โžœ git checkout -b feature/your-feature
  2. Run npm install โžœ rename .env.sample โžœ .env
  3. Make your changes with clear commit messages
  4. Open a PR โ€” mention issue number and design rationale
  5. Donโ€™t forget unit tests for new logic

โš™๏ธ Tech Stack & Principles

Layer Tech
๐Ÿš€ Backend Node.js + Express.js
๐Ÿง  DB PostgreSQL (Prisma ORM)
๐Ÿ” Auth JWT (stateless), cookie fallback
๐Ÿ“ž Logs Console + audit logs (JSON-ready)
โฑ๏ธ Limiting User + Device rate limiters
โ™ป๏ธ Cleanup Cron jobs (expired logs, stale users)

๐ŸŽฏ Final Takeaway

This project started as my personal dive into enterprise-grade authentication systems. Now, itโ€™s yours too.
Whether itโ€™s your first PR or a production-grade refactor โ€” welcome aboard.

Letโ€™s build a fortress of security โ€” the clean way. ๐Ÿ”

โ€” Yatharth Kumar Saxena

About

โœจ Open-source repo for contributing to the Strict Authentication Service โ€“ built with Node.js, Prisma, and production-grade security principles. ๐Ÿ›ก๏ธ Enforce session expiry, device lock, rate limiting, and auto-logout policies. Help extend it with token rotation, audit trails, or distributed lock mechanisms.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published