apikeymapper

package
v0.0.0-...-85a8e8d Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// APIKeyHeader is HTTP header name to be used for auth
	APIKeyHeader = "X-DC-AUTH"
)
View Source
const ProviderName = "apikey"

ProviderName is identifier for role mapper provider

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// HeaderName is HTTP header
	HeaderName string `json:"header" yaml:"header"`
	// KeysMap is a map of key to Identity
	KeysMap map[string]Identity `json:"keys" yaml:"keys"`
}

Config provides mapping of API Keys to Roles

func LoadConfig

func LoadConfig(file string) (*Config, error)

LoadConfig returns configuration loaded from a file

type Identity

type Identity struct {
	// Name of identity
	Name string `json:"name" yaml:"name"`
	// Role of identity
	Role string `json:"role" yaml:"role"`
}

Identity of the caller

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider of API Key identity

func Load

func Load(cfgfile string) (*Provider, error)

Load returns new Provider

func New

func New(cfg *Config) *Provider

New returns new Provider

func (*Provider) Applicable

func (p *Provider) Applicable(r *http.Request) bool

Applicable returns true if the request has autherization data applicable to the provider

func (*Provider) HTTPHeaderName

func (p *Provider) HTTPHeaderName() string

HTTPHeaderName returns name of HTTP header to be used in auth

func (*Provider) IdentityMapper

func (p *Provider) IdentityMapper(r *http.Request) (identity.Identity, error)

IdentityMapper interface

Jump to

Keyboard shortcuts

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