Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Jwt | 6,910 | 6,817 | 535 | 4 days ago | 51 | August 19, 2022 | 5 | bsd-3-clause | PHP | |
A simple library to work with JSON Web Token and JSON Web Signature | ||||||||||
Pyjwt | 4,518 | 9,443 | 1,606 | 2 days ago | 45 | May 12, 2022 | 22 | mit | Python | |
JSON Web Token implementation in Python | ||||||||||
Jsmn | 3,090 | 5 months ago | 88 | mit | C | |||||
Jsmn is a world fastest JSON parser/tokenizer. This is the official repo replacing the old one at Bitbucket | ||||||||||
Jwt | 1,944 | 313 | 305 | 19 days ago | 122 | September 26, 2022 | 7 | other | C# | |
Jwt.Net, a JWT (JSON Web Token) implementation for .NET | ||||||||||
Node Jwt Simple | 1,320 | 7,828 | 569 | 2 years ago | 13 | March 30, 2019 | 33 | mit | JavaScript | |
JWT(JSON Web Token) encode and decode module for node.js | ||||||||||
Vault Ui | 1,299 | 5 years ago | 3 | October 04, 2017 | 50 | other | JavaScript | |||
Vault-UI — A beautiful UI to manage your Vault, written in React | ||||||||||
Frangipanni | 1,156 | 3 months ago | 6 | April 10, 2021 | 6 | mit | Go | |||
Program to convert lines of text into a tree structure. | ||||||||||
Spring Boot Jwt | 1,022 | a year ago | mit | Java | ||||||
JWT auth service using Spring Boot, Spring Security and MySQL | ||||||||||
Token Lists | 942 | 51 | 6 days ago | 30 | June 16, 2022 | 91 | mit | TypeScript | ||
📚 The Token Lists specification | ||||||||||
Jwt | 844 | 6 years ago | mit | Java | ||||||
webapp用户身份认证方案 JSON WEB TOKEN 实现Deme示例,Java版 |
JSON Web Token for Go RFC 7519, also see jwt.io for more.
The latest version is v5
.
There 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.
See GUIDE.md for more details.
Go version 1.17+
go get github.com/cristalhq/jwt/v5
Build new token:
// create a Signer (HMAC in this example)
key := []byte(`secret`)
signer, err := jwt.NewSignerHS(jwt.HS256, key)
checkErr(err)
// create claims (you can create your own, see: Example_BuildUserClaims)
claims := &jwt.RegisteredClaims{
Audience: []string{"admin"},
ID: "random-unique-string",
}
// create a Builder
builder := jwt.NewBuilder(signer)
// and build a Token
token, err := builder.Build(claims)
checkErr(err)
// here is token as a string
var _ string = token.String()
Parse and verify token:
// create a Verifier (HMAC in this example)
key := []byte(`secret`)
verifier, err := jwt.NewVerifierHS(jwt.HS256, key)
checkErr(err)
// parse and verify a token
tokenBytes := token.Bytes()
newToken, err := jwt.Parse(tokenBytes, verifier)
checkErr(err)
// or just verify it's signature
err = verifier.Verify(newToken)
checkErr(err)
// get Registered claims
var newClaims jwt.RegisteredClaims
errClaims := json.Unmarshal(newToken.Claims(), &newClaims)
checkErr(errClaims)
// or parse only claims
errParseClaims := jwt.ParseClaims(tokenBytes, verifier, &newClaims)
checkErr(errParseClaims)
// verify claims as you wish
var _ bool = newClaims.IsForAudience("admin")
var _ bool = newClaims.IsValidAt(time.Now())
Also see examples: example_test.go.
See these docs.