Documentation ¶
Index ¶
- Variables
- type AuthDecorator
- type AuthRequestListener
- type AuthenticationHandler
- type AuthenticationRequest
- type AuthorizationTokenWriter
- type BearerTokenReader
- type CacheDecorator
- type CacheRecord
- type ExternalAuthenticationRequest
- type ExternalAuthenticationResponse
- type HeaderTokenWriter
- type JWTResponse
- type JwtVerifier
- type MappedToken
- type RedisTokenStore
- type RestAuthDecorator
- type TokenReader
- type TokenStore
- type TokenStoreOptions
- type TokenWriter
Constants ¶
This section is empty.
Variables ¶
View Source
var InvalidCredentialsError error = errors.New("invalid credentials given")
View Source
var NoTokenError error = errors.New("No authentication token found in request")
Functions ¶
This section is empty.
Types ¶
type AuthDecorator ¶
type AuthDecorator interface { DecorateHandler(httprouter.Handle, string, *config.Application, *config.Configuration) httprouter.Handle RegisterRoutes(*httprouter.Router) error RegisterRequestListener(AuthRequestListener) }
func NewAuthDecorator ¶
func NewAuthDecorator( authConfig *config.GlobalAuth, redisPool *redis.Pool, logger *logging.Logger, authHandler *AuthenticationHandler, tokenStore TokenStore, uiDir string, ) (AuthDecorator, error)
type AuthRequestListener ¶
type AuthenticationHandler ¶
type AuthenticationHandler struct {
// contains filtered or unexported fields
}
func NewAuthenticationHandler ¶
func NewAuthenticationHandler( cfg *config.GlobalAuth, redisPool *redis.Pool, tokenStore TokenStore, verifier *JwtVerifier, logger *logging.Logger, ) (*AuthenticationHandler, error)
func (*AuthenticationHandler) Authenticate ¶
func (h *AuthenticationHandler) Authenticate(username string, password string) (*JWTResponse, error)
func (*AuthenticationHandler) IsAuthenticated ¶
func (h *AuthenticationHandler) IsAuthenticated(req *http.Request) (bool, *JWTResponse, error)
type AuthenticationRequest ¶
type AuthorizationTokenWriter ¶
type AuthorizationTokenWriter struct{}
func (*AuthorizationTokenWriter) WriteTokenToRequest ¶
func (a *AuthorizationTokenWriter) WriteTokenToRequest(jwt string, req *http.Request) error
type BearerTokenReader ¶
type BearerTokenReader struct {
// contains filtered or unexported fields
}
func (*BearerTokenReader) TokenFromRequest ¶
func (b *BearerTokenReader) TokenFromRequest(req *http.Request) (*JWTResponse, error)
type CacheDecorator ¶
type CacheDecorator struct {
// contains filtered or unexported fields
}
func (*CacheDecorator) AddToken ¶
func (s *CacheDecorator) AddToken(jwt *JWTResponse) (string, int64, error)
func (*CacheDecorator) GetAllTokens ¶
func (s *CacheDecorator) GetAllTokens() (<-chan MappedToken, error)
func (*CacheDecorator) GetToken ¶
func (s *CacheDecorator) GetToken(token string) (*JWTResponse, error)
func (*CacheDecorator) SetToken ¶
func (s *CacheDecorator) SetToken(token string, jwt *JWTResponse) (int64, error)
type CacheRecord ¶
type CacheRecord struct {
// contains filtered or unexported fields
}
type HeaderTokenWriter ¶
type HeaderTokenWriter struct {
HeaderName string
}
func (*HeaderTokenWriter) WriteTokenToRequest ¶
func (h *HeaderTokenWriter) WriteTokenToRequest(jwt string, req *http.Request) error
type JWTResponse ¶
type JwtVerifier ¶
type JwtVerifier struct {
// contains filtered or unexported fields
}
func NewJwtVerifier ¶
func NewJwtVerifier(cfg *config.GlobalAuth) (*JwtVerifier, error)
func (*JwtVerifier) GetVerificationKey ¶
func (h *JwtVerifier) GetVerificationKey() ([]byte, error)
func (*JwtVerifier) VerifyToken ¶
func (h *JwtVerifier) VerifyToken(token string) (bool, *jwt.StandardClaims, jwt.MapClaims, error)
type MappedToken ¶
type RedisTokenStore ¶
type RedisTokenStore struct {
// contains filtered or unexported fields
}
func (*RedisTokenStore) AddToken ¶
func (s *RedisTokenStore) AddToken(jwt *JWTResponse) (string, int64, error)
func (*RedisTokenStore) GetAllTokens ¶
func (s *RedisTokenStore) GetAllTokens() (<-chan MappedToken, error)
func (*RedisTokenStore) GetToken ¶
func (s *RedisTokenStore) GetToken(token string) (*JWTResponse, error)
func (*RedisTokenStore) SetToken ¶
func (s *RedisTokenStore) SetToken(token string, jwt *JWTResponse) (int64, error)
type RestAuthDecorator ¶
type RestAuthDecorator struct {
// contains filtered or unexported fields
}
func NewRestAuthDecorator ¶
func NewRestAuthDecorator(authHandler *AuthenticationHandler, tokenStore TokenStore, logger *logging.Logger) *RestAuthDecorator
func (*RestAuthDecorator) DecorateHandler ¶
func (a *RestAuthDecorator) DecorateHandler(orig httprouter.Handle, appName string, appCfg *config.Application, cfg *config.Configuration) httprouter.Handle
func (*RestAuthDecorator) RegisterRequestListener ¶
func (a *RestAuthDecorator) RegisterRequestListener(listener AuthRequestListener)
func (*RestAuthDecorator) RegisterRoutes ¶
func (a *RestAuthDecorator) RegisterRoutes(mux *httprouter.Router) error
type TokenReader ¶
type TokenReader interface {
TokenFromRequest(*http.Request) (*JWTResponse, error)
}
type TokenStore ¶
type TokenStore interface { AddToken(*JWTResponse) (string, int64, error) SetToken(string, *JWTResponse) (int64, error) GetToken(string) (*JWTResponse, error) GetAllTokens() (<-chan MappedToken, error) }
func NewTokenStore ¶
func NewTokenStore(redisPool *redis.Pool, verifier *JwtVerifier, options TokenStoreOptions) (TokenStore, error)
type TokenStoreOptions ¶
type TokenStoreOptions struct {
LocalCacheBucketSize int
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.