{"id":26516364,"url":"https://github.com/rahulstech/node-authentication-with-email-verification","last_synced_at":"2025-03-21T07:17:22.611Z","repository":{"id":274344403,"uuid":"922561725","full_name":"rahulstech/node-authentication-with-email-verification","owner":"rahulstech","description":"Complete Node.js authentication boilerplate with email verification, password management, JWT token-based authentication, and Google OAuth support. Also containerized using docker","archived":false,"fork":false,"pushed_at":"2025-03-16T20:41:23.000Z","size":29,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-16T21:32:35.227Z","etag":null,"topics":["authentication","aws-ses","bcrypt","bcryptjs-for-password-encryption","docker","docker-compose","expressjs","google-oauth2","joi-validation","json-web-token","mysql","nodejs","passport","passport-jwt","password-hashing","redis","sequelize","token-based-authentication"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rahulstech.png","metadata":{"files":{"readme":"ReadMe.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-26T14:47:41.000Z","updated_at":"2025-03-16T20:41:27.000Z","dependencies_parsed_at":"2025-02-22T13:39:27.017Z","dependency_job_id":"1cc2129d-ca5b-4abf-99e3-5f0a1d64d740","html_url":"https://github.com/rahulstech/node-authentication-with-email-verification","commit_stats":null,"previous_names":["rahulstech/node-express-auth","rahulstech/node-authentication-with-email-verification"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahulstech%2Fnode-authentication-with-email-verification","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahulstech%2Fnode-authentication-with-email-verification/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahulstech%2Fnode-authentication-with-email-verification/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahulstech%2Fnode-authentication-with-email-verification/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rahulstech","download_url":"https://codeload.github.com/rahulstech/node-authentication-with-email-verification/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244752360,"owners_count":20504256,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","aws-ses","bcrypt","bcryptjs-for-password-encryption","docker","docker-compose","expressjs","google-oauth2","joi-validation","json-web-token","mysql","nodejs","passport","passport-jwt","password-hashing","redis","sequelize","token-based-authentication"],"created_at":"2025-03-21T07:17:22.047Z","updated_at":"2025-03-21T07:17:22.599Z","avatar_url":"https://github.com/rahulstech.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NodeJS Authentication with Email Verification and OAuth\n\nThis project provides a robust and secure authentication system for your Node.js applications, featuring email verification, password management, and OAuth integration (Google). It emphasizes security best practices, including token-based authentication with *asymmetric key signing* and password hashing.\n\n## Table of Contents\n\n* [Features](#features)\n* [Tech Stack](#tech-stack)\n* [Installation](#installation)\n    - [Development](#development)\n    - [Production](#production)\n* [API Endpoints](#api-endpoints)\n\n\n## Features\n\n* **User Registration:**\n    * Email and Password registration with mandatory email verification.\n    * Google OAuth registration.\n* **Email Verification:**\n    * Time-limited verification links (15 minutes).\n    * Resend verification email functionality.\n    * Change email address with verification.\n* **Password Management:**\n    * Secure password hashing using bcrypt.\n    * Password reset functionality with time-limited reset links (5 minutes).\n    * Change password functionality.\n* **Authentication:**\n    * Token-based authentication (JWT).\n    * Short-lived access tokens (15 minutes).\n    * Long-lived refresh tokens (7 days) for seamless token renewal.\n    * Access tokens are sent via the `Authorization` header (Bearer token).\n* **Security:**\n    * Protection against common vulnerabilities.\n* **Scalability:**\n    * Designed for scalability using Redis for caching.\n\n[Go to Table of Contents](#table-of-contents)\n\n## Tech Stack\n\n* **Backend:**\n    * Node.js\n    * Express.js\n    * Passport.js (for authentication strategies)\n* **Database:**\n    * MySQL (with Sequelize ORM)\n* **Caching:**\n    * Redis\n* **Email:**\n    * AWS SES\n* **Authentication \u0026 Authorization:**\n    * JWT (JSON Web Tokens)\n    * Google OAuth 2.0\n* **Validation:**\n    * Joi\n* **Other:**\n    * Bcrypt (for password hashing)\n\n[Go to Table of Contents](#table-of-contents)\n\n## Installation \n\n1. **Clone the Repository:**\n\n    ```bash\n    git clone https://github.com/rahulstech/node-authentication-with-email-verification.git\n\n    cd node-authentication-with-email-verification\n    ````\n\n2. **Environment Variables:**\n\n    * Copy `example.env-dev` to `.env-dev` and `example.env-prod` to `.env-prod`\n    * Fill in the required credentials:\n        * Google OAuth Client ID and Secret\n        * AWS SES credentials (IAM user with SES permissions)\n        * Redis host and port (defaults are usually fine)\n\n            ```\n            # Example .env file\n            GOOGLE_CLIENT_ID=your_google_client_id\n            GOOGLE_CLIENT_SECRET=your_google_client_secret\n            AMAZON_ID=your_aws_iam_id\n            AMAZON_SECRET=your_aws_iam_secret\n            AMAZON_REGION=your_aws_region\n            EMAIL_VERIFICATION_SENDER=your_verified_ses_email\n            REDIS_HOST=localhost\n            REDIS_PORT=6379\n            ```\n\n3.  **JWT Keys:**\n\n    * Generate RSA key pair for JWT signing (using OpenSSL):\n\n        ```bash\n        openssl genpkey -algorithm RSA -out jwt_private.pem -pgenopt rsa:key_gen_bits:4096\n        openssl rsa -in jwt_private.pem -pubout -out jwt_public.pem\n        ```\n\n    * Place `jwt_private.pem` and `jwt_public.pem` in the `secrets` directory.  *(Create the `secrets` directory if it doesn't exist.)*\n\n\n    ### Development \n    \n    4.  **Install Dependencies:**\n\n        ```bash\n        npm install\n        ```\n\n    5.  **Database Setup:**\n\n        * Configure MySQL connection in `config/config.json`.\n        * Create the database and run migrations:\n\n            ```bash\n            npx sequelize-cli db:create\n            npx sequelize-cli db:migrate\n            ```\n\n\n    6.  **Run the Dev Server:**\n\n        ```bash\n        npm run dev\n        ```\n\n        The server will typically start on port 5000 (configurable in `.env-dev`).\n\n    [Go to Table of Contents](#table-of-contents)\n\n    ### Production\n\n    4. **Run Docker:**\n        \n        * Run the following command from the project root directory\n\n            ```sh\n            docker-compose up -d # -d will run containers in detached mode. remove -d if you don't want to run in detached mode\n            ```\n\n\n    [Go to Table of Contents](#table-of-contents)\n\n## API Endpoints\n\n```\nPOST /register - Register a new user\nPOST /login - Login a user with email and password\nGET /login/google - Login via google\nGEt /google/callback - Web hook used by google oauth server on authenticated\nGET /dashboard - \nPOST /refresh - Generates new access token based on sent refresh token in request body\nGET /verify/email/link - Send a new email verification link to registered email, requires login\nGET /verify/email - Verify email\nPATCH /email/new - Change email, requires login\nPOST /password/reset/link - Generate the password reset link\nPATCH /password/reset - Reset password if forget\nPATCH /password/new - Change password, requires log in\nGET /logout - Log out, requires login\n```\n\n[Go to Table of Contents](#table-of-contents)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frahulstech%2Fnode-authentication-with-email-verification","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frahulstech%2Fnode-authentication-with-email-verification","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frahulstech%2Fnode-authentication-with-email-verification/lists"}