Versions in this module Expand all Collapse all v1 v1.0.0 Apr 27, 2026 Changes in this version + var ErrForbidden = errors.New("security: forbidden") + var ErrTokenExpired = errors.New("security: token expired") + var ErrTokenInvalid = errors.New("security: token invalid") + var ErrUnauthorized = errors.New("security: unauthorized") + func ClaimsFromContext(ctx web.Context) (map[string]any, bool) + func NewRoleGuardFactory() web.GuardFactory + type Configurer interface + Configure func(hs *HTTPSecurity) + type HTTPSecurity struct + func NewHTTPSecurity(svc JWTServicer) *HTTPSecurity + func (hs *HTTPSecurity) Build() web.Guard + func (hs *HTTPSecurity) Route(pattern string) *RouteSecurityBuilder + type JWTGuard struct + func NewJWTGuard(svc JWTServicer) *JWTGuard + func (g *JWTGuard) CanActivate(ctx web.Context) error + type JWTService struct + func NewJWTService(secret string, expiry time.Duration) (*JWTService, error) + func (s *JWTService) Generate(claims map[string]any) (string, error) + func (s *JWTService) Refresh(tokenStr string) (string, error) + func (s *JWTService) Validate(tokenStr string) (map[string]any, error) + type JWTServicer interface + Generate func(claims map[string]any) (string, error) + Refresh func(token string) (string, error) + Validate func(token string) (map[string]any, error) + type RoleGuard struct + func NewRoleGuard(allowedRoles ...string) *RoleGuard + func (g *RoleGuard) CanActivate(ctx web.Context) error + type RouteSecurityBuilder struct + func (b *RouteSecurityBuilder) Authenticated() *HTTPSecurity + func (b *RouteSecurityBuilder) HasRole(roles ...string) *HTTPSecurity + func (b *RouteSecurityBuilder) PermitAll() *HTTPSecurity