auth

package
v0.0.0-...-926f103 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorRefreshTimeExceeded = errors.New("refresh time exceeded")
	ErrorTokenExpired        = errors.New("token expired")
	ErrorNoPrimaryKeyField   = errors.New("the primaryKey field was not found in the model, set primaryKey like orm.Model")
	ErrorEmptySecret         = errors.New("secret is required")
	ErrorTokenDisabled       = errors.New("token is disabled")
	ErrorParseTokenFirst     = errors.New("parse token first")
	ErrorInvalidClaims       = errors.New("invalid claims")
	ErrorInvalidToken        = errors.New("invalid token")
	ErrorInvalidKey          = errors.New("invalid key")
)

Functions

This section is empty.

Types

type Auth

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

func NewAuth

func NewAuth(guard string) *Auth

func (*Auth) Guard

func (app *Auth) Guard(name string) contractauth.Auth

func (*Auth) Login

func (app *Auth) Login(ctx http.Context, user any) (token string, err error)

func (*Auth) LoginUsingID

func (app *Auth) LoginUsingID(ctx http.Context, id any) (token string, err error)

func (*Auth) Logout

func (app *Auth) Logout(ctx http.Context) error

func (*Auth) Parse

func (app *Auth) Parse(ctx http.Context, token string) error

func (*Auth) Refresh

func (app *Auth) Refresh(ctx http.Context) (token string, err error)

Refresh need parse token first.

func (*Auth) User

func (app *Auth) User(ctx http.Context, user any) error

User need parse token first.

type Claims

type Claims struct {
	Key string `json:"key"`
	jwt.RegisteredClaims
}

type Guard

type Guard struct {
	Claims *Claims
	Token  string
}

type Guards

type Guards map[string]*Guard

type ServiceProvider

type ServiceProvider struct {
}

func (*ServiceProvider) Boot

func (database *ServiceProvider) Boot()

func (*ServiceProvider) Register

func (database *ServiceProvider) Register()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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