auth

package
v1.3.3-0...-f31c912 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessTokenProvider

type AccessTokenProvider interface {
	GetAccessToken() (string, error)
}

AccessTokenProvider provides a method to get the bearer token for use when authorizing to a 3rd-party provider API.

type RotatedAccessTokenProvider

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

RotatedAccessTokenProvider is an implementation of AccessTokenProvider that uses OAuth2 refresh token flow to renew the acess token. The credentials are stored in the given persistent store.

To have an up-to-date token, one must run RefreshLoop() in a background goroutine.

func NewRotatedTokenProvider

NewRotatedTokenProvider creates a new RotatedAccessTokenProvider from the given config. NewRotatedTokenProvider will return an error if the store does not have existing credentials, meaning they need to be acquired first (e.g. via OAuth2 authorization code flow).

func (*RotatedAccessTokenProvider) GetAccessToken

func (r *RotatedAccessTokenProvider) GetAccessToken() (string, error)

GetAccessToken implements AccessTokenProvider()

func (*RotatedAccessTokenProvider) RefreshLoop

func (r *RotatedAccessTokenProvider) RefreshLoop(ctx context.Context)

RefreshLoop runs the credential refresh process.

type RotatedAccessTokenProviderConfig

type RotatedAccessTokenProviderConfig struct {
	RetryInterval       time.Duration
	TokenBufferInterval time.Duration

	Store     storage.Store
	Refresher oauth.Refresher
	Clock     clockwork.Clock

	Log *logrus.Entry
}

RotatedAccessTokenProviderConfig contains parameters and dependencies for RotatedAccessTokenProvider

func (*RotatedAccessTokenProviderConfig) CheckAndSetDefaults

func (c *RotatedAccessTokenProviderConfig) CheckAndSetDefaults() error

CheckAndSetDefaults validates a configuration and sets default values

type StaticAccessTokenProvider

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

StaticAccessTokenProvider is an implementation of AccessTokenProvider that always returns the specified token.

func NewStaticAccessTokenProvider

func NewStaticAccessTokenProvider(token string) *StaticAccessTokenProvider

NewStaticAccessTokenProvider creates a new StaticAccessTokenProvider.

func (*StaticAccessTokenProvider) GetAccessToken

func (s *StaticAccessTokenProvider) GetAccessToken() (string, error)

GetAccessToken implements AccessTokenProvider

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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