Documentation ¶
Index ¶
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 ¶
var ErrTokenRevoked = fmt.Errorf("ErrTokenRevoked")
ErrTokenRevoked is returned when trying to refresh a revoked token
var ErrTokenUnset = fmt.Errorf("ErrTokenUnset")
ErrTokenUnset is returned when no oatuh access token was found in the config file
Functions ¶
This section is empty.
Types ¶
type ConfigProvider ¶
type ConfigProvider struct { *ProviderBasis Client v1auth.OpsClientInterface OAuthClientID string Session conf.SessionInterface }
ConfigProvider provides a oauth access token from the config file. For the default file location please see TokenFilename().
func NewConfigProvider ¶
func NewConfigProvider(client v1auth.OpsClientInterface, oauthClientID string, session conf.SessionInterface) *ConfigProvider
NewConfigProvider creates a new ConfigProvider provider.
func (*ConfigProvider) Retrieve ¶
func (e *ConfigProvider) Retrieve() (string, error)
Retrieve retrieves the token from the nerd config file.
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.