# README
JWT
A JWT plugin for gin, iris, go-frame, beego, go-zero, go-chassis, go-kit and other frameworks
Use
Download and install
go get github.com/dobyte/jwt
Demo
package main
import (
"fmt"
"log"
"github.com/dobyte/jwt"
)
func main() {
auth, err := jwt.NewJWT(
jwt.WithIssuer("backend"),
jwt.WithSignAlgorithm(jwt.HS256),
jwt.WithSecretKey("secret"),
jwt.WithValidDuration(3600),
jwt.WithLookupLocations("header:Authorization"),
jwt.WithIdentityKey("uid"),
)
if err != nil {
log.Fatal("create jwt instance failed:" + err.Error())
}
token, err := auth.GenerateToken(jwt.Payload{
"uid": 1,
"account": "fuxiao",
})
if err != nil {
log.Fatal("Generate token failed:" + err.Error())
}
fmt.Println(token)
}
Example
View demo example/server.go
API Demo
View demo example/jwt.postman.json
# Functions
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
WithIdentityKey Set the identity key of the token.
WithIssuer Set the issuer of the token.
WithLookupLocations Set the token lookup locations within requests.
WithPublicPrivateKey Set public key and private key.
WithRefreshDuration Set token refresh duration.
WithSecretKey Set secret key.
WithSignAlgorithm Set signature algorithm.
WithStore Set a store adapter for authentication.
WithValidDuration Set token valid duration.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Interfaces
No description provided by the author
# Type aliases
No description provided by the author
No description provided by the author
No description provided by the author