Documentation
¶
Overview ¶
Package middleware provides login middlewares: - Auth: adds auth from session and populates user info - Trace: populates user info if token presented - AdminOnly: restrict access to admin users only
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Authenticator ¶
type Authenticator struct {
logger.L
JWTService TokenService
Providers []provider.Service
Validator token.Validator
AdminPasswd string
RefreshCache RefreshCache
}
Authenticator is top level auth object providing middlewares
func (*Authenticator) AdminOnly ¶
func (a *Authenticator) AdminOnly(next http.Handler) http.Handler
AdminOnly middleware allows access for admins only this handler internally wrapped with auth(true) to avoid situation if AdminOnly defined without prior Auth
type RefreshCache ¶ added in v0.4.0
type RefreshCache interface {
Get(key interface{}) (value interface{}, ok bool)
Set(key, value interface{})
}
type TokenService ¶
type TokenService interface {
Parse(tokenString string) (claims token.Claims, err error)
Set(w http.ResponseWriter, claims token.Claims) (token.Claims, error)
Get(r *http.Request) (claims token.Claims, token string, err error)
IsExpired(claims token.Claims) bool
Reset(w http.ResponseWriter)
}
TokenService defines interface accessing tokens
Click to show internal directories.
Click to hide internal directories.