authclient

package
v1.89.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: AGPL-3.0 Imports: 15 Imported by: 1

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
	// contains filtered or unexported fields
}

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

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

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

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

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

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

type Config

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

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