authx

package
v1.0.3-beta Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2021 License: MIT Imports: 7 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UserLoginError      = errors.New("please first authorize user login")
	RefreshTokenExpired = errors.New("refresh token verification expired")
)

Functions

func Middleware

func Middleware(auth Auth, args ...interface{}) gin.HandlerFunc

Middleware authorization verification

Types

type Args

type Args struct {
	Method    jwt.SigningMethod
	UseCookie *cookie.Cookie
	RefreshFn RefreshFn
}

type Auth

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

func Make

func Make(option Option, args Args) *Auth

func (*Auth) Create

func (x *Auth) Create(c *gin.Context, sub interface{}, uid interface{}, data interface{}) (raw string, err error)

Create authorization logic

func (*Auth) Destory

func (x *Auth) Destory(c *gin.Context, args ...interface{}) (err error)

Destory authorization logic

func (*Auth) Verify

func (x *Auth) Verify(c *gin.Context, args ...interface{}) (err error)

Verify authorization logic

type Option

type Option struct {
	Key       string   `yaml:"key"`
	Issuer    string   `yaml:"issuer"`
	Audience  []string `yaml:"audience"`
	NotBefore int64    `yaml:"not_before"`
	Expires   int64    `yaml:"expires"`
}

type RefreshFn

type RefreshFn interface {
	Factory(claims jwt.MapClaims, args ...interface{})
	Verify(claims jwt.MapClaims, args ...interface{}) bool
	Renewal(claims jwt.MapClaims, args ...interface{})
	Destory(claims jwt.MapClaims, args ...interface{}) (err error)
}

Jump to

Keyboard shortcuts

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