authclient

package
v1.43.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2022 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AuthServiceError = errs.Class("auth service")

AuthServiceError wraps all the errors returned when resolving an access key.

Functions

This section is empty.

Types

type AuthClient

type AuthClient struct {
	Config
	// Cache is used for caching authservice's responses.
	Cache *lrucache.ExpiringLRU
}

AuthClient communicates with the Auth Service.

func New

func New(config Config) *AuthClient

New returns a new auth client.

func (*AuthClient) GetHealthLive

func (a *AuthClient) GetHealthLive(ctx context.Context) (_ bool, err error)

GetHealthLive returns the auth service health live status.

func (*AuthClient) Resolve added in v1.17.0

func (a *AuthClient) Resolve(ctx context.Context, accessKeyID string, clientIP string) (_ AuthServiceResponse, err error)

Resolve maps an access key into an auth service response. clientIP is the IP of the client that originated the request and it's required to be sent to the Auth Service.

func (*AuthClient) ResolveWithCache added in v1.17.0

func (a *AuthClient) ResolveWithCache(ctx context.Context, accessKeyID string, clientIP string) (_ AuthServiceResponse, err error)

ResolveWithCache is like Resolve, but it uses the underlying LRU cache to cache and returns cached authservice's successful responses if caching is enabled.

type AuthServiceCacheConfig added in v1.17.0

type AuthServiceCacheConfig struct {
	Expiration time.Duration `user:"true" help:"how long to keep cached access grants in cache" default:"24h"`
	Capacity   int           `user:"true" help:"how many cached access grants to keep in cache" default:"10000"`
}

AuthServiceCacheConfig describes configuration necessary to cache the results of auth service lookups.

type AuthServiceResponse added in v1.17.0

type AuthServiceResponse struct {
	AccessGrant string `json:"access_grant"`
	SecretKey   string `json:"secret_key"`
	Public      bool   `json:"public"`
}

AuthServiceResponse is the struct representing the response from the auth service.

type Config added in v1.17.0

type Config struct {
	BaseURL string        `user:"true" help:"base url to use for resolving access key ids" releaseDefault:"" devDefault:"http://localhost:20000"`
	Token   string        `user:"true" help:"auth token for giving access to the auth service" releaseDefault:"" devDefault:"super-secret"`
	Timeout time.Duration `user:"true" help:"how long to wait for a single auth service connection" default:"10s"`
	BackOff backoff.ExponentialBackoff
	Cache   AuthServiceCacheConfig
}

Config describes configuration necessary to interact with the auth service.

func (Config) Validate added in v1.17.0

func (a Config) Validate() error

Validate checks if the configuration value are valid.

Jump to

Keyboard shortcuts

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