Documentation ¶
Index ¶
- Variables
- type AccessToken
- type Option
- func WithGetAccessToken(getToken func(ctx *gin.Context) (string, error)) Option
- func WithHandlerError(handlerError func(ctx *gin.Context, err error) error) Option
- func WithLock(lock sync.Locker) Option
- func WithSetContext(...) Option
- func WithStorage(storage Storage) Option
- func WithTokenExpired(tokenExpired int64, refreshExpired int64) Option
- type Options
- type Storage
- type TokenAuth
- func (t *TokenAuth) Delete(ctx context.Context, accessToken *AccessToken) error
- func (t *TokenAuth) Generate(ctx context.Context) *AccessToken
- func (t *TokenAuth) Get(ctx context.Context) *AccessToken
- func (t *TokenAuth) Middleware(force bool) gin.HandlerFunc
- func (t *TokenAuth) Refresh(ctx context.Context, refreshToken string) (*AccessToken, error)
- func (t *TokenAuth) Save(ctx context.Context, accessToken *AccessToken) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrTokenInvalid = httputils.NewUnauthorizedError(-2, "token失效") ErrTokenExpired = httputils.NewUnauthorizedError(-3, "token过期") ErrRefreshTokenInvalid = httputils.NewUnauthorizedError(-4, "refresh_token失效") ErrRefreshTokenExpired = httputils.NewUnauthorizedError(-5, "refresh_token过期") )
Functions ¶
This section is empty.
Types ¶
type AccessToken ¶
type Option ¶
type Option func(*Options)
func WithGetAccessToken ¶
func WithHandlerError ¶
func WithSetContext ¶
func WithStorage ¶
func WithTokenExpired ¶
type Storage ¶
type Storage interface { Save(ctx context.Context, accessToken *AccessToken) error FindByAccessToken(ctx context.Context, accessToken string) (*AccessToken, error) FindByRefreshToken(ctx context.Context, refreshToken string) (*AccessToken, error) Delete(ctx context.Context, accessToken *AccessToken) error }
type TokenAuth ¶
type TokenAuth struct {
// contains filtered or unexported fields
}
func NewTokenAuth ¶
func (*TokenAuth) Delete ¶
func (t *TokenAuth) Delete(ctx context.Context, accessToken *AccessToken) error
func (*TokenAuth) Middleware ¶
func (t *TokenAuth) Middleware(force bool) gin.HandlerFunc
Middleware 中间件 force 是否强制要求鉴权
Click to show internal directories.
Click to hide internal directories.