auth

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: May 15, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Authentication was attempted and failed (likely due to incorrect credentials, too
	// many retries within a time window, etc). Distinctly different from authentication
	// errors (e.g. network errors, configuration errors, etc).
	AuthenticationFailed = errors.New("authentication failed")
)
View Source
var (
	// No login provider name has been specified in a context.Context
	NoLoginProviderName = errors.New("missing login provider name in context")
)

Functions

func Login

func Login(ctx context.Context, handler callback.Handler) error

Main client entrypoint into the authentication APIs: clients are expected to invoke this func with a context containing a login provider name value. This may be written as:

providerName := ...  // the user has probably configured this via some flag
handler := ...  // handlers provide data like usernames and passwords
ctx := ...  // obtain some initial or timed context
err := auth.Login(auth.WithLoginProvider(ctx, providerName), handler)

func LoginProvider

func LoginProvider(ctx context.Context) string

Return the name of the login provider specified in this context, or empty string if none.

func LoginProviderFrom

func LoginProviderFrom(ctx context.Context) (name string, ok bool)

Return the name of the login provider specified in this context.

func ParentUPID

func ParentUPID(ctx context.Context) (upid *upid.UPID)

func ParentUPIDFrom

func ParentUPIDFrom(ctx context.Context) (pid upid.UPID, ok bool)

func RegisterAuthenticateeProvider

func RegisterAuthenticateeProvider(name string, auth Authenticatee) (err error)

Register an authentication provider (aka "login provider"). packages that provide Authenticatee implementations should invoke this func in their init() to register.

func Timeout

func Timeout(ctx context.Context) (d time.Duration)

func TimeoutFrom

func TimeoutFrom(ctx context.Context) (d time.Duration, ok bool)

func WithLoginProvider

func WithLoginProvider(ctx context.Context, providerName string) context.Context

Return a context that inherits all values from the parent ctx and specifies the login provider name given here. Intended to be invoked before calls to Login().

func WithParentUPID

func WithParentUPID(ctx context.Context, pid upid.UPID) context.Context

func WithTimeout

func WithTimeout(ctx context.Context, d time.Duration) context.Context

Types

type Authenticatee

type Authenticatee interface {
	// Returns no errors if successfully authenticated, otherwise a single
	// error.
	Authenticate(ctx context.Context, handler callback.Handler) error
}

SPI interface: login provider implementations support this interface, clients do not authenticate against this directly, instead they should use Login()

type AuthenticateeFunc

type AuthenticateeFunc func(ctx context.Context, handler callback.Handler) error

Func adapter for interface: allow func's to implement the Authenticatee interface as long as the func signature matches

func (AuthenticateeFunc) Authenticate

func (f AuthenticateeFunc) Authenticate(ctx context.Context, handler callback.Handler) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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