{"id":30323917,"url":"https://github.com/pardnchiu/go-jwt","last_synced_at":"2026-04-05T15:01:44.985Z","repository":{"id":295281303,"uuid":"989466496","full_name":"pardnchiu/go-jwt","owner":"pardnchiu","description":"JWT authentication with auto-renewal","archived":false,"fork":false,"pushed_at":"2025-10-21T18:54:11.000Z","size":164,"stargazers_count":15,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-02T19:10:11.162Z","etag":null,"topics":["backend","golang","jwt","jwt-auth","pardnchiu"],"latest_commit_sha":null,"homepage":"","language":"Go","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/pardnchiu.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-24T06:40:32.000Z","updated_at":"2026-01-03T06:09:15.000Z","dependencies_parsed_at":"2026-01-12T03:02:58.160Z","dependency_job_id":null,"html_url":"https://github.com/pardnchiu/go-jwt","commit_stats":null,"previous_names":["pardnio/golang-jwt-auth","pardnltd-tools/golang-jwt-auth","pardnchiu/golang-jwt-auth","pardnchiu/go-jwt-auth"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/pardnchiu/go-jwt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pardnchiu%2Fgo-jwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pardnchiu%2Fgo-jwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pardnchiu%2Fgo-jwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pardnchiu%2Fgo-jwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pardnchiu","download_url":"https://codeload.github.com/pardnchiu/go-jwt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pardnchiu%2Fgo-jwt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31439442,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T13:13:19.330Z","status":"ssl_error","status_checked_at":"2026-04-05T13:13:17.778Z","response_time":75,"last_error":"SSL_read: 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":["backend","golang","jwt","jwt-auth","pardnchiu"],"created_at":"2025-08-17T22:20:15.037Z","updated_at":"2026-04-05T15:01:44.980Z","avatar_url":"https://github.com/pardnchiu.png","language":"Go","funding_links":[],"categories":["Authentication and Authorization"],"sub_categories":[],"readme":"\u003e [!NOTE]\n\u003e This README was generated by [SKILL](https://github.com/pardnchiu/skill-readme-generate), get the ZH version from [here](./README.zh.md).\n\n# go-jwt\n\n[![pkg](https://pkg.go.dev/badge/github.com/pardnchiu/go-jwt.svg)](https://pkg.go.dev/github.com/pardnchiu/go-jwt)\n[![card](https://goreportcard.com/badge/github.com/pardnchiu/go-jwt)](https://goreportcard.com/report/github.com/pardnchiu/go-jwt)\n[![codecov](https://img.shields.io/codecov/c/github/pardnchiu/go-jwt)](https://app.codecov.io/github/pardnchiu/go-jwt)\n[![license](https://img.shields.io/github/license/pardnchiu/go-jwt)](LICENSE)\n[![version](https://img.shields.io/github/v/tag/pardnchiu/go-jwt?label=release)](https://github.com/pardnchiu/go-jwt/releases)\n[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)\n\n\u003e ECDSA and Redis-backed JWT authentication library with full token lifecycle management and device fingerprint binding.\n\n## Table of Contents\n\n- [Features](#features)\n- [Architecture](#architecture)\n- [File Structure](#file-structure)\n- [License](#license)\n- [Author](#author)\n- [Stars](#stars)\n\n## Features\n\n\u003e `go get github.com/pardnchiu/go-jwt` · [Documentation](./doc.md)\n\n### Redis-Driven Token Lifecycle\n\nIntegrates Redis for complete Access Token and Refresh ID lifecycle management, including creation, verification, refresh, and revocation. Ensures atomicity of multi-key operations through Redis Transaction Pipelines and prevents concurrent Refresh Token race conditions with distributed locks.\n\n### Device Fingerprint Binding\n\nBinds tokens to the user's device environment (OS, browser, device type) via SHA-256 hashing. Even if a token is stolen, attackers cannot use it on a different device, fundamentally preventing token hijacking attacks.\n\n### Dual-Framework Middleware\n\nProvides plug-and-play middleware for both Gin and standard `net/http`, automatically handling token verification and expiration refresh flows. Developers retrieve authenticated user data directly from the context without manual token lifecycle intervention.\n\n## Architecture\n\n```mermaid\ngraph TB\n    REQ[HTTP Request] --\u003e MW[Middleware\u003cbr/\u003eGin / net/http]\n    MW --\u003e V[Verify]\n    V --\u003e|Valid Token| AUTH[Return Auth Data]\n    V --\u003e|Expired Token| RF[Refresh]\n    V --\u003e|No Token| DENY[Deny Access]\n    RF --\u003e|Valid Refresh ID| SIGN[Re-sign Access Token]\n    RF --\u003e|Threshold Exceeded| CREATE[Full Token Rebuild]\n    RF --\u003e|Invalid| DENY\n    SIGN --\u003e REDIS[(Redis)]\n    CREATE --\u003e REDIS\n    V --\u003e FP[Device Fingerprint Check]\n    FP --\u003e REDIS\n```\n\n## File Structure\n\n```\ngo-jwt/\n├── instance.go       # Initialization and config validation\n├── create.go         # Token creation and JWT signing\n├── verify.go         # Token verification and JWT parsing\n├── refresh.go        # Token refresh with distributed lock\n├── revoke.go         # Token revocation\n├── middleware.go     # Gin / net/http middleware\n├── cookie.go         # Cookie management\n├── pem.go            # ECDSA key handling\n├── refreshData.go    # Refresh ID and device fingerprint\n├── utility.go        # Helper functions\n├── uuid.go           # UUID v4 generation\n├── type.go           # Type definitions\n├── jwt_test.go       # Unit tests\n└── go.mod\n```\n\n## License\n\nThis project is licensed under the [MIT LICENSE](LICENSE).\n\n## Author\n\n\u003cimg src=\"https://avatars.githubusercontent.com/u/25631760\" align=\"left\" width=\"96\" height=\"96\" style=\"margin-right: 0.5rem;\"\u003e\n\n\u003ch4 style=\"padding-top: 0\"\u003e邱敬幃 Pardn Chiu\u003c/h4\u003e\n\n\u003ca href=\"mailto:dev@pardn.io\" target=\"_blank\"\u003e\n\u003cimg src=\"https://pardn.io/image/email.svg\" width=\"48\" height=\"48\"\u003e\n\u003c/a\u003e \u003ca href=\"https://linkedin.com/in/pardnchiu\" target=\"_blank\"\u003e\n\u003cimg src=\"https://pardn.io/image/linkedin.svg\" width=\"48\" height=\"48\"\u003e\n\u003c/a\u003e\n\n## Stars\n\n[![Star](https://api.star-history.com/svg?repos=pardnchiu/go-jwt\u0026type=Date)](https://www.star-history.com/#pardnchiu/go-jwt\u0026Date)\n\n***\n\n©️ 2025 [邱敬幃 Pardn Chiu](https://linkedin.com/in/pardnchiu)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpardnchiu%2Fgo-jwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpardnchiu%2Fgo-jwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpardnchiu%2Fgo-jwt/lists"}