auth

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: MIT Imports: 12 Imported by: 5

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")
)

Functions

func NewApplication

func NewApplication(guard string) contractauth.Auth

Types

type Application

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

func (*Application) Guard

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

func (*Application) Login

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

func (*Application) LoginUsingID

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

func (*Application) Logout

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

func (*Application) Parse

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

func (*Application) Refresh

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

Refresh need parse token first.

func (*Application) User

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

User need parse token first.

type Auth added in v1.2.0

type Auth map[string]*Guard

type Claims

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

type Guard added in v1.2.0

type Guard struct {
	Claims *Claims
	Token  string
}

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