{"id":21497862,"url":"https://github.com/saiyamdubey/jwt_authentication","last_synced_at":"2025-07-04T12:06:51.043Z","repository":{"id":216112377,"uuid":"740497092","full_name":"saiyamdubey/JWT_authentication","owner":"saiyamdubey","description":"Secure your App with JWT authentication. Our middleware checks for valid user login or verified JWT tokens, enabling access to authenticated features. Redirects to the root if not authenticated.","archived":false,"fork":false,"pushed_at":"2024-01-08T13:23:39.000Z","size":5,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-23T16:07:52.394Z","etag":null,"topics":["authorization","es6","express","html-css-javascript","javascript","jwt","jwt-authentication","router-dom","server-side-rendering","tools","validation"],"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/saiyamdubey.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":"2024-01-08T13:18:54.000Z","updated_at":"2024-08-05T19:00:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"fdced8ea-7433-45bb-b419-d72e3ea0148a","html_url":"https://github.com/saiyamdubey/JWT_authentication","commit_stats":null,"previous_names":["saiyamdubey/jwt_authentication"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/saiyamdubey/JWT_authentication","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saiyamdubey%2FJWT_authentication","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saiyamdubey%2FJWT_authentication/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saiyamdubey%2FJWT_authentication/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saiyamdubey%2FJWT_authentication/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saiyamdubey","download_url":"https://codeload.github.com/saiyamdubey/JWT_authentication/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saiyamdubey%2FJWT_authentication/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263507900,"owners_count":23477406,"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":["authorization","es6","express","html-css-javascript","javascript","jwt","jwt-authentication","router-dom","server-side-rendering","tools","validation"],"created_at":"2024-11-23T16:27:06.871Z","updated_at":"2025-07-04T12:06:51.020Z","avatar_url":"https://github.com/saiyamdubey.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JWT Authentication\n\nThis is my JWT_Authentication App it help When the client want to use the Authenticated things then it will run as a MIDDLEWARE to that and finds that if the user is login or they have the verified JWT_token then it allows to do it, otherwise redirect user to the Root ..\n\n## Overview\n\nThis repository contains a sample implementation of JSON Web Token (JWT) authentication. JWT is a compact, URL-safe means of representing claims to be transferred between two parties. It is commonly used for authentication and authorization purposes in web applications.\n\n## Features\n\n- **User Registration**: Register new users with unique credentials.\n- **User Login**: Authenticate users and generate JWT tokens for subsequent requests.\n- **Token Refresh**: Allow users to refresh their JWT tokens to extend their session.\n- **Middleware**: Implement middleware to protect routes that require authentication.\n\n## Technologies Used\n\n- **Node.js**: JavaScript runtime for server-side development.\n- **Express.js**: Web application framework for Node.js.\n- **jsonwebtoken**: Library for generating and verifying JSON Web Tokens.\n- **MongoDB**: NoSQL database for storing user information.\n- **dotenv**: Module to load environment variables from a .env file.\n\n## Setup\n\n1. Clone the repository:\n\n```bash\ngit clone https://github.com/your-username/JWT_authentication.git\ncd JWT_authentication\nInstall dependencies:\n```\n\n```bash\nCopy code\nnpm install\n```\n\nCreate a .env file in the project root and configure environment variables:\n\n# env\n\nCopy code\nPORT=8000 // give your port here\nMONGODB_URI=mongodb://localhost:27017/userlist\nJWT_SECRET=your-secret-key // BeAMan\nStart the server:\n\n# bash\n\nCopy code\n\n```bash\n\nnpm start dev\n\n```\n\nThe server should now be running at http://localhost:8000.\n\n### API Endpoints\n\nPOST /api/register: Register a new user.\nPOST /api/login: Log in and receive a JWT token.\nPOST /api/refresh-token: Refresh the JWT token.\nGET /api/protected-route: Example protected route requiring authentication.\nUsage\nRegister a new user using the /api/register endpoint.\nLog in with the registered credentials using the /api/login endpoint to receive a JWT token.\nUse the token to access protected routes like /api/protected-route.\nTo extend the session, use the /api/refresh-token endpoint with the refresh token.\nContributors\nYour Name saiyamdubey@gmail.com\nLicense\nThis project is licensed under the ISC License.\n\ncreated By --- `Saiyam_Dubey`,\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaiyamdubey%2Fjwt_authentication","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaiyamdubey%2Fjwt_authentication","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaiyamdubey%2Fjwt_authentication/lists"}