{"id":18429501,"url":"https://github.com/go-chi/jwtauth","last_synced_at":"2026-02-26T11:28:18.792Z","repository":{"id":37734229,"uuid":"45200393","full_name":"go-chi/jwtauth","owner":"go-chi","description":"JWT authentication middleware for Go HTTP services","archived":false,"fork":false,"pushed_at":"2025-11-20T09:41:09.000Z","size":102,"stargazers_count":628,"open_issues_count":16,"forks_count":92,"subscribers_count":8,"default_branch":"master","last_synced_at":"2026-02-12T07:56:34.784Z","etag":null,"topics":["go","http","jwt","jwt-authentication-middleware","jwtauth","microservices"],"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/go-chi.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}},"created_at":"2015-10-29T17:43:54.000Z","updated_at":"2026-02-07T22:30:35.000Z","dependencies_parsed_at":"2024-06-21T13:03:31.144Z","dependency_job_id":"6c99aef2-ad86-4ea1-94e0-6d8484a2c050","html_url":"https://github.com/go-chi/jwtauth","commit_stats":{"total_commits":80,"total_committers":15,"mean_commits":5.333333333333333,"dds":0.6,"last_synced_commit":"f399db5200f612f0e6ed098801e5b2d873a21cda"},"previous_names":["goware/jwtauth"],"tags_count":27,"template":false,"template_full_name":null,"purl":"pkg:github/go-chi/jwtauth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-chi%2Fjwtauth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-chi%2Fjwtauth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-chi%2Fjwtauth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-chi%2Fjwtauth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/go-chi","download_url":"https://codeload.github.com/go-chi/jwtauth/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-chi%2Fjwtauth/sbom","scorecard":{"id":431512,"data":{"date":"2025-08-11","repo":{"name":"github.com/go-chi/jwtauth","commit":"0eb3c515b56b0578c296494d00851122175f1d90"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.8,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":3,"reason":"Found 10/28 approved changesets -- score normalized to 3","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":3,"reason":"dependency not pinned by hash detected -- score normalized to 3","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/go-chi/jwtauth/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/go-chi/jwtauth/ci.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   1 out of   1 goCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":9,"reason":"1 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2025-3770 / GHSA-vrw8-fxc6-2r93"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 16 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T03:27:38.001Z","repository_id":37734229,"created_at":"2025-08-19T03:27:38.002Z","updated_at":"2025-08-19T03:27:38.002Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29857369,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-26T08:51:08.701Z","status":"ssl_error","status_checked_at":"2026-02-26T08:50:19.607Z","response_time":89,"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":["go","http","jwt","jwt-authentication-middleware","jwtauth","microservices"],"created_at":"2024-11-06T05:17:25.060Z","updated_at":"2026-02-26T11:28:18.762Z","avatar_url":"https://github.com/go-chi.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jwtauth - JWT authentication middleware for HTTP services\n\n[![GoDoc Widget]][godoc]\n\nThe `jwtauth` http middleware package provides a simple way to verify a JWT token\nfrom a http request and send the result down the request context (`context.Context`).\n\nPlease note, `jwtauth` works with any Go http router, but resides under the go-chi group\nfor maintenance and organization - its only 3rd party dependency is the underlying jwt library\n\"github.com/lestrrat-go/jwx\".\n\nIn a complete JWT-authentication flow, you'll first capture the token from a http\nrequest, decode it, verify it and then validate that its correctly signed and hasn't\nexpired - the `jwtauth.Verifier` middleware handler takes care of all of that. The\n`jwtauth.Verifier` will set the context values on keys `jwtauth.TokenCtxKey` and\n`jwtauth.ErrorCtxKey`.\n\nNext, it's up to an authentication handler to respond or continue processing after the\n`jwtauth.Verifier`. The `jwtauth.Authenticator` middleware responds with a 401 Unauthorized\nplain-text payload for all unverified tokens and passes the good ones through. You can\nalso copy the Authenticator and customize it to handle invalid tokens to better fit\nyour flow (ie. with a JSON error response body).\n\nBy default, the `Verifier` will search for a JWT token in a http request, in the order:\n\n1.  'Authorization: BEARER T' request header\n2.  'jwt' Cookie value\n\nThe first JWT string that is found as an authorization header\nor cookie header is then decoded by the `lestrrat-go/jwx` library and a jwt.Token\nobject is set on the request context. In the case of a signature decoding error\nthe Verifier will also set the error on the request context.\n\nThe Verifier always calls the next http handler in sequence, which can either\nbe the generic `jwtauth.Authenticator` middleware or your own custom handler\nwhich checks the request context jwt token and error to prepare a custom\nhttp response.\n\nNote: jwtauth supports custom verification sequences for finding a token\nfrom a request by using the `Verify` middleware instantiator directly. The default\n`Verifier` is instantiated by calling `Verify(ja, TokenFromHeader, TokenFromCookie)`.\n\n# Usage\n\nSee the full [example](https://github.com/go-chi/jwtauth/blob/master/_example/main.go).\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\n\t\"github.com/go-chi/chi/v5\"\n\t\"github.com/go-chi/jwtauth/v5\"\n)\n\nvar tokenAuth *jwtauth.JWTAuth\n\nfunc init() {\n\ttokenAuth = jwtauth.New(\"HS256\", []byte(\"secret\"), nil)\n\n\t// For debugging/example purposes, we generate and print\n\t// a sample jwt token with claims `user_id:123` here:\n\t_, tokenString, _ := tokenAuth.Encode(map[string]interface{}{\"user_id\": 123})\n\tfmt.Printf(\"DEBUG: a sample jwt is %s\\n\\n\", tokenString)\n}\n\nfunc main() {\n\taddr := \":3333\"\n\tfmt.Printf(\"Starting server on %v\\n\", addr)\n\thttp.ListenAndServe(addr, router())\n}\n\nfunc router() http.Handler {\n\tr := chi.NewRouter()\n\n\t// Protected routes\n\tr.Group(func(r chi.Router) {\n\t\t// Seek, verify and validate JWT tokens\n\t\tr.Use(jwtauth.Verifier(tokenAuth))\n\n\t\t// Handle valid / invalid tokens. In this example, we use\n\t\t// the provided authenticator middleware, but you can write your\n\t\t// own very easily, look at the Authenticator method in jwtauth.go\n\t\t// and tweak it, its not scary.\n\t\tr.Use(jwtauth.Authenticator(tokenAuth))\n\n\t\tr.Get(\"/admin\", func(w http.ResponseWriter, r *http.Request) {\n\t\t\t_, claims, _ := jwtauth.FromContext(r.Context())\n\t\t\tw.Write([]byte(fmt.Sprintf(\"protected area. hi %v\", claims[\"user_id\"])))\n\t\t})\n\t})\n\n\t// Public routes\n\tr.Group(func(r chi.Router) {\n\t\tr.Get(\"/\", func(w http.ResponseWriter, r *http.Request) {\n\t\t\tw.Write([]byte(\"welcome anonymous\"))\n\t\t})\n\t})\n\n\treturn r\n}\n```\n\n# Util\n\nSee https://github.com/goware/jwtutil for utility to help you generate JWT tokens.\n\n`go install github.com/goware/jwtutil`\n\nUsage: `jwtutil -secret=secret -encode -claims='{\"user_id\":111}'`\n\nOutput: `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoxMTF9._cLJn0xFS0Mdr_4L_8XF8-8tv7bHyOQJXyWaNsSqlEs`\n\n\n# LICENSE\n\n[MIT](/LICENSE)\n\n[godoc]: https://pkg.go.dev/github.com/go-chi/jwtauth/v5\n[godoc widget]: https://godoc.org/github.com/go-chi/jwtauth?status.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-chi%2Fjwtauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgo-chi%2Fjwtauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-chi%2Fjwtauth/lists"}