Documentation ¶
Overview ¶
Package rkmidauth provide auth related options
Index ¶
- type BeforeCtx
- type BootConfig
- type Option
- func ToOptions(config *BootConfig, entryName, entryType string) []Option
- func WithApiKeyAuth(key ...string) Option
- func WithBasicAuth(realm string, cred ...string) Option
- func WithEntryNameAndType(entryName, entryType string) Option
- func WithMockOptionSet(mock OptionSetInterface) Option
- func WithPathToIgnore(paths ...string) Option
- type OptionSetInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BeforeCtx ¶
type BeforeCtx struct { Input struct { BasicAuthHeader string ApiKeyHeader string UrlPath string } Output struct { HeadersToReturn map[string]string ErrResp rkerror.ErrorInterface } }
BeforeCtx context for Before() function
func NewBeforeCtx ¶
func NewBeforeCtx() *BeforeCtx
NewBeforeCtx create new BeforeCtx with fields initialized
type BootConfig ¶
type BootConfig struct { Enabled bool `yaml:"enabled" json:"enabled"` Ignore []string `yaml:"ignore" json:"ignore"` Basic []string `yaml:"basic" json:"basic"` ApiKey []string `yaml:"apiKey" json:"apiKey"` }
BootConfig for YAML
type Option ¶
type Option func(*optionSet)
Option for optionSet
func ToOptions ¶
func ToOptions(config *BootConfig, entryName, entryType string) []Option
ToOptions convert BootConfig into Option list
func WithApiKeyAuth ¶
WithApiKeyAuth provide API Key auth credentials. An API key is a token that a client provides when making API calls. With API key auth, you send a key-value pair to the API either in the request headers or query parameters. Some APIs use API keys for authorization.
The API key was injected into incoming header with key of X-API-Key
func WithBasicAuth ¶
WithBasicAuth provide basic auth credentials formed as user:pass. We will encode credential with base64 since incoming credential from client would be encoded.
func WithEntryNameAndType ¶
WithEntryNameAndType provide entry name and entry type.
func WithMockOptionSet ¶
func WithMockOptionSet(mock OptionSetInterface) Option
WithMockOptionSet provide mock OptionSetInterface
func WithPathToIgnore ¶
WithPathToIgnore provide paths prefix that will ignore.
type OptionSetInterface ¶
type OptionSetInterface interface { GetEntryName() string GetEntryType() string Before(*BeforeCtx) BeforeCtx(*http.Request) *BeforeCtx ShouldIgnore(string) bool }
OptionSetInterface mainly for testing purpose
func NewOptionSet ¶
func NewOptionSet(opts ...Option) OptionSetInterface
NewOptionSet Create new optionSet with options.
func NewOptionSetMock ¶
func NewOptionSetMock(before *BeforeCtx) OptionSetInterface
NewOptionSetMock for testing purpose