provider

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2017 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultExpireWindow = 20

DefaultExpireWindow is the default amount of seconds that a nerd token is assumed to be expired, before it's actually expired. This will prevent the server from declining the token because it was just expired.

Variables

This section is empty.

Functions

func NewChainCredentials

func NewChainCredentials(pub *ecdsa.PublicKey, providers ...credentials.Provider) *credentials.NerdAPI

NewChainCredentials creates a new NerdAPI credentials object with the ChainProvider as provider.

func NewConfigCredentials

func NewConfigCredentials(pub *ecdsa.PublicKey) *credentials.NerdAPI

NewConfigCredentials creates a new NerdAPI credentials object with the Config provider as provider.

func NewEnvCredentials

func NewEnvCredentials(pub *ecdsa.PublicKey) *credentials.NerdAPI

NewEnvCredentials creates new nerdalize credentials with the env provider.

Types

type AuthAPI

type AuthAPI struct {
	*Basis

	Client *client.AuthAPIClient
	//UserPassProvider is a function that provides the AuthAPI provider with a username and password. This could for example be a function
	//that reads from stdin.
	UserPassProvider func() (string, string, error)
}

AuthAPI provides nerdalize credentials by making a request to the nerdalize auth server. The UserPassProvider is used to retreive the username and password required to authenticate with the auth server.

func NewAuthAPI

func NewAuthAPI(userPassProvider func() (string, string, error), c *client.AuthAPIClient) *AuthAPI

NewAuthAPI creates a new AuthAPI provider.

func (*AuthAPI) Retrieve

func (p *AuthAPI) Retrieve(pub *ecdsa.PublicKey) (*credentials.NerdAPIValue, error)

Retrieve retrieves the token from the authentication server.

type Basis added in v0.1.1

type Basis struct {
	CurrentTime func() time.Time
	AlwaysValid bool

	ExpireWindow time.Duration
	// contains filtered or unexported fields
}

Basis is the basis for every provider.

func (*Basis) IsExpired added in v0.1.1

func (b *Basis) IsExpired() bool

IsExpired checks if the current token is expired.

func (*Basis) SetExpiration added in v0.1.1

func (b *Basis) SetExpiration(expiration time.Time)

SetExpiration sets the expiration field and takes the ExpireWindow into account.

type Chain added in v0.1.1

type Chain struct {
	Providers []credentials.Provider
	// contains filtered or unexported fields
}

Chain provides nerdalize credentials based on multiple providers. The given providers are tried in sequential order.

func (*Chain) IsExpired added in v0.1.1

func (c *Chain) IsExpired() bool

IsExpired will returned the expired state of the currently cached provider if there is one. If there is no current provider, true will be returned.

func (*Chain) Retrieve added in v0.1.1

func (c *Chain) Retrieve(pub *ecdsa.PublicKey) (*credentials.NerdAPIValue, error)

Retrieve returns the credentials value or error if no provider returned without error.

If a provider is found it will be cached and any calls to IsExpired() will return the expired state of the cached provider.

type Config

type Config struct {
	*Basis
}

Config provides nerdalize credentials from a file on Config. The default file can be found in TokenFilename().

func NewConfig

func NewConfig() *Config

NewConfig creates a new Config provider.

func (*Config) Retrieve

func (e *Config) Retrieve(pub *ecdsa.PublicKey) (*credentials.NerdAPIValue, error)

Retrieve retrieves the token from the nerd config file.

type Env

type Env struct {
	*Basis
}

Env provides nerdalize credentials from the `credentials.NerdTokenEnvVar` environment variable.

func NewEnv

func NewEnv() *Env

NewEnv creates a new Env provider.

func (*Env) Retrieve

func (e *Env) Retrieve(pub *ecdsa.PublicKey) (*credentials.NerdAPIValue, error)

Retrieve retrieves the token from the env variable.

type UserFacingError added in v0.2.3

type UserFacingError struct {
	// contains filtered or unexported fields
}

func (UserFacingError) Error added in v0.2.3

func (e UserFacingError) Error() string

func (UserFacingError) Underlying added in v0.2.3

func (e UserFacingError) Underlying() error

func (UserFacingError) UserFacingMsg added in v0.2.3

func (e UserFacingError) UserFacingMsg() string

Jump to

Keyboard shortcuts

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