authenticator

package
v0.0.0-...-9154c2c Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RealIP

func RealIP(forwardIPs string) string

func RealIPFromRequest

func RealIPFromRequest(r *http.Request) string

func Register

func Register(name string, factory FactoryFunc)

func WithCredentials

func WithCredentials(ctx context.Context, credentials Credentials) context.Context

WithCredentials creates a child context containing in it the `Credentials` object.

Types

type AnonymousCredentials

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

func (*AnonymousCredentials) GetLogFields

func (c *AnonymousCredentials) GetLogFields() []zap.Field

func (*AnonymousCredentials) GetUserID

func (c *AnonymousCredentials) GetUserID() string

type Authenticator

type Authenticator interface {
	IsAuthenticationTokenRequired() bool
	Check(ctx context.Context, token, ipAddress string) (context.Context, error)
}

func New

func New(config string) (Authenticator, error)

type Credentials

type Credentials interface {
	GetLogFields() []zap.Field
	GetUserID() string
}

func GetCredentials

func GetCredentials(ctx context.Context) Credentials

GetCredentials extracts `Credentials` object from context if it exists, returning it if present and `nil` if not found.

type FactoryFunc

type FactoryFunc func(config string) (Authenticator, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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