Help us shape the future of Go! Take the 2026 Go Developer Survey

auth

package
v1.20.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorRefreshTimeExceeded     = errors.AuthRefreshTimeExceeded
	ErrorTokenExpired            = errors.AuthTokenExpired
	ErrorNoPrimaryKeyField       = errors.AuthNoPrimaryKeyField
	ErrorEmptySecret             = errors.AuthEmptySecret
	ErrorTokenDisabled           = errors.AuthTokenDisabled
	ErrorParseTokenFirst         = errors.AuthParseTokenFirst
	ErrorInvalidClaims           = errors.AuthInvalidClaims
	ErrorInvalidToken            = errors.AuthInvalidToken
	ErrorInvalidKey              = errors.AuthInvalidKey
	ErrorGuardMismatch           = errors.AuthGuardMismatch
	ErrorUnsupportedDriverMethod = errors.AuthUnsupportedDriverMethod
)

These errors may be used by user's project, so we can't remove them.

Functions

func NewJwtGuard

func NewJwtGuard(ctx http.Context, name string, userProvider contractsauth.UserProvider) (contractsauth.GuardDriver, error)

func NewOrmUserProvider

func NewOrmUserProvider(ctx http.Context) (contractsauth.UserProvider, error)

func NewSessionGuard

func NewSessionGuard(ctx http.Context, name string, userProvider contractsauth.UserProvider) (contractsauth.GuardDriver, error)

Types

type Auth

type Auth struct {
	contractsauth.GuardDriver
	// contains filtered or unexported fields
}

func NewAuth

func NewAuth(ctx http.Context, config config.Config, log log.Log) (*Auth, error)

func (*Auth) Extend

func (r *Auth) Extend(name string, fn contractsauth.GuardFunc)

func (*Auth) Guard

func (r *Auth) Guard(name string) contractsauth.GuardDriver

func (*Auth) Provider

func (r *Auth) Provider(name string, fn contractsauth.UserProviderFunc)

type Claims

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

type Guards

type Guards map[string]*JwtToken

type JwtGuard

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

func (*JwtGuard) Check

func (r *JwtGuard) Check() bool

func (*JwtGuard) GetJwtToken

func (r *JwtGuard) GetJwtToken() (*JwtToken, error)

func (*JwtGuard) Guest

func (r *JwtGuard) Guest() bool

func (*JwtGuard) ID

func (r *JwtGuard) ID() (string, error)

func (*JwtGuard) Login

func (r *JwtGuard) Login(user any) (token string, err error)

func (*JwtGuard) LoginUsingID

func (r *JwtGuard) LoginUsingID(id any) (token string, err error)

func (*JwtGuard) Logout

func (r *JwtGuard) Logout() error

func (*JwtGuard) Parse

func (r *JwtGuard) Parse(token string) (*contractsauth.Payload, error)

func (*JwtGuard) Refresh

func (r *JwtGuard) Refresh() (token string, err error)

Refresh need parse token first.

func (*JwtGuard) User

func (r *JwtGuard) User(user any) error

User need parse token first.

type JwtToken

type JwtToken struct {
	Claims *Claims
	Token  string
}

type OrmUserProvider

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

func (*OrmUserProvider) GetID

func (r *OrmUserProvider) GetID(user any) (any, error)

GetID implements auth.UserProvider.

func (*OrmUserProvider) RetriveByID

func (r *OrmUserProvider) RetriveByID(user any, id any) error

RetriveByID implements auth.UserProvider.

The id is passed as a bare value, which the ORM resolves against the model's primary key. That is the same shape the relation writers use, and it keeps this package free of GORM's clause types.

type ServiceProvider

type ServiceProvider struct {
}

func (*ServiceProvider) Boot

func (r *ServiceProvider) Boot(app foundation.Application)

func (*ServiceProvider) Register

func (r *ServiceProvider) Register(app foundation.Application)

func (*ServiceProvider) Relationship

func (r *ServiceProvider) Relationship() contractsbinding.Relationship

type SessionGuard

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

func (*SessionGuard) Check

func (r *SessionGuard) Check() bool

func (*SessionGuard) Guest

func (r *SessionGuard) Guest() bool

func (*SessionGuard) ID

func (r *SessionGuard) ID() (token string, err error)

func (*SessionGuard) Login

func (r *SessionGuard) Login(user any) (token string, err error)

func (*SessionGuard) LoginUsingID

func (r *SessionGuard) LoginUsingID(id any) (token string, err error)

func (*SessionGuard) Logout

func (r *SessionGuard) Logout() error

func (*SessionGuard) Parse

func (r *SessionGuard) Parse(token string) (*contractsauth.Payload, error)

func (*SessionGuard) Refresh

func (r *SessionGuard) Refresh() (token string, err error)

func (*SessionGuard) User

func (r *SessionGuard) User(user any) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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