auth

package
v2.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package auth provides the interface and registry for authentication providers

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUserPoolNotFound is returned when a user pool does not exist
	ErrUserPoolNotFound = errors.New("user pool not found")

	// ErrUserNotFound is returned when a user does not exist
	ErrUserNotFound = errors.New("user not found")

	// ErrUserExists is returned when a user exists and there is a conflict
	ErrUserExists = errors.New("user with that username exists")

	// ErrUserDisabled is returned when a user is disabled
	ErrUserDisabled = errors.New("user disabled")

	// ErrPasswordExpired is returned when a user's password is expired
	ErrPasswordExpired = errors.New("password expired")
)

Functions

func RegisterProvider

func RegisterProvider(name string, provider NewFunc)

RegisterProvider makes a database provider available by the provided name. If RegisterProvider is called twice with the same name or if provider is nil, it panics.

Types

type NewFunc

type NewFunc func(name string, params types.StringMap) (Provider, error)

NewFunc intializes the provider

type Provider

type Provider interface {
	// AuthenticateUser authenticates the user and returns an AuthToken
	AuthenticateUser(username, password string) (keychain.AuthToken, error)

	// CreateUser creates a new user
	CreateUser(username, password string, attributes map[string]string, options ...types.StringMap) (User, error)

	// ChangeUserPassword attempts to change the users password from current to the proposed
	ChangeUserPassword(username, current, proposed string) error

	// GetUser returns a user
	GetUser(username string) (User, error)

	// UpdateUser updates a users attributes
	UpdateUser(username string, attributes types.StringMap) error

	// DeleteUser deletes a user record
	DeleteUser(username string) error

	// DisableUser disables a user account
	DisableUser(username string) error
}

Provider is an interface for user providers

func MustOpen

func MustOpen(uri string) Provider

MustOpen will panic on fail

func Open

func Open(uri string) (Provider, error)

Open opens a new auth provider

type User

type User interface {
	// Login returns the user login i.e. username
	Login() string

	// Attributes returns a map of user attributes
	Attributes() types.StringMap

	// Status returns the user status as a string
	Status() string

	// Enabled represents the user's status
	Enabled() bool

	// Groups returns a list of groups the user belongs to
	Groups() []string
}

User is a common user interface

Directories

Path Synopsis
Package keychain manages the validation and processing of jwt/oauth tokens
Package keychain manages the validation and processing of jwt/oauth tokens
providers

Jump to

Keyboard shortcuts

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