Documentation ¶
Index ¶
Constants ¶
View Source
const ( CredsFieldName = "server.http.auth.creds" TokensFieldName = "server.http.auth.tokens" HeaderNameFieldName = "server.http.auth.header_name" HeaderNameDefault = "X-Auth-Token" )
Variables ¶
View Source
var ( BasicAuthComponent = &app.Component{ Dependencies: app.Components{ logger.Component, configurator.Component, re_configuration.Component, router.Component, }, Constructor: func(container container.Container) error { return container.Provides( NewCredConfig, NewBasicReConfigurationWithConfigurator, ) }, BindFlags: func(flagSet *pflag.FlagSet, container container.Container) error { return container.Invoke(func(config *CredConfig) { flagSet.StringSliceVar(&config.Creds, CredsFieldName, nil, "pairs login:password for basic authorization via http") }) }, Run: func(c container.Container) error { basic, err := container.Get[*BasicReConfiguration](c) if err != nil { return err } router, err := container.Get[router.Router](c) if err != nil { return err } reConfiguration, err := container.Get[configurator.ReConfiguration](c) if err != nil { return err } informer, err := container.Get[logger.Informer](c) if err != nil { return err } reConfiguration.Registration(basic) informer.Info("http.client.middleware.auth.basic: registration in the reConfigurator") router.Use(basic) return nil }, } TokenAuthComponent = &app.Component{ Dependencies: app.Components{ logger.Component, configurator.Component, re_configuration.Component, router.Component, }, Constructor: func(container container.Container) error { return container.Provides( NewTokenConfig, NewTokenReConfigurationWithConfigurator, ) }, BindFlags: func(flagSet *pflag.FlagSet, container container.Container) error { return container.Invoke(func(config *TokenConfig) { flagSet.StringSliceVar(&config.Tokens, TokensFieldName, nil, "list of access tokens") flagSet.StringVar(&config.HeaderName, HeaderNameFieldName, HeaderNameDefault, "header name with token") }) }, Run: func(c container.Container) error { token, err := container.Get[*TokenReConfiguration](c) if err != nil { return err } router, err := container.Get[router.Router](c) if err != nil { return err } reConfiguration, err := container.Get[configurator.ReConfiguration](c) if err != nil { return err } informer, err := container.Get[logger.Informer](c) if err != nil { return err } reConfiguration.Registration(token) informer.Info("http.client.middleware.auth.token: registration in the reConfigurator") router.Use(token) return nil }, } )
Functions ¶
This section is empty.
Types ¶
type Basic ¶
type Basic struct {
// contains filtered or unexported fields
}
func NewBasicWithConfigurator ¶
func NewBasicWithConfigurator(config *CredConfig, configurator configurator.Configurator) *Basic
type BasicReConfiguration ¶
type BasicReConfiguration struct {
// contains filtered or unexported fields
}
func NewBasicReConfiguration ¶
func NewBasicReConfiguration(informer logger.Informer, config *CredConfig) *BasicReConfiguration
func NewBasicReConfigurationWithConfigurator ¶
func NewBasicReConfigurationWithConfigurator(informer logger.Informer, config *CredConfig, configurator configurator.Configurator) *BasicReConfiguration
func (*BasicReConfiguration) Middleware ¶
func (reConfiguration *BasicReConfiguration) Middleware(next http.Handler) http.Handler
func (*BasicReConfiguration) ReConfiguration ¶
func (reConfiguration *BasicReConfiguration) ReConfiguration(configurator configurator.Configurator) error
type CredConfig ¶
type CredConfig struct {
Creds []string `info:"secret"`
}
func BasicConfiguration ¶
func BasicConfiguration(config *CredConfig, configurator configurator.Configurator) *CredConfig
func NewCredConfig ¶
func NewCredConfig() *CredConfig
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
func NewToken ¶
func NewToken(config *TokenConfig) *Token
func NewTokenWithConfigurator ¶
func NewTokenWithConfigurator(config *TokenConfig, configurator configurator.Configurator) *Token
type TokenConfig ¶
func NewTokenConfig ¶
func NewTokenConfig() *TokenConfig
func TokenConfiguration ¶
func TokenConfiguration(config *TokenConfig, configurator configurator.Configurator) *TokenConfig
type TokenReConfiguration ¶
type TokenReConfiguration struct {
// contains filtered or unexported fields
}
func NewTokenReConfiguration ¶
func NewTokenReConfiguration(informer logger.Informer, config *TokenConfig) *TokenReConfiguration
func NewTokenReConfigurationWithConfigurator ¶
func NewTokenReConfigurationWithConfigurator(informer logger.Informer, config *TokenConfig, configurator configurator.Configurator) *TokenReConfiguration
func (*TokenReConfiguration) Middleware ¶
func (reConfiguration *TokenReConfiguration) Middleware(next http.Handler) http.Handler
func (*TokenReConfiguration) ReConfiguration ¶
func (reConfiguration *TokenReConfiguration) ReConfiguration(configurator configurator.Configurator) error
Click to show internal directories.
Click to hide internal directories.