tokenstore

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound         = errors.New("auth token not found")
	AUTH_TOKEN_KEY_NAME = "commonfate_provider_registry"
)

Functions

This section is empty.

Types

type NotifyRefreshTokenSource

type NotifyRefreshTokenSource struct {
	New oauth2.TokenSource

	T         *oauth2.Token
	SaveToken TokenNotifyFunc // called when token refreshed so new refresh token can be persisted
	// contains filtered or unexported fields
}

NotifyRefreshTokenSource is essentially `oauth2.ResuseTokenSource` with `TokenNotifyFunc` added.

func (*NotifyRefreshTokenSource) Token

func (s *NotifyRefreshTokenSource) Token() (*oauth2.Token, error)

Token returns the current token if it's still valid, else will refresh the current token (using r.Context for HTTP client information) and return the new one.

type Storage

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

func New

func New() Storage

New creates a new token storage driver.

func (*Storage) Clear

func (s *Storage) Clear() error

Clear the token

func (*Storage) Save

func (s *Storage) Save(token *oauth2.Token) error

Save the token

func (*Storage) Token

func (s *Storage) Token() (*oauth2.Token, error)

Token returns the OAuth2.0 token. It meets the TokenSource interface in the oauth2 package.

type TokenNotifyFunc

type TokenNotifyFunc func(*oauth2.Token) error

TokenNotifyFunc is a function that accepts an oauth2 Token upon refresh, and returns an error if it should not be used.

Jump to

Keyboard shortcuts

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