Documentation ¶
Index ¶
- Constants
- func NewBasicAuthHandler(config cfg.Config, logger log.Logger) (gin.HandlerFunc, error)
- func NewChainHandler(authenticators map[string]Authenticator) gin.HandlerFunc
- func NewConfigGoogleHandler(config cfg.Config, logger log.Logger) (gin.HandlerFunc, error)
- func NewConfigKeyHandler(config cfg.Config, logger log.Logger, provider ApiKeyProvider) gin.HandlerFunc
- func NewJwtAuthHandler(config cfg.Config, name string) gin.HandlerFunc
- func NewTokenBearerHandler(config cfg.Config, logger log.Logger, provider TokenBearerProvider) gin.HandlerFunc
- func NewUncheckedKeyHandler(config cfg.Config, logger log.Logger, provider ApiKeyProvider) gin.HandlerFunc
- func OnlyConfiguredAuthenticators(config cfg.Config, name string, authenticators map[string]Authenticator) map[string]Authenticator
- func RequestWithSubject(ginCtx *gin.Context, subject *Subject)
- type ApiKeyProvider
- type Authenticator
- func NewBasicAuthAuthenticator(config cfg.Config, logger log.Logger) (Authenticator, error)
- func NewBasicAuthAuthenticatorWithInterfaces(logger log.Logger, users map[string]string) Authenticator
- func NewConfigGoogleAuthenticator(config cfg.Config, logger log.Logger) (Authenticator, error)
- func NewConfigGoogleAuthenticatorWithInterfaces(logger log.Logger, tokenProvider TokenInfoProvider, clientIds []string, ...) Authenticator
- func NewConfigKeyAuthenticator(config cfg.Config, logger log.Logger, provider ApiKeyProvider) Authenticator
- func NewConfigKeyAuthenticatorWithInterfaces(logger log.Logger, keys []string, provider ApiKeyProvider) Authenticator
- func NewJWTAuthAuthenticator(config cfg.Config, name string) Authenticator
- func NewJWTAuthAuthenticatorWithInterfaces(jwtTokenHandler JwtTokenHandler) Authenticator
- func NewTokenBearerAuthenticator(config cfg.Config, logger log.Logger, provider TokenBearerProvider) Authenticator
- func NewTokenBearerAuthenticatorWithInterfaces(logger log.Logger, keyHeader string, tokenHeader string, ...) Authenticator
- func NewUncheckedKeyAuthenticator(_ cfg.Config, logger log.Logger, provider ApiKeyProvider) Authenticator
- func NewUncheckedKeyAuthenticatorWithInterfaces(logger log.Logger, provider ApiKeyProvider) Authenticator
- type Claims
- type Getter
- type GoogleTokenProvider
- type InvalidBearerErr
- type InvalidTokenErr
- type JwtClaims
- type JwtTokenHandler
- type JwtTokenHandlerSettings
- type ModelProvider
- type Settings
- type SignUserInput
- type Subject
- type TokenBearer
- type TokenBearerProvider
- type TokenInfoProvider
Constants ¶
View Source
const ( ByBasicAuth = "basicAuth" AttributeUser = "user" )
View Source
const ( ByApiKey = "apiKey" HeaderApiKey = "X-API-KEY" AttributeApiKey = "apiKey" )
View Source
const ( ByTokenBearer = "tokenBearer" AttributeToken = "token" AttributeTokenBearerId = "tokenBearerId" AttributeTokenBearer = "tokenBearer" )
View Source
const Anonymous = "anon"
View Source
const ByGoogle = "google"
View Source
const (
ByJWT = "jwtAuth"
)
Variables ¶
This section is empty.
Functions ¶
func NewBasicAuthHandler ¶
func NewChainHandler ¶
func NewChainHandler(authenticators map[string]Authenticator) gin.HandlerFunc
func NewConfigGoogleHandler ¶
func NewConfigKeyHandler ¶
func NewConfigKeyHandler(config cfg.Config, logger log.Logger, provider ApiKeyProvider) gin.HandlerFunc
func NewJwtAuthHandler ¶
func NewJwtAuthHandler(config cfg.Config, name string) gin.HandlerFunc
func NewTokenBearerHandler ¶
func NewTokenBearerHandler(config cfg.Config, logger log.Logger, provider TokenBearerProvider) gin.HandlerFunc
func NewUncheckedKeyHandler ¶
func NewUncheckedKeyHandler(config cfg.Config, logger log.Logger, provider ApiKeyProvider) gin.HandlerFunc
func OnlyConfiguredAuthenticators ¶ added in v0.21.3
func OnlyConfiguredAuthenticators(config cfg.Config, name string, authenticators map[string]Authenticator) map[string]Authenticator
func RequestWithSubject ¶
Types ¶
type ApiKeyProvider ¶
func ProvideValueFromHeader ¶
func ProvideValueFromHeader(header string) ApiKeyProvider
func ProvideValueFromQueryParam ¶
func ProvideValueFromQueryParam(queryParam string) ApiKeyProvider
func ProvideValueFromUriPath ¶
func ProvideValueFromUriPath(param string) ApiKeyProvider
type Authenticator ¶
func NewBasicAuthAuthenticatorWithInterfaces ¶
func NewBasicAuthAuthenticatorWithInterfaces(logger log.Logger, users map[string]string) Authenticator
func NewConfigGoogleAuthenticatorWithInterfaces ¶
func NewConfigGoogleAuthenticatorWithInterfaces(logger log.Logger, tokenProvider TokenInfoProvider, clientIds []string, allowedAddresses []string) Authenticator
func NewConfigKeyAuthenticator ¶
func NewConfigKeyAuthenticator(config cfg.Config, logger log.Logger, provider ApiKeyProvider) Authenticator
func NewConfigKeyAuthenticatorWithInterfaces ¶
func NewConfigKeyAuthenticatorWithInterfaces(logger log.Logger, keys []string, provider ApiKeyProvider) Authenticator
func NewJWTAuthAuthenticator ¶
func NewJWTAuthAuthenticator(config cfg.Config, name string) Authenticator
func NewJWTAuthAuthenticatorWithInterfaces ¶
func NewJWTAuthAuthenticatorWithInterfaces(jwtTokenHandler JwtTokenHandler) Authenticator
func NewTokenBearerAuthenticator ¶
func NewTokenBearerAuthenticator(config cfg.Config, logger log.Logger, provider TokenBearerProvider) Authenticator
func NewTokenBearerAuthenticatorWithInterfaces ¶
func NewTokenBearerAuthenticatorWithInterfaces(logger log.Logger, keyHeader string, tokenHeader string, provider TokenBearerProvider) Authenticator
func NewUncheckedKeyAuthenticator ¶
func NewUncheckedKeyAuthenticator(_ cfg.Config, logger log.Logger, provider ApiKeyProvider) Authenticator
func NewUncheckedKeyAuthenticatorWithInterfaces ¶
func NewUncheckedKeyAuthenticatorWithInterfaces(logger log.Logger, provider ApiKeyProvider) Authenticator
type Claims ¶ added in v0.21.3
type Claims interface { jwt.Claims GetStandardClaims() jwt.StandardClaims SetStandardClaims(standardClaims jwt.StandardClaims) }
type Getter ¶
A Getter retrieves a value from the store by the given key. If the value does not exist, false is returned and value is not modified. value should be a pointer to the model you want to retrieve.
type GoogleTokenProvider ¶
type GoogleTokenProvider struct {
// contains filtered or unexported fields
}
func (*GoogleTokenProvider) GetTokenInfo ¶
func (p *GoogleTokenProvider) GetTokenInfo(idToken string) (*oauth2.Tokeninfo, error)
type InvalidBearerErr ¶
type InvalidBearerErr struct {
Message string
}
func (InvalidBearerErr) As ¶
func (i InvalidBearerErr) As(target interface{}) bool
func (InvalidBearerErr) Error ¶
func (i InvalidBearerErr) Error() string
type InvalidTokenErr ¶
type InvalidTokenErr struct{}
func (InvalidTokenErr) As ¶
func (i InvalidTokenErr) As(target interface{}) bool
func (InvalidTokenErr) Error ¶
func (i InvalidTokenErr) Error() string
func (InvalidTokenErr) Is ¶
func (i InvalidTokenErr) Is(err error) bool
type JwtClaims ¶
type JwtClaims struct { Name string `json:"name"` Email string `json:"email"` Image string `json:"image"` jwt.StandardClaims }
func (*JwtClaims) GetStandardClaims ¶ added in v0.21.3
func (c *JwtClaims) GetStandardClaims() jwt.StandardClaims
func (*JwtClaims) SetStandardClaims ¶ added in v0.21.3
func (c *JwtClaims) SetStandardClaims(standardClaims jwt.StandardClaims)
type JwtTokenHandler ¶
type JwtTokenHandler interface { Sign(user SignUserInput) (*string, error) SignClaims(claims Claims) (*string, error) Valid(jwtToken string) (bool, *jwt.Token, error) }
func NewJwtTokenHandler ¶
func NewJwtTokenHandler(config cfg.Config, name string) JwtTokenHandler
func NewJwtTokenHandlerWithInterfaces ¶
func NewJwtTokenHandlerWithInterfaces(settings JwtTokenHandlerSettings) JwtTokenHandler
type JwtTokenHandlerSettings ¶
type ModelProvider ¶
type ModelProvider func() TokenBearer
type Settings ¶ added in v0.21.3
type Settings struct {
AllowedAuthenticators []string `cfg:"allowedAuthenticators"`
}
type SignUserInput ¶
type Subject ¶
type Subject struct { Name string Anonymous bool AuthenticatedBy string Attributes map[string]interface{} }
func GetSubject ¶
type TokenBearer ¶
type TokenBearer interface {
GetToken() string
}
type TokenBearerProvider ¶
func ProvideTokenBearerFromDdb ¶
func ProvideTokenBearerFromDdb(repo ddb.Repository, getModel ModelProvider) TokenBearerProvider
func ProvideTokenBearerFromGetter ¶
func ProvideTokenBearerFromGetter(getter Getter, getModel ModelProvider) TokenBearerProvider
type TokenInfoProvider ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.