Documentation
¶
Index ¶
- Variables
- func NewJwtGuard(ctx http.Context, name string, userProvider contractsauth.UserProvider) (contractsauth.GuardDriver, error)
- func NewOrmUserProvider(ctx http.Context) (contractsauth.UserProvider, error)
- func NewSessionGuard(ctx http.Context, name string, userProvider contractsauth.UserProvider) (contractsauth.GuardDriver, error)
- type Auth
- type Claims
- type Guards
- type JwtGuard
- func (r *JwtGuard) Check() bool
- func (r *JwtGuard) GetJwtToken() (*JwtToken, error)
- func (r *JwtGuard) Guest() bool
- func (r *JwtGuard) ID() (string, error)
- func (r *JwtGuard) Login(user any) (token string, err error)
- func (r *JwtGuard) LoginUsingID(id any) (token string, err error)
- func (r *JwtGuard) Logout() error
- func (r *JwtGuard) Parse(token string) (*contractsauth.Payload, error)
- func (r *JwtGuard) Refresh() (token string, err error)
- func (r *JwtGuard) User(user any) error
- type JwtToken
- type OrmUserProvider
- type ServiceProvider
- type SessionGuard
- func (r *SessionGuard) Check() bool
- func (r *SessionGuard) Guest() bool
- func (r *SessionGuard) ID() (token string, err error)
- func (r *SessionGuard) Login(user any) (token string, err error)
- func (r *SessionGuard) LoginUsingID(id any) (token string, err error)
- func (r *SessionGuard) Logout() error
- func (r *SessionGuard) Parse(token string) (*contractsauth.Payload, error)
- func (r *SessionGuard) Refresh() (token string, err error)
- func (r *SessionGuard) User(user any) error
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 (*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 JwtGuard ¶
type JwtGuard struct {
// contains filtered or unexported fields
}
func (*JwtGuard) GetJwtToken ¶
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) 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
Source Files
¶
Click to show internal directories.
Click to hide internal directories.