auth

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2020 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

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 AuthRequestListener interface {
	OnAuthenticatedRequest(req *http.Request, jwt string)
}

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 AuthenticationRequest struct {
	Username   string   `json:"username"`
	Password   string   `json:"password"`
	TimeToLive int      `json:"ttl"`
	Providers  []string `json:"providers"`
}

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 ExternalAuthenticationRequest

type ExternalAuthenticationRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type ExternalAuthenticationResponse

type ExternalAuthenticationResponse struct {
	Token   string `json:"token"`
	Expires string `json:"expires,omitempty"`
}

type HeaderTokenWriter

type HeaderTokenWriter struct {
	HeaderName string
}

func (*HeaderTokenWriter) WriteTokenToRequest

func (h *HeaderTokenWriter) WriteTokenToRequest(jwt string, req *http.Request) error

type JWTResponse

type JWTResponse struct {
	JWT                 string
	AllowedApplications []string
}

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 MappedToken struct {
	Jwt   string
	Token string
}

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
}

type TokenWriter

type TokenWriter interface {
	WriteTokenToRequest(string, *http.Request) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL