rkmidauth

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2022 License: Apache-2.0 Imports: 8 Imported by: 4

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.ErrorResp
	}
}

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"`
	IgnorePrefix []string `yaml:"ignorePrefix" json:"ignorePrefix"`
	Basic        []string `yaml:"basic" json:"basic"`
	ApiKey       []string `yaml:"apiKey" json:"apiKey"`
}

BootConfig for YAML

type Option

type Option func(*optionSet)

Option

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 WithIgnorePrefix

func WithIgnorePrefix(paths ...string) Option

WithIgnorePrefix provide paths prefix that will ignore. Mainly used for swagger main page and RK TV entry.

func WithMockOptionSet

func WithMockOptionSet(mock OptionSetInterface) Option

WithMockOptionSet provide mock OptionSetInterface

type OptionSetInterface

type OptionSetInterface interface {
	GetEntryName() string

	GetEntryType() string

	Before(*BeforeCtx)

	BeforeCtx(*http.Request) *BeforeCtx
}

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