All Projects → cristalhq → Jwt

cristalhq / Jwt

Licence: mit
Safe, simple and fast JSON Web Tokens for Go

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Jwt

Jose2go
Golang (GO) implementation of Javascript Object Signing and Encryption specification
Stars: ✭ 150 (-35.06%)
Mutual labels:  jwt, jwt-token, jws, jose, jwe
Jose Jwt
Ultimate Javascript Object Signing and Encryption (JOSE) and JSON Web Token (JWT) Implementation for .NET and .NET Core
Stars: ✭ 692 (+199.57%)
Mutual labels:  jwt, jwt-token, jws, jose, jwe
Cli
🧰 A zero trust swiss army knife for working with X509, OAuth, JWT, OATH OTP, etc.
Stars: ✭ 2,151 (+831.17%)
Mutual labels:  jwt, jws, jose, jwe
Authlib
The ultimate Python library in building OAuth, OpenID Connect clients and servers. JWS,JWE,JWK,JWA,JWT included.
Stars: ✭ 2,854 (+1135.5%)
Mutual labels:  jwt, jws, jose, jwe
Jose
🔐 JSON Object Signing and Encryption Framework (JWT, JWS, JWE, JWA, JWK, JWKSet and more)
Stars: ✭ 479 (+107.36%)
Mutual labels:  jwt, jws, jose, jwe
Jose
JSON Object Signing and Encryption for Node.js and the browser
Stars: ✭ 25 (-89.18%)
Mutual labels:  jwt, jws, jose, jwe
Json Jwt
JSON Web Token and its family (JSON Web Signature, JSON Web Encryption and JSON Web Key) in Ruby
Stars: ✭ 262 (+13.42%)
Mutual labels:  jwt, jws, jose, jwe
Jwt Framework
JWT Framework
Stars: ✭ 577 (+149.78%)
Mutual labels:  jwt, jws, jose, jwe
Go Jose
An implementation of JOSE standards (JWE, JWS, JWT) in Go
Stars: ✭ 1,849 (+700.43%)
Mutual labels:  jwt, jws, jose, jwe
Jose
Universal "JSON Web Almost Everything" - JWA, JWS, JWE, JWT, JWK with no dependencies
Stars: ✭ 1,029 (+345.45%)
Mutual labels:  jwt, jws, jose, jwe
Joseswift
A framework for the JOSE standards JWS, JWE, and JWK written in Swift.
Stars: ✭ 114 (-50.65%)
Mutual labels:  jws, jose, jwe
Hs Jose
Haskell JOSE and JWT library
Stars: ✭ 100 (-56.71%)
Mutual labels:  jwt, jws, jose
lexik-jose-bridge
An Encoder for the LexikJWTAuthenticationBundle that uses web-token/jwt-framework
Stars: ✭ 27 (-88.31%)
Mutual labels:  jose, jwe, jws
jwt-signature
[READ ONLY] Signature component of the JWT Framework
Stars: ✭ 32 (-86.15%)
Mutual labels:  jose, jwe, jws
Jwt
Go JWT signing, verifying and validating
Stars: ✭ 394 (+70.56%)
Mutual labels:  jwt, jwt-token, jws
Jose
A JOSE implementation
Stars: ✭ 20 (-91.34%)
Mutual labels:  jwt, jws, jose
jwx
JSON/JWK/JWS/JWT/Base64 library in SPARK
Stars: ✭ 15 (-93.51%)
Mutual labels:  jose, jwt-token, jws
jwt-core
[READ-ONLY] Core component of the JWT Framework
Stars: ✭ 46 (-80.09%)
Mutual labels:  jose, jwe, jws
Jwx
Implementation of various JWx (Javascript Object Signing and Encryption/JOSE) technologies
Stars: ✭ 600 (+159.74%)
Mutual labels:  jwt, jws, jwe
Python Jwt
JSON Web Token library for Python
Stars: ✭ 81 (-64.94%)
Mutual labels:  jwt, jws, jose

jwt

build-img pkg-img reportcard-img coverage-img

JSON Web Token for Go RFC 7519, also see jwt.io for more.

The latest version is v3.

Rationale

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.

Features

  • Simple API.
  • Clean and tested code.
  • Optimized for speed.
  • Concurrent-safe.
  • Dependency-free.
  • All well-known algorithms are supported
    • HMAC (HS)
    • RSA (RS)
    • RSA-PSS (PS)
    • ECDSA (ES)
    • EdDSA (EdDSA)
    • or your own!

Install

Go version 1.13+

GO111MODULE=on go get github.com/cristalhq/jwt/v3

Example

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 byte slice
var _ []byte = token.Bytes() // or just token.String() for 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 a Token (by example received from a request)
tokenStr := `<header.payload.signature>`
token, err := jwt.ParseString(tokenStr)
checkErr(err)

// and verify it's signature
err = verifier.Verify(token.Payload(), token.Signature())
checkErr(err)

// also you can parse and verify together
newToken, err := jwt.ParseAndVerifyString(tokenStr, verifier)
checkErr(err)

// get standard claims
var newClaims jwt.StandardClaims
errClaims := json.Unmarshal(newToken.RawClaims(), &newClaims)
checkErr(errClaims)

// verify claims as you 
var _ bool = newClaims.IsForAudience("admin")
var _ bool = newClaims.IsValidAt(time.Now())

Also see examples: example_test.go.

Documentation

See these docs.

License

MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].