oauth

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2018 License: Apache-2.0 Imports: 6 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

This section is empty.

Types

type ConfigProvider

type ConfigProvider struct {
	*ProviderBasis
	Client            v1auth.OpsClientInterface
	OAuthClientID     string
	OAuthClientSecret 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, oauthClientSecret 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.

Jump to

Keyboard shortcuts

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