Documentation ¶
Index ¶
- Constants
- func NewChainCredentials(pub *ecdsa.PublicKey, providers ...credentials.Provider) *credentials.NerdAPI
- func NewConfigCredentials(pub *ecdsa.PublicKey) *credentials.NerdAPI
- func NewEnvCredentials(pub *ecdsa.PublicKey) *credentials.NerdAPI
- type AuthAPI
- type Basis
- type Chain
- type Config
- type Env
- type UserFacingError
Constants ¶
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 ¶
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) SetExpiration ¶ added in v0.1.1
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
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 (*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 (*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