provider

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const DefaultExpireWindow = 20
View Source
const NerdTokenPermissions = 0644

Variables

This section is empty.

Functions

func NewChainCredentials

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

func NewConfigCredentials

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

func NewEnvCredentials

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

NewEnvCredentials creates new nerdalize credentials with the env provider.

func TokenFilename

func TokenFilename() (string, error)

Types

type AuthAPI

type AuthAPI struct {
	*ProviderBasis

	Client           *client.AuthAPIClient
	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

func (*AuthAPI) Retrieve

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

type ChainProvider

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

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

func (*ChainProvider) IsExpired

func (c *ChainProvider) 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 (*ChainProvider) Retrieve

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 {
	*ProviderBasis
}

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

func NewConfig

func NewConfig() *Config

func (*Config) Retrieve

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

type Env

type Env struct {
	*ProviderBasis
}

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

func NewEnv

func NewEnv() *Env

func (*Env) Retrieve

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

type ProviderBasis

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

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

ProviderBasis is the basis for every provider.

func (*ProviderBasis) IsExpired

func (b *ProviderBasis) IsExpired() bool

IsExpired checks if the current token is expired.

func (*ProviderBasis) SetExpiration

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

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

Jump to

Keyboard shortcuts

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