{"id":13408771,"url":"https://github.com/cristalhq/jwt","last_synced_at":"2025-05-14T07:08:30.501Z","repository":{"id":35031170,"uuid":"197966460","full_name":"cristalhq/jwt","owner":"cristalhq","description":"Safe, simple and fast JSON Web Tokens for Go","archived":false,"fork":false,"pushed_at":"2024-07-10T08:11:23.000Z","size":309,"stargazers_count":683,"open_issues_count":1,"forks_count":47,"subscribers_count":14,"default_branch":"main","last_synced_at":"2025-05-14T01:46:12.983Z","etag":null,"topics":["dependency-free","go","golang","golang-library","jose","jwe","jwk","jws","jwt","jwt-claims","jwt-token"],"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/cristalhq.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":"2019-07-20T18:14:58.000Z","updated_at":"2025-05-12T10:24:58.000Z","dependencies_parsed_at":"2023-11-18T11:28:11.479Z","dependency_job_id":"c126446a-3c1c-45dc-9e43-afa59a96c0df","html_url":"https://github.com/cristalhq/jwt","commit_stats":{"total_commits":192,"total_committers":15,"mean_commits":12.8,"dds":"0.40104166666666663","last_synced_commit":"5acbf8433b5ec0a12f404b90a8adc44ede4485d4"},"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristalhq%2Fjwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristalhq%2Fjwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristalhq%2Fjwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristalhq%2Fjwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cristalhq","download_url":"https://codeload.github.com/cristalhq/jwt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254092776,"owners_count":22013290,"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":["dependency-free","go","golang","golang-library","jose","jwe","jwk","jws","jwt","jwt-claims","jwt-token"],"created_at":"2024-07-30T20:00:55.133Z","updated_at":"2025-05-14T07:08:30.478Z","avatar_url":"https://github.com/cristalhq.png","language":"Go","funding_links":[],"categories":["Authentication and Authorization","开源类库","Authentication and OAuth","Go","Open source library","认证和OAuth授权","身份验证和OAuth","Uncategorized"],"sub_categories":["Auth","Contents"],"readme":"# jwt\n\n[![build-img]][build-url]\n[![pkg-img]][pkg-url]\n[![reportcard-img]][reportcard-url]\n[![coverage-img]][coverage-url]\n[![version-img]][version-url]\n\nJSON Web Token for Go [RFC 7519](https://tools.ietf.org/html/rfc7519), also see [jwt.io](https://jwt.io) for more.\n\nThe latest version is `v5`.\n\n## Rationale\n\nThere are many JWT libraries, but many of them are hard to use (unclear or fixed API), not optimal (unneeded allocations + strange API). This library addresses all these issues. It's simple to read, to use, memory and CPU conservative.\n\n## Features\n\n* Simple API.\n* Clean and tested code.\n* Optimized for speed.\n* Concurrent-safe.\n* Dependency-free.\n* All well-known algorithms are supported\n  * HMAC (HS)\n  * RSA (RS)\n  * RSA-PSS (PS)\n  * ECDSA (ES)\n  * EdDSA (EdDSA)\n  * or your own!\n\nSee [GUIDE.md](https://github.com/cristalhq/jwt/blob/main/GUIDE.md) for more details.\n\n## Install\n\nGo version 1.17+\n\n```\ngo get github.com/cristalhq/jwt/v5\n```\n\n## Example\n\nBuild new token:\n\n```go\n// create a Signer (HMAC in this example)\nkey := []byte(`secret`)\nsigner, err := jwt.NewSignerHS(jwt.HS256, key)\ncheckErr(err)\n\n// create claims (you can create your own, see: ExampleBuilder_withUserClaims)\nclaims := \u0026jwt.RegisteredClaims{\n    Audience: []string{\"admin\"},\n    ID:       \"random-unique-string\",\n}\n\n// create a Builder\nbuilder := jwt.NewBuilder(signer)\n\n// and build a Token\ntoken, err := builder.Build(claims)\ncheckErr(err)\n\n// here is token as a string\nvar _ string = token.String()\n```\n\nParse and verify token:\n```go\n// create a Verifier (HMAC in this example)\nkey := []byte(`secret`)\nverifier, err := jwt.NewVerifierHS(jwt.HS256, key)\ncheckErr(err)\n\n// parse and verify a token\ntokenBytes := token.Bytes()\nnewToken, err := jwt.Parse(tokenBytes, verifier)\ncheckErr(err)\n\n// or just verify it's signature\nerr = verifier.Verify(newToken)\ncheckErr(err)\n\n// get Registered claims\nvar newClaims jwt.RegisteredClaims\nerrClaims := json.Unmarshal(newToken.Claims(), \u0026newClaims)\ncheckErr(errClaims)\n\n// or parse only claims\nerrParseClaims := jwt.ParseClaims(tokenBytes, verifier, \u0026newClaims)\ncheckErr(errParseClaims)\n\n// verify claims as you wish\nvar _ bool = newClaims.IsForAudience(\"admin\")\nvar _ bool = newClaims.IsValidAt(time.Now())\n```\n\nAlso see examples: [example_test.go](https://github.com/cristalhq/jwt/blob/main/example_test.go).\n\n## Documentation\n\nSee [these docs][pkg-url].\n\n## License\n\n[MIT License](LICENSE).\n\n[build-img]: https://github.com/cristalhq/jwt/workflows/build/badge.svg\n[build-url]: https://github.com/cristalhq/jwt/actions\n[pkg-img]: https://pkg.go.dev/badge/cristalhq/jwt/v5\n[pkg-url]: https://pkg.go.dev/github.com/cristalhq/jwt/v5\n[reportcard-img]: https://goreportcard.com/badge/cristalhq/jwt\n[reportcard-url]: https://goreportcard.com/report/cristalhq/jwt\n[coverage-img]: https://codecov.io/gh/cristalhq/jwt/branch/main/graph/badge.svg\n[coverage-url]: https://codecov.io/gh/cristalhq/jwt\n[version-img]: https://img.shields.io/github/v/release/cristalhq/jwt\n[version-url]: https://github.com/cristalhq/jwt/releases\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcristalhq%2Fjwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcristalhq%2Fjwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcristalhq%2Fjwt/lists"}