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
- func TokenFilename() (string, error)
- type AuthAPI
- type ChainProvider
- type Config
- type Env
- type ProviderBasis
Constants ¶
const DefaultExpireWindow = 20
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 ¶
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 (*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 ¶
func (c *ChainProvider) 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 {
*ProviderBasis
}
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)
type Env ¶
type Env struct {
*ProviderBasis
}
Env provides nerdalize credentials from the `credentials.NerdTokenEnvVar` environment variable.
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.