rkmidauth

package
v2.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package rkmidauth provide auth related options

Index

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

func WithApiKeyAuth(key ...string) Option

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

func WithBasicAuth(realm string, cred ...string) Option

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

func WithEntryNameAndType(entryName, entryType string) Option

WithEntryNameAndType provide entry name and entry type.

func WithMockOptionSet

func WithMockOptionSet(mock OptionSetInterface) Option

WithMockOptionSet provide mock OptionSetInterface

func WithPathToIgnore

func WithPathToIgnore(paths ...string) Option

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

Jump to

Keyboard shortcuts

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