Documentation
¶
Index ¶
Constants ¶
View Source
const ( ContextKeyUID = "uid" ContextKeySubject = "subject" ContextKeyRoles = "roles" )
Variables ¶
View Source
var ( TokenNotFoundError = statuserr.UnauthorizedError( errors.New("AuthorizerError:TOKEN_NOT_FOUND"), "没有提供有效的认证信息", ) NeedLoginError = statuserr.UnauthorizedError( errors.New("AuthorizerError:NEED_LOGIN"), "需要登录才能访问", ) PermissionError = statuserr.ForbiddenError( errors.New("AuthorizerError:PERMISSION_DENIED"), "没有权限访问该资源", ) )
Functions ¶
func GetCurrentRoles ¶
Types ¶
type ContextUtils ¶
type ContextUtils[I UID] struct{}
func (ContextUtils[I]) CheckAuthID ¶
func (c ContextUtils[I]) CheckAuthID(ctx context.Context, id I) error
func (ContextUtils[I]) CheckAuthStatus ¶
func (c ContextUtils[I]) CheckAuthStatus(ctx context.Context) error
func (ContextUtils[I]) GetCurrentID ¶
func (ContextUtils[I]) GetCurrentID(ctx context.Context) (I, error)
type ParserFunc ¶
func (ParserFunc[I, T]) ParseToken ¶
func (f ParserFunc[I, T]) ParseToken(ctx context.Context, token string) (T, error)
type TokenAuthorizer ¶
type UID ¶
type UID interface {
constraints.Integer | ~string
}
Click to show internal directories.
Click to hide internal directories.