cloud

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package cloud provides the interfaces and manager for cloud providers

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")
)
View Source
var (
	// ContextKeyAuthToken is used by authorization providers to mark the token in a context
	ContextKeyAuthToken = ContextKey("auth-token")
)

Functions

func RegisterProvider added in v1.2.0

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 Attributes added in v1.2.0

type Attributes = sparks.Params

Attributes is an alias for sparks.Params

type AuthToken added in v1.2.0

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

	// Retunrs a context from the token
	Context(context.Context) context.Context
}

AuthToken is a driver interface for parsing and using JWT values

func AuthTokenFromContext added in v1.4.7

func AuthTokenFromContext(c context.Context) AuthToken

AuthTokenFromContext returns the cloud authtoken from the context

type Claims added in v1.2.0

type Claims = Params

Claims is an alias from Params (types.StringMap)

type ContextKey

type ContextKey string

ContextKey defines a static context key

func (ContextKey) String

func (c ContextKey) String() string

type NewFunc added in v1.2.0

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 added in v1.2.0

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

ObjectProvider provides an object store

type ObjectStore added in v1.2.0

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

	// GetObjectURL returns a secure url to the object
	GetObjectURL(key string, timeout time.Duration, write ...bool) (string, error)

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

	// DeleteObject deletes and object
	DeleteObject(key string, params ...Params) error

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

ObjectStore is an interface for kv object stores implemented by providers

type Params added in v1.2.0

type Params = sparks.Params

Params is an alias for sparks.Params

type Provider added in v1.2.0

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

func OpenProvider added in v1.2.0

func OpenProvider(name string, params Params) (Provider, error)

OpenProvider opens a new cloud provider instance with the specified parameters

type Queue added in v1.2.0

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 added in v1.2.0

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

QueueProvider defines a queue provider interface

type TokenValidationError added in v1.2.0

type TokenValidationError error

type User added in v1.2.0

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

type UserPool added in v1.2.0

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, options ...Params) (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
}

UserPool is an interface implemented by providers that support users

type UserProvider added in v1.2.0

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

Directories

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

Jump to

Keyboard shortcuts

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