Documentation
¶
Index ¶
- func GetClaimsFromToken(ctx context.Context) (jwt.MapClaims, error)
- func GetStringFromToken(ctx context.Context, key string) (string, error)
- func GetValueFromToken(ctx context.Context, key string) (any, error)
- func HasACL(ctx context.Context, acl string) (bool, error)
- func HasACLs(ctx context.Context, acls []string) (bool, error)
- func Middleware(opts ...MiddlewareFunc) func(http.Handler) http.Handler
- func MustHasACL(ctx context.Context, acl string) bool
- func MustHasACLs(ctx context.Context, acls []string) bool
- func NeedACL(acl string, func401 func(http.ResponseWriter, *http.Request)) func(http.Handler) http.Handler
- func NeedACLs(acls []string, func401 func(http.ResponseWriter, *http.Request)) func(http.Handler) http.Handler
- func RegisterBearerValidationOperation(n string, o func(*ValidationOperation, any) (bool, error)) func(dm *Doorman)
- func WithMiddlewareUseDoorman(dm *Doorman) func() *Doorman
- func WithMiddlewareUseGlobalDoorman() func() *Doorman
- func WithNewAsGlobalDefault(force bool) func(dm *Doorman) error
- func WithNewAuthenticatorConfigs(configs []*AuthenticatorConfig) func(dm *Doorman) error
- func WithNewHashAlgorithm(name string, f HasherFunc) func(dm *Doorman) error
- func WithNewLogger(l Logger) func(epp *Doorman) error
- func WithNewRegisterAuthenticator(name string, authenticator RegisterAuthenticatorFunc) func(dm *Doorman) error
- type Authenticator
- func NewBasicAuthAuthenticator(cfg *AuthenticatorConfig) (authenticator Authenticator, err error)
- func NewBearerAuthenticator(cfg *AuthenticatorConfig) (authenticator Authenticator, err error)
- func NewHttpHeaderAuthenticator(cfg *AuthenticatorConfig) (authenticator Authenticator, err error)
- func NewIPAddressAuthenticator(cfg *AuthenticatorConfig) (authenticator Authenticator, err error)
- type AuthenticatorConfig
- type AuthenticatorInfo
- type BasicAuthAuthenticator
- type BasicAuthAuthenticatorInfo
- type BasicAuthCredential
- type BearerAuthenticator
- type BearerAuthenticatorInfo
- type BearerKeyManager
- type ClaimValidation
- type ClaimsValidationGroup
- type Doorman
- type HasherFunc
- type HttpHeader
- type HttpHeaderAuthenticator
- type HttpHeaderAuthenticatorInfo
- type IPAddressAuthenticator
- type IPAddressAuthenticatorInfo
- type Info
- type JwksUrlResponse
- type Logger
- type MiddlewareFunc
- type NewFunc
- type NullLogger
- type RegisterAuthenticatorFunc
- type TokenKeyAliases
- type ValidationOperation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Middleware ¶
func Middleware(opts ...MiddlewareFunc) func(http.Handler) http.Handler
func WithMiddlewareUseGlobalDoorman ¶
func WithMiddlewareUseGlobalDoorman() func() *Doorman
func WithNewAsGlobalDefault ¶
func WithNewAuthenticatorConfigs ¶
func WithNewAuthenticatorConfigs(configs []*AuthenticatorConfig) func(dm *Doorman) error
func WithNewHashAlgorithm ¶
func WithNewHashAlgorithm(name string, f HasherFunc) func(dm *Doorman) error
func WithNewLogger ¶
func WithNewRegisterAuthenticator ¶
func WithNewRegisterAuthenticator(name string, authenticator RegisterAuthenticatorFunc) func(dm *Doorman) error
Types ¶
type Authenticator ¶
type Authenticator interface {
GetName() string
GetType() string
GetACLs() []string
Evaluate(r *http.Request) (AuthenticatorInfo, error)
}
func NewBasicAuthAuthenticator ¶
func NewBasicAuthAuthenticator(cfg *AuthenticatorConfig) (authenticator Authenticator, err error)
func NewBearerAuthenticator ¶
func NewBearerAuthenticator(cfg *AuthenticatorConfig) (authenticator Authenticator, err error)
NewBearerAuthenticator initialize
func NewHttpHeaderAuthenticator ¶
func NewHttpHeaderAuthenticator(cfg *AuthenticatorConfig) (authenticator Authenticator, err error)
NewHttpHeaderAuthenticator initialize
func NewIPAddressAuthenticator ¶
func NewIPAddressAuthenticator(cfg *AuthenticatorConfig) (authenticator Authenticator, err error)
NewIPAddressAuthenticator initialize
type AuthenticatorConfig ¶
type AuthenticatorInfo ¶
type BasicAuthAuthenticator ¶
type BasicAuthAuthenticator struct {
Name string `mapstructure:"name"`
Type string `mapstructure:"type"`
ACLs []string `mapstructure:"acls"`
Credentials []BasicAuthCredential `mapstructure:"credentials"`
// contains filtered or unexported fields
}
func (*BasicAuthAuthenticator) Evaluate ¶
func (a *BasicAuthAuthenticator) Evaluate(r *http.Request) (AuthenticatorInfo, error)
func (*BasicAuthAuthenticator) GetACLs ¶
func (a *BasicAuthAuthenticator) GetACLs() []string
func (*BasicAuthAuthenticator) GetName ¶
func (a *BasicAuthAuthenticator) GetName() string
GetName returns protector name
func (*BasicAuthAuthenticator) GetType ¶
func (a *BasicAuthAuthenticator) GetType() string
type BasicAuthAuthenticatorInfo ¶
type BasicAuthAuthenticatorInfo struct {
Authenticator *BasicAuthAuthenticator
Username string
}
func (BasicAuthAuthenticatorInfo) GetName ¶
func (i BasicAuthAuthenticatorInfo) GetName() string
func (BasicAuthAuthenticatorInfo) GetType ¶
func (i BasicAuthAuthenticatorInfo) GetType() string
type BasicAuthCredential ¶
type BearerAuthenticator ¶
type BearerAuthenticator struct {
Name string `mapstructure:"name"`
Type string `mapstructure:"type"`
ACLs []string `mapstructure:"acls"`
MetaUrl string `mapstructure:"meta_url"`
JwksUrl string `mapstructure:"jwks_url"`
KeysFetchInterval time.Duration `mapstructure:"keys_fetch_interval"`
// _
ClaimsValidationGroups []*ClaimsValidationGroup `mapstructure:"claims_validation_groups"`
// _
ClaimsValidations []ClaimValidation `mapstructure:"claims_validations"`
TokenKeyAliases TokenKeyAliases `mapstructure:"token_key_aliases"`
TokenMapACLs []string `mapstructure:"token_map_acls"`
// contains filtered or unexported fields
}
func (*BearerAuthenticator) Evaluate ¶
func (a *BearerAuthenticator) Evaluate(r *http.Request) (AuthenticatorInfo, error)
func (*BearerAuthenticator) GetACLs ¶
func (a *BearerAuthenticator) GetACLs() []string
func (*BearerAuthenticator) GetName ¶
func (a *BearerAuthenticator) GetName() string
func (*BearerAuthenticator) GetType ¶
func (a *BearerAuthenticator) GetType() string
type BearerAuthenticatorInfo ¶
type BearerAuthenticatorInfo struct {
Authenticator *BearerAuthenticator
TokenClaims jwt.MapClaims
Token *jwt.Token
// contains filtered or unexported fields
}
func (*BearerAuthenticatorInfo) GetName ¶
func (i *BearerAuthenticatorInfo) GetName() string
func (*BearerAuthenticatorInfo) GetStringFromToken ¶
func (i *BearerAuthenticatorInfo) GetStringFromToken(key string) string
func (*BearerAuthenticatorInfo) GetType ¶
func (i *BearerAuthenticatorInfo) GetType() string
func (*BearerAuthenticatorInfo) GetValueFromToken ¶
func (i *BearerAuthenticatorInfo) GetValueFromToken(key string) any
type BearerKeyManager ¶
type BearerKeyManager struct {
// contains filtered or unexported fields
}
func NewBearerKeyManager ¶
type ClaimValidation ¶
type ClaimValidation struct {
Key string `mapstructure:"key"`
IsOptional bool `mapstructure:"optional"`
ValidationOperation *ValidationOperation `mapstructure:"validation"`
DynamicACLS []string `mapstructure:"dynamic_acls"`
}
type ClaimsValidationGroup ¶
type ClaimsValidationGroup struct {
ClaimsValidations []ClaimValidation `mapstructure:"claims_validations"`
TokenKeyAliases TokenKeyAliases `mapstructure:"token_key_aliases"`
TokenMapACLs []string `mapstructure:"token_map_acls"`
}
type HasherFunc ¶
type HttpHeader ¶
type HttpHeaderAuthenticator ¶
type HttpHeaderAuthenticator struct {
Name string `mapstructure:"name"`
Type string `mapstructure:"type"`
ACLs []string `mapstructure:"acls"`
Headers []HttpHeader `mapstructure:"headers"`
// contains filtered or unexported fields
}
func (*HttpHeaderAuthenticator) Evaluate ¶
func (a *HttpHeaderAuthenticator) Evaluate(r *http.Request) (AuthenticatorInfo, error)
func (*HttpHeaderAuthenticator) GetACLs ¶
func (a *HttpHeaderAuthenticator) GetACLs() []string
func (*HttpHeaderAuthenticator) GetName ¶
func (a *HttpHeaderAuthenticator) GetName() string
func (*HttpHeaderAuthenticator) GetType ¶
func (a *HttpHeaderAuthenticator) GetType() string
type HttpHeaderAuthenticatorInfo ¶
type HttpHeaderAuthenticatorInfo struct {
Authenticator *HttpHeaderAuthenticator
CapturedHeaders map[string]string
}
func (*HttpHeaderAuthenticatorInfo) GetName ¶
func (i *HttpHeaderAuthenticatorInfo) GetName() string
func (*HttpHeaderAuthenticatorInfo) GetType ¶
func (i *HttpHeaderAuthenticatorInfo) GetType() string
type IPAddressAuthenticator ¶
type IPAddressAuthenticator struct {
Name string `mapstructure:"name"`
Type string `mapstructure:"type"`
ACLs []string `mapstructure:"acls"`
Addresses []string `mapstructure:"addresses"`
// contains filtered or unexported fields
}
func (*IPAddressAuthenticator) Evaluate ¶
func (a *IPAddressAuthenticator) Evaluate(r *http.Request) (pi AuthenticatorInfo, err error)
func (*IPAddressAuthenticator) GetACLs ¶
func (a *IPAddressAuthenticator) GetACLs() []string
func (*IPAddressAuthenticator) GetName ¶
func (a *IPAddressAuthenticator) GetName() string
func (*IPAddressAuthenticator) GetType ¶
func (a *IPAddressAuthenticator) GetType() string
type IPAddressAuthenticatorInfo ¶
type IPAddressAuthenticatorInfo struct {
Authenticator *IPAddressAuthenticator
ClientIP net.IP
MatchedAddress *net.IPNet
}
func (IPAddressAuthenticatorInfo) GetName ¶
func (i IPAddressAuthenticatorInfo) GetName() string
func (IPAddressAuthenticatorInfo) GetType ¶
func (i IPAddressAuthenticatorInfo) GetType() string
type Info ¶
type Info struct {
Infos []AuthenticatorInfo
ACLs map[string]struct{}
}
type JwksUrlResponse ¶
type JwksUrlResponse struct {
Keys []bearerSignKey `json:"keys"`
}
type MiddlewareFunc ¶
type MiddlewareFunc func() *Doorman
type NullLogger ¶
type NullLogger struct{}
func (NullLogger) Debug ¶
func (NullLogger) Debug(string, ...any)
func (NullLogger) Error ¶
func (NullLogger) Error(string, ...any)
func (NullLogger) Info ¶
func (NullLogger) Info(string, ...any)
type RegisterAuthenticatorFunc ¶
type RegisterAuthenticatorFunc func(*AuthenticatorConfig) (Authenticator, error)
type TokenKeyAliases ¶
type ValidationOperation ¶
Click to show internal directories.
Click to hide internal directories.