auth

package
v1.15.12 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2025 License: MIT Imports: 25 Imported by: 11

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
	ErrorUnsupportedDriverMethod = errors.AuthUnsupportedDriverMethod
)

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

Functions

func NewJwtGuard added in v1.15.12

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

func NewOrmUserProvider added in v1.15.12

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

func NewSessionGuard added in v1.15.12

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

Types

type Auth added in v1.2.0

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

func NewAuth added in v1.6.0

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

func (*Auth) Extend added in v1.15.12

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

func (*Auth) Guard added in v1.6.0

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

func (*Auth) Provider added in v1.15.12

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

type Claims

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

type Guards added in v1.6.0

type Guards map[string]*JwtToken

type JwtGuard added in v1.15.12

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

func (*JwtGuard) Check added in v1.15.12

func (r *JwtGuard) Check() bool

func (*JwtGuard) GetJwtToken added in v1.15.12

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

func (*JwtGuard) Guest added in v1.15.12

func (r *JwtGuard) Guest() bool

func (*JwtGuard) ID added in v1.15.12

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

func (*JwtGuard) Login added in v1.15.12

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

func (*JwtGuard) LoginUsingID added in v1.15.12

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

func (*JwtGuard) Logout added in v1.15.12

func (r *JwtGuard) Logout() error

func (*JwtGuard) Parse added in v1.15.12

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

func (*JwtGuard) Refresh added in v1.15.12

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

Refresh need parse token first.

func (*JwtGuard) User added in v1.15.12

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

User need parse token first.

type JwtToken added in v1.15.12

type JwtToken struct {
	Claims *Claims
	Token  string
}

type OrmUserProvider added in v1.15.12

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

func (*OrmUserProvider) GetID added in v1.15.12

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

GetID implements auth.UserProvider.

func (*OrmUserProvider) RetriveByID added in v1.15.12

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

RetriveByID implements auth.UserProvider.

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 added in v1.15.12

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

type SessionGuard added in v1.15.12

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

func (*SessionGuard) Check added in v1.15.12

func (r *SessionGuard) Check() bool

func (*SessionGuard) Guest added in v1.15.12

func (r *SessionGuard) Guest() bool

func (*SessionGuard) ID added in v1.15.12

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

func (*SessionGuard) Login added in v1.15.12

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

func (*SessionGuard) LoginUsingID added in v1.15.12

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

func (*SessionGuard) Logout added in v1.15.12

func (r *SessionGuard) Logout() error

func (*SessionGuard) Parse added in v1.15.12

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

func (*SessionGuard) Refresh added in v1.15.12

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

func (*SessionGuard) User added in v1.15.12

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