jwt

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: BSD-3-Clause Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultAlg                = jwt.SigningMethodHS512
	DefaultExpireSecond int64 = 60 * 30
)

Functions

This section is empty.

Types

type Guard

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

func NewJwtGuard

func NewJwtGuard(tokenProvider TokenProvider, userProvider authenticate.UserProvider, key []byte, expireSecond ...int64) *Guard

func (*Guard) Alg

func (g *Guard) Alg() *jwt.SigningMethodHMAC

func (*Guard) Auth

func (g *Guard) Auth(user authenticate.User) error

func (*Guard) Check

func (g *Guard) Check() (authenticate.User, error)

func (*Guard) ExpireSecond

func (g *Guard) ExpireSecond() int64

func (*Guard) Key

func (g *Guard) Key() ([]byte, error)

func (*Guard) ParseToken

func (g *Guard) ParseToken() error

func (*Guard) Token

func (g *Guard) Token() Token

func (*Guard) User

func (g *Guard) User() authenticate.User

type InvalidTokenError

type InvalidTokenError string

func (InvalidTokenError) Error

func (it InvalidTokenError) Error() string

type Token

type Token struct {
	AccessToken string `json:"access_token"`
	ExpireIn    int64  `json:"expire_in"`
	Type        string `json:"type"`
	// contains filtered or unexported fields
}

type TokenProvider

type TokenProvider interface {
	GetAccessToken() ([]byte, error)
}

type User

type User interface {
	authenticate.User
	GetJwtClaims() jwt.MapClaims
}

Jump to

Keyboard shortcuts

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