{"id":24056338,"url":"https://github.com/mohsen104/jwt-based-authentication","last_synced_at":"2026-05-14T11:34:13.600Z","repository":{"id":271602095,"uuid":"899436882","full_name":"mohsen104/JWT-Based-Authentication","owner":"mohsen104","description":"This repository demonstrates a simple implementation of JWT-based authentication in web applications. It includes examples of secure user login, token generation, and protected routes.","archived":false,"fork":false,"pushed_at":"2025-01-08T18:02:26.000Z","size":33,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-08T19:23:57.759Z","etag":null,"topics":["api","authentication","authorization","backend","javascript","jwt","jwt-authentication","node-js","nodejs","webservice"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mohsen104.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-12-06T09:09:52.000Z","updated_at":"2025-01-08T18:04:11.000Z","dependencies_parsed_at":"2025-01-10T12:18:06.120Z","dependency_job_id":null,"html_url":"https://github.com/mohsen104/JWT-Based-Authentication","commit_stats":null,"previous_names":["mohsen104/jwt-based-authentication"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohsen104%2FJWT-Based-Authentication","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohsen104%2FJWT-Based-Authentication/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohsen104%2FJWT-Based-Authentication/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohsen104%2FJWT-Based-Authentication/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mohsen104","download_url":"https://codeload.github.com/mohsen104/JWT-Based-Authentication/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240849057,"owners_count":19867617,"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":["api","authentication","authorization","backend","javascript","jwt","jwt-authentication","node-js","nodejs","webservice"],"created_at":"2025-01-09T05:00:32.154Z","updated_at":"2026-05-14T11:34:13.555Z","avatar_url":"https://github.com/mohsen104.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JWT Based Authentication\n\nA backend API server built with Node.js and Express.js, designed to handle user authentication, login, and account management. The project also integrates Redis for caching and rate limiting to enhance security and performance.\n\n## Features\n\n- User authentication with multiple methods (OTP, password).\n- Secure email and password update functionalities.\n- Token-based access management with refresh tokens.\n- Developer-specific tools like OTP generation.\n- Swagger API documentation for easier integration.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Available Scripts](#available-scripts)\n- [API Documentation](#api-documentation)\n- [Dependencies](#dependencies)\n- [Rate Limiting with Redis](#rate-limiting-with-redis)\n\n## Installation\n\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/mohsen104/JWT-Based-Authentication.git\n   cd JWT-Based-Authentication\n   ```\n\n2. Install dependencies:\n   ```bash\n   npm install\n   ```\n\n3. Install and run Redis:\n   - Follow the [Redis installation guide](https://redis.io/docs/getting-started/installation/).\n   - Start the Redis server:\n     ```bash\n     redis-server\n     ```\n\n4. Create a `.env` file in the root directory with the following content:\n   ```env\n   NODE_ENV\n   PORT\n   MONGO_URI\n   COOKIE_PARSER_SECRET_KEY\n   JWT_SECRET_KEY\n   ```\n\n## Available Scripts\n\n- **Start in Development Mode**:\n  ```bash\n  npm run dev\n  ```\n- **Start in Production Mode**:\n  ```bash\n  npm start\n  ```\n\n## API Documentation\n\nSwagger documentation is available at:\n```\nhttp://localhost:3000/api-docs\n```\n\n### Key Endpoints\n\n#### User Routes\n- **POST** `/user/authentication` - Authenticate a user.\n- **POST** `/user/login/otp` - Login using OTP.\n- **POST** `/user/login/password` - Login using password.\n- **POST** `/user/email/update` - Update email.\n- **POST** `/user/password/update` - Update password.\n- **GET** `/user/accessToken` - Get a new access token using refresh token.\n- **GET** `/user/logout` - Logout user.\n\n#### Developer Routes\n- **POST** `/dev/loginMethod` - Fetch login methods.\n- **GET** `/dev/generateCodeOtp` - Generate an OTP code.\n\n## Dependencies\n\n### Main\n- **bcryptjs**: For password hashing.\n- **cookie-parser**: Parsing cookies in requests.\n- **cors**: Handling cross-origin resource sharing.\n- **express**: Web framework for Node.js.\n- **express-rate-limit**: Middleware for rate limiting.\n- **helmet**: Security headers for Express apps.\n- **joi**: Schema validation.\n- **jsonwebtoken**: JSON Web Token for authentication.\n- **mongoose**: MongoDB object modeling.\n- **morgan**: HTTP request logger.\n- **rate-limit-redis**: Redis-backed rate limiting.\n- **redis**: Redis client for caching and rate limiting.\n\n### Dev\n- **dotenv**: For environment variable management.\n- **nodemon**: Auto-restart server during development.\n- **swagger-jsdoc**: Generate Swagger definitions.\n- **swagger-ui-express**: Swagger UI middleware for Express.\n\n## Rate Limiting with Redis\n\nThis project uses **Redis** with `rate-limit-redis` for advanced rate limiting:\n- Redis acts as a store for request counts.\n- Provides a high-performance solution to prevent abuse of the API.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohsen104%2Fjwt-based-authentication","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmohsen104%2Fjwt-based-authentication","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohsen104%2Fjwt-based-authentication/lists"}