oauth

package
v0.0.0-...-9592e8f Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2019 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileCache

type FileCache struct {
	// contains filtered or unexported fields
}

FileCache handles caching oauth2 tokens.

func NewFileCache

func NewFileCache(cacheDir string) *FileCache

NewFileCache creates a new instance.

func (*FileCache) Delete

func (c *FileCache) Delete(token Tokens) error

Delete the tokens file.

func (*FileCache) Get

func (c *FileCache) Get() (Tokens, error)

Get will return the oauth token from cache.

func (*FileCache) Put

func (c *FileCache) Put(token Tokens) error

Put writes an oauth token to cache.

type KeychainCache

type KeychainCache struct {
	// contains filtered or unexported fields
}

KeychainCache handles caching oauth2 tokens in the keychain.

func NewKeychainCache

func NewKeychainCache(keychain *secrets.Keychain) *KeychainCache

NewKeychainCache creates a new keychain cache.

func (KeychainCache) Delete

func (k KeychainCache) Delete(token Tokens) error

Delete deletes the tokens from the keychain.

func (KeychainCache) Get

func (k KeychainCache) Get() (Tokens, error)

Get gets the tokens from the keychain.

func (KeychainCache) Put

func (k KeychainCache) Put(token Tokens) error

Put puts the tokens in the keychain.

type TokenCache

type TokenCache interface {
	Get() (Tokens, error)
	Put(token Tokens) error
	Delete(token Tokens) error
}

TokenCache defines the interface for token caches.

type Tokens

type Tokens struct {
	AccessToken  string    `yaml:"access_token"`
	RefreshToken string    `yaml:"refresh_token"`
	IDToken      string    `yaml:"id_token"`
	Expiry       time.Time `yaml:"expiry"`
}

Tokens type

func (*Tokens) HasExpired

func (c *Tokens) HasExpired() bool

HasExpired checks if the token has expired.

func (*Tokens) Validate

func (c *Tokens) Validate() error

Validate the OAuth token file.

type TokensRefresher

type TokensRefresher interface {
	// refreshOAuthTokens refreshes the oauth tokens, and saves them to file.
	RefreshOAuthTokens(refreshToken string) (Tokens, error)
}

TokensRefresher interface

type TokensResolver

type TokensResolver struct {
	// contains filtered or unexported fields
}

TokensResolver struct

func NewTokensResolver

func NewTokensResolver(tokensCache TokenCache, tokensRefresher TokensRefresher) *TokensResolver

NewTokensResolver creates a new tokens resolver.

func (*TokensResolver) GetTokens

func (r *TokensResolver) GetTokens() (Tokens, error)

GetTokens gets the tokens, refreshing if needed.

Jump to

Keyboard shortcuts

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