{"id":24019785,"url":"https://github.com/anuragchauhan766/jwt-auth","last_synced_at":"2025-05-07T07:35:11.628Z","repository":{"id":186642792,"uuid":"675380306","full_name":"anuragchauhan766/jwt-auth","owner":"anuragchauhan766","description":"JWT Authentication system ","archived":false,"fork":false,"pushed_at":"2023-08-08T03:40:16.000Z","size":137,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T07:41:35.548Z","etag":null,"topics":["express-session","jwt-authentication","mern","mern-authentication","nodejs","nodejs-authorization-middleware"],"latest_commit_sha":null,"homepage":"https://jwt-auth-eb22.onrender.com","language":"TypeScript","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/anuragchauhan766.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":"2023-08-06T18:10:46.000Z","updated_at":"2025-01-03T11:30:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"a650d420-8e8d-44ee-87de-5ba4d06b680b","html_url":"https://github.com/anuragchauhan766/jwt-auth","commit_stats":null,"previous_names":["anuragchauhan766/jwt-auth"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anuragchauhan766%2Fjwt-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anuragchauhan766%2Fjwt-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anuragchauhan766%2Fjwt-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anuragchauhan766%2Fjwt-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anuragchauhan766","download_url":"https://codeload.github.com/anuragchauhan766/jwt-auth/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252834210,"owners_count":21811336,"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":["express-session","jwt-authentication","mern","mern-authentication","nodejs","nodejs-authorization-middleware"],"created_at":"2025-01-08T11:40:39.275Z","updated_at":"2025-05-07T07:35:11.604Z","avatar_url":"https://github.com/anuragchauhan766.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JWT Authentication System with Session Management - MERN Stack\n\nThis repository contains a JWT (JSON Web Token) Authentication System developed using the MERN Stack (MongoDB, Express, React, Node.js). The system focuses on session management, access token, and refresh token mechanisms with an expiration time of 30 seconds and 2 minutes, respectively. Additionally, it provides features like password reset, email verification, and silent authentication with access token renewal. The primary aim of this project is to delve into the details of JWT and authentication, emphasizing session management.\n\n## Table of Content\n\n1. [Introduction](#introduction)\n2. [Features](#features)\n3. [Requirements](#requirements)\n4. [Installation](#installation)\n5. [Configuration](#configuration)\n6. [Usage](#usage)\n7. [API Endpoints](#api-endpoints)\n8. [Contributing](#contributing)\n9. [License](#license)\n\n## Introduction\n\nThis JWT Authentication System serves as a backend-focused project to demonstrate the workings of JWT and session management in a MERN application. JSON Web Tokens are used to authenticate users and maintain their sessions securely. The system implements access and refresh tokens, each with different expiration times, to achieve improved security and usability.\n\n\u003e ### Note\n\n\u003e For development and project showcase, the expiration time of tokens is kept short\n\u003e\n\u003e - Access token: 30 seconds\n\u003e - Refresh token: 2 minutes\n\u003e - reset password token: 3 minutes\n\u003e - account Activation token: 30 minutes\n\nYou can change these according to your needs\n\n## Features\n\n1. User registration with Email verification\n2. User login with email and password\n3. Password reset functionality with email confirmation.\n4. Access token renewal (Silent Authentication)\n5. Secure Session Management with Token Expiration\n6. Protected Account route with Token authentication\n\n## Requirements\n\n- [Nodejs](https://nodejs.org/en) (v18 or higher)\n- [pnpm](https://pnpm.io/) (v8 or higher)\n- [mongodb](https://www.mongodb.com/)\n\n## Installation\n\n1. Clone this repository on your local machine\n\n```bash\ngit clone https://github.com/anuragchauhan766/jwt-auth.git\n```\n\n1. Install dependencies by running\n\n```bash\npnpm i -r\n```\n\n## Configuration\n\nBefore running the application, you need to configure some settings.\n\n### Create a .env file from env.example in the API root folder and set the following environment variables:\n\n```env\nDATABASE=\"Your mongodb connection URL \"\nACCESS_TOKEN_SECRET_KEY=' secret key'\nREFRESH_TOKEN_SECRET_KEY='secret key'\nRESET_PASSWORD_SECRET_KEY='secret key'\nACTIVATION_SECRET_KEY='secret key'\nSEND_IN_BLUE_EMAIL_SERVICE_API_KEY=\"send in blue API key\"\nSEND_IN_BLUE_USERNAME=\"sendinblue username\"\nSEND_IN_BLUE_PASSWORD=\"send in blue password\"\nNODEMAIL_EMAIL_FROM=\"email for sending mails to user\"\nCLIENT_BASE_URL=\"http://localhost:5173\"\n```\n\nMake sure to replace the key's value with an actual value, You can generate **secret keys** with crypto as follows:\n\n1. run node command\n\n```bash\nnode\n```\n\n1. Now generate a random string with given command\n\n```bash\nrequire(\"crypto\").randomBytes(64).toString(\"hex\")\n```\n\n#### create .env file from env.example in the **client** root folder with following variables:\n\n```\nVITE_API_BASE_URL=\"http://localhost:3000\"\n```\n\n## Usage\n\nTo start the application, run the following command from the project root:\n\n### - backend\n\n```bash\ncd api \u0026\u0026 pnpm dev\n```\n\n### - frontend\n\n```bash\ncd client \u0026\u0026 pnpm dev\n```\n\nThe backend will be available at http://localhost:3000\nFrontend will be available at http://localhost:5173\n\n## API Endpoints\n\nThe API provides the following endpoints:\n\n- `POST api/auth/signin`: Singin and get access token and refresh token\n- `POST api/auth/signup`: Register new User with email verification\n- `POST api/auth/forgotpassword`: Send mail for password reset link\n- `POST api/auth/resetpassword`: reset password\n- `POST api/auth/send-verification-mail`: send account verification mail\n- `GET api/auth/verifyemail`: verify the user mail with token\n- `GET api/auth/refresh`: refresh(renew) the access token\n- `GET api/auth/signout`: signout the User\n- `GET api/user`: get the user details\n\n## Contributing\n\nContributions to this project are welcome. Please fork the repository, make your changes, and submit a pull request. For major changes, please open an issue first to discuss the proposed changes.\n\n## License\n\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanuragchauhan766%2Fjwt-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanuragchauhan766%2Fjwt-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanuragchauhan766%2Fjwt-auth/lists"}