jwt

package
v1.24.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JWT

type JWT struct {
	// contains filtered or unexported fields
}

func (*JWT) GenerateToken

func (t *JWT) GenerateToken(payload interface{}, sub string, isAdmin bool, expire time.Duration) (token string, claims JWTClaims, err error)

GenerateToken Generate new jwt token

func (*JWT) ParseToken

func (t *JWT) ParseToken(token string) (*JWTClaims, error)

ParseToken Parse jwt token, return the claims

type JWTClaims

type JWTClaims struct {
	*jwt.StandardClaims
	Admin   bool `json:"admin,omitempty"`
	Payload interface{}
}

type Options

type Options struct {
	Expire     time.Duration `yaml:"expire" default:"24h0m0s" help:"jwt expire time"`
	Cert       string        `yaml:"cert" default:"certs/jwt/tls.crt" help:"jwt cert file"`
	Key        string        `yaml:"key" default:"certs/jwt/tls.key" help:"jwt key file"`
	IssuerAddr string        `json:"issuerAddr" description:"oidc provider issuer address"`
}

func DefaultOptions

func DefaultOptions() *Options

func (*Options) ToJWT

func (opts *Options) ToJWT() *JWT

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL