auth

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: Apache-2.0 Imports: 3 Imported by: 6

Documentation

Index

Constants

View Source
const (
	// UserIDField is a key
	UserIDField keyType = iota
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorizationType

type AuthorizationType int

AuthorizationType designates a type of authorization.

const (
	// UnknownAuthorization is the unknown authorizationType case.
	UnknownAuthorization AuthorizationType = iota
	// NoAuthorization is the no authorizationType case.
	NoAuthorization
	// ReadOnlyAuthorization is the read only authorizationType case.
	ReadOnlyAuthorization
	// WriteOnlyAuthorization is the write only authorizationType case.
	WriteOnlyAuthorization
	// ReadWriteAuthorization is the read and write authorizationType case.
	ReadWriteAuthorization
)

type HTTPAuthService

type HTTPAuthService interface {
	// NewAuthHandler should return a handler that performs some check on the request coming into the given handler
	// and then runs the handler if it is. If the request passes authentication/authorization successfully, it should call SetUser
	// to make the callers id available to the service in a global context. errHandler should be passed in to properly format the
	// the error and respond the the request in the event of bad auth.
	NewAuthHandler(authType AuthorizationType, next http.Handler, errHandler errorResponseHandler) http.Handler

	// SetUser sets a userID that identifies the api caller in the global context.
	SetUser(parent context.Context, userID string) context.Context

	// GetUser fetches the ID of an api caller from the global context.
	GetUser(ctx context.Context) (string, error)
}

HTTPAuthService defines how to handle requests for various http authentication and authorization methods.

func NewNoopAuth

func NewNoopAuth() HTTPAuthService

NewNoopAuth creates a new noop auth instance.

type SimpleAuthConfig

type SimpleAuthConfig struct {
	Authentication authenticationConfig `yaml:"authentication"`
	Authorization  authorizationConfig  `yaml:"authorization"`
}

SimpleAuthConfig holds this configuration necessary for a simple auth implementation.

func (SimpleAuthConfig) NewSimpleAuth

func (ac SimpleAuthConfig) NewSimpleAuth() HTTPAuthService

NewSimpleAuth creates a new simple auth instance given using the provided config.

Jump to

Keyboard shortcuts

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