Documentation ¶
Index ¶
- Variables
- func Login(ctx context.Context, handler callback.Handler) error
- func LoginProvider(ctx context.Context) string
- func LoginProviderFrom(ctx context.Context) (name string, ok bool)
- func ParentUPID(ctx context.Context) (upid *upid.UPID)
- func ParentUPIDFrom(ctx context.Context) (pid upid.UPID, ok bool)
- func RegisterAuthenticateeProvider(name string, auth Authenticatee) (err error)
- func Timeout(ctx context.Context) (d time.Duration)
- func TimeoutFrom(ctx context.Context) (d time.Duration, ok bool)
- func WithLoginProvider(ctx context.Context, providerName string) context.Context
- func WithParentUPID(ctx context.Context, pid upid.UPID) context.Context
- func WithTimeout(ctx context.Context, d time.Duration) context.Context
- type Authenticatee
- type AuthenticateeFunc
Constants ¶
This section is empty.
Variables ¶
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") )
var ( // No login provider name has been specified in a context.Context NoLoginProviderName = errors.New("missing login provider name in context") )
Functions ¶
func Login ¶
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 ¶
Return the name of the login provider specified in this context, or empty string if none.
func LoginProviderFrom ¶
Return the name of the login provider specified in this context.
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 WithLoginProvider ¶
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().
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 ¶
Func adapter for interface: allow func's to implement the Authenticatee interface as long as the func signature matches