{"id":19227450,"url":"https://github.com/sushantrahate/jwt-auth-refresh-token-as-http-only-cookie","last_synced_at":"2026-05-16T15:34:18.307Z","repository":{"id":237399226,"uuid":"794452626","full_name":"sushantrahate/jwt-auth-refresh-token-as-http-only-cookie","owner":"sushantrahate","description":"JWT Authentication With Refresh Token as HTTP-only Cookie","archived":false,"fork":false,"pushed_at":"2024-11-12T07:30:40.000Z","size":63,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-23T10:29:06.425Z","etag":null,"topics":["access-token","authentication","httponly-cookie","javscript","jwt","nodejs","refresh-token"],"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/sushantrahate.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-05-01T07:40:30.000Z","updated_at":"2024-11-12T07:30:43.000Z","dependencies_parsed_at":"2025-02-23T10:25:56.984Z","dependency_job_id":null,"html_url":"https://github.com/sushantrahate/jwt-auth-refresh-token-as-http-only-cookie","commit_stats":null,"previous_names":["sushantrahate/jwt-auth-refresh-token-as-http-only-cookie"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sushantrahate/jwt-auth-refresh-token-as-http-only-cookie","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sushantrahate%2Fjwt-auth-refresh-token-as-http-only-cookie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sushantrahate%2Fjwt-auth-refresh-token-as-http-only-cookie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sushantrahate%2Fjwt-auth-refresh-token-as-http-only-cookie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sushantrahate%2Fjwt-auth-refresh-token-as-http-only-cookie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sushantrahate","download_url":"https://codeload.github.com/sushantrahate/jwt-auth-refresh-token-as-http-only-cookie/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sushantrahate%2Fjwt-auth-refresh-token-as-http-only-cookie/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33108186,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T04:41:52.686Z","status":"ssl_error","status_checked_at":"2026-05-16T04:41:52.009Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["access-token","authentication","httponly-cookie","javscript","jwt","nodejs","refresh-token"],"created_at":"2024-11-09T15:23:21.087Z","updated_at":"2026-05-16T15:34:18.288Z","avatar_url":"https://github.com/sushantrahate.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JWT Authentication With Refresh Token as HTTP-only Cookie using NodeJS\n\nA simple Node.js app that implements JWT-based authentication, including handling both access and refresh tokens via HttpOnly cookies. The project serves a static HTML file and manages secure backend routes.\n\n## Usage\nDownload repo, install dependency `npm i` and run `node app.js`\n\n## Access the App\nOpen a browser and navigate to `http://localhost:3000`\n\n## Project Structure\n```\n│\n├── app.js # Node.js server file\n├── index.html # HTML file for frontend operations\n```\n\n## Functionality:\n\n### Backend:\n- Static File Serving: Serves static files (HTML, JS, CSS) from the public directory.\n- API Routes:\n  - Register: Allows users to register with a username and password.\n  - Login: Validates credentials and issues access and refresh tokens, stored as HttpOnly cookies.\n  - Token Refresh: Generates a new access token if the current one expires, using the refresh token.\n  - Logout: Clears tokens and removes them from in-memory storage.\n- Middleware:\n  - Token Verification: Checks for a valid access token, and attempts to renew it using the refresh token if it fails.\n\n### Frontend:\n- HTML Interface: Provides forms for registration, login, accessing protected routes, and logging out.\n- JavaScript Logic: Handles communication with the backend via fetch requests, including:\n  - Handling Credentials: Uses credentials: 'include' to include cookies in requests.\n  - Error Handling: Alerts users for unsuccessful actions and renews tokens if needed.\n\nIf you liked it then please show your love by ⭐ the repo\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsushantrahate%2Fjwt-auth-refresh-token-as-http-only-cookie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsushantrahate%2Fjwt-auth-refresh-token-as-http-only-cookie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsushantrahate%2Fjwt-auth-refresh-token-as-http-only-cookie/lists"}