provider

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

providers should use the cloud package

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserPoolNotFound = errors.New("user pool not found")

	ErrUserNotFound = errors.New("user not found")

	ErrUserExists = errors.New("user with that username exists")

	ErrUserDisabled = errors.New("user disabled")

	ErrPasswordExpired = errors.New("password expired")

	ErrTokenRequired = TokenValidationError(errors.New("token required"))

	ErrTokenMismatch = TokenValidationError(errors.New("token mismatch"))

	ErrInvalidClient = TokenValidationError(errors.New("invalid auth client"))

	ErrInvalidToken = TokenValidationError(errors.New("invalid token"))

	ErrAccessDenied = TokenValidationError(errors.New("invalid scope"))

	ErrStoreNotFound = errors.New("store not found")

	ErrObjectNotFound = errors.New("object not found")
)

Functions

This section is empty.

Types

type Attributes

type Attributes = sparks.Params

type AuthToken

type AuthToken interface {
	// ID returns the token identifier
	ID() string

	// ClientID returns the OAuth client identity
	ClientID() string

	// Username() returns the user for the token or empty if no user is associated
	Username() string

	// ExpiresAt returns the token expiration time
	ExpiresAt() int64

	// Scope returns the scopes the token has
	Scope() []string

	// Returns the token use, i.e. access, identity, etc.
	Use() string

	// Claims returns the token claims
	Claims() Claims

	// String returns the string value of the token as a signed JWT
	String() string
}

AuthToken is a driver interface for parsing and using JWT values

type Claims

type Claims = Params

type NewFunc

type NewFunc func(params Params) (Provider, error)

NewFunc is a function registered with the cloud layer for creating a new instance of the provider.

type ObjectProvider

type ObjectProvider interface {
	// OpenObjectStore store returns an object store with the given name and parameter
	OpenObjectStore(name string, params Params) (ObjectStore, error)
}

type ObjectStore

type ObjectStore interface {
	// GetObject returns an io.Reader that allows for getting the object data
	GetObject(key string, params ...Params) (io.Reader, error)

	// PutObject set the value
	PutObject(key string, r io.Reader, params ...Params) error

	// DeleteObject deletes and object
	DeleteObject(key string) error

	// Name returns the object store name
	Name() string
}

ObjectStore is an interface for kv object stores implemented by providers

type Params

type Params = sparks.Params

type Provider

type Provider interface {
	// ProxyHTTP handles incoming cloud events, proxying them to the virtual http.Handler
	ProxyHTTP(http.Handler) error

	// Close is called to cleanup the provider
	Close()
}

Provider is an interface that must be implemented by cloud providers

type Queue

type Queue interface {
	// Publish publishes the message body with optioanl attributes and return the id
	Publish(body []byte, attributes ...Attributes) (string, error)
}

Queue defines a queue interface

type QueueProvider

type QueueProvider interface {
	OpenQueue(name string, params Params) (Queue, error)
}

QueueProvider defines a queue provider interface

type TokenValidationError

type TokenValidationError error

type User

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

	// Attributes returns a map of user attributes
	Attributes() map[string]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

type UserPool

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

	// AuthorizeToken takes the signed JWT string, parses and validates it returning an AuthToken
	AuthorizeToken(token string, scopes ...[]string) (AuthToken, error)

	// CreateUser creates a new user
	CreateUser(username, password string, attributes map[string]string) (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 map[string]string) error

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

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

UserPool is an interface implemented by providers that support users

type UserProvider

type UserProvider interface {
	// OpenUserPool returns a user pool with the given name and parameters
	OpenUserPool(name string, params Params) (UserPool, error)
}

UserProvider is an interface for getting a UserPool from the provider

Jump to

Keyboard shortcuts

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