auth

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2021 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnauthenticated = errors.New("unauthenticated")

ErrUnauthenticated defines the basic unauthenticated error.

Functions

func Errorf

func Errorf(message string, args ...interface{}) error

Errorf indicates ErrUnauthenticated with a custom message.

func Register

func Register(name string, factory Factory)

Register registers a new factory by name. It will panic if multiple factories are registered under the same name.

func WrapError

func WrapError(err error) error

WrapError indicates ErrUnauthenticated and wraps an internal error.

Types

type Factory

type Factory func(*riposo.Helpers) (Method, error)

Factory initializes a Method at runtime.

func Get

func Get(name string) (Factory, error)

Get returns a factory by name. Returns an error if not found.

type Method

type Method interface {
	// Authenticate parses an API request and returns a user. If a user cannot authenticated it must
	// return an ErrUnauthenticated compatible error.
	Authenticate(*http.Request) (*api.User, error)

	// Close may release all resources held by the Method implementation.
	Close() error
}

Method implementations are responsible for authenticating users from HTTP requests.

func Basic

func Basic() Method

Basic inits a HTTP basic auth Method.

func OneOf

func OneOf(multiple ...Method) Method

OneOf adds support for multi-method authentication.

Jump to

Keyboard shortcuts

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