Fullstack Authorization using Nest.js (Node Framework), Postgresql (DB), Redis (Sessions), Prisma (ORM), Docker Compose, Oauth2 (Google | Github), 2FA (Email Verification), Google Captcha. Frontend - Next.js, Tailwind, ShadCN, Zod, React-hook-form.
User Authentication: Register and log in with email and password or via OAuth2 providers (Google, GitHub).
Two-Factor Authentication (2FA): Optional 2FA via email-based one-time codes.
Email Verification: Mandatory email verification upon registration.
Password Recovery: Secure password reset functionality via email.
Google reCAPTCHA: Protects registration and login forms from bots.
User Profile Management: Update name, email, and 2FA settings.
Session Management: Secure session handling with Redis and logout functionality.
Dockerized Deployment: Backend and frontend are containerized with Docker and orchestrated using Docker Compose.
Node.js: JavaScript backend runtime.
NestJS: Framework for building scalable applications.
Prisma ORM: Database toolkit for PostgreSQL to manage data.
PostgreSQL: Relational database.
Redis: Session management.
OAuth2: Authentication via Google and GitHub.
Argon2: Password hashing algorithm.
TypeScript: Strongly typed JavaScript for better maintainability.
Docker: Containerization for consistent environments.
Docker Compose: Multi-container orchestration for local development.
Next.js: React framework for server-side rendering.
TypeScript: Type-safe JavaScript for robust frontend code.
Tailwind CSS: Utility-first CSS framework for styling.
ShadCN: Component library for accessible and customizable UI.
Zod: Schema validation for form data.
React Hook Form: Performant and flexible form handling.
Users can register using an email and password or via OAuth2 (Google or GitHub). Google reCAPTCHA is required to prevent automated registrations. After registration, a verification email is sent. Users must click the link to verify their email before accessing the profile page.
Registered users can log in with their credentials or OAuth2 providers. If 2FA is enabled, a one-time code is sent to the user's email, which must be entered to complete the login. Sessions are managed securely using Redis.
Users can update their name, email, or enable/disable 2FA. Changes are validated and securely stored in the PostgreSQL database.
Users can request a password reset link via email if they forget their password. The link allows secure password reset.
Users can log out by clicking the user icon and selecting "Logout," which terminates the session.
- you need to have
dockeranddocker-composeinstalled. Follow the docker documentation on how to do this. Node.js (optional for local development without Docker).
- create a new directory (e.g.
fullstack-auth) and navigate into it. - download the fullstack-auth repo.
- create an
.envfile, you can copy the content from the .env.example. - run
docker compose up -d
Access the Application:
Frontend: http://localhost:3000
Backend API: http://localhost:4000
-
Register: Navigate to
/auth/register, complete the form with reCAPTCHA, and verify your email. -
Login: Go to
/auth/login, enter credentials or use OAuth2, and input 2FA code if enabled. -
Profile: Access
/dashboard/settingsto update user details or enable 2FA. -
Password Recovery: Use
/auth/password-recoveryto request a reset link. -
Logout: Click the user icon and select "Logout."