Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // The API server address, this should correspond exactly to value of the // audience specified during token exchanges. Server string `json:"server" yaml:"server" env:"STORMFORGE_SERVER" envDefault:"https://api.stormforge.io/"` // The API authorization server address, this should correspond exactly to // the expected issuer claim of the tokens being used. Issuer string `json:"issuer,omitempty" yaml:"issuer,omitempty" env:"STORMFORGE_ISSUER" envDefault:"https://api.stormforge.io/"` // The client ID used to obtain tokens via a client credentials grant. ClientID string `json:"client_id,omitempty" yaml:"client_id,omitempty" env:"STORMFORGE_CLIENT_ID"` // The client secret used to obtain tokens via a client credentials grant. ClientSecret string `json:"client_secret,omitempty" yaml:"client_secret,omitempty" env:"STORMFORGE_CLIENT_SECRET"` // The list of scopes to request during token exchanges. Scopes []string `json:"scopes,omitempty" yaml:"scopes,omitempty"` // Additional parameters to be included with the token request. AuthorizationParams url.Values `json:"params,omitempty" yaml:"params,omitempty"` // A hard-coded bearer token for debugging, the token will not be refreshed // so the caller is responsible for providing a valid token. Token string `json:"token,omitempty" yaml:"token,omitempty" env:"STORMFORGE_TOKEN"` // be invoked on a sample of errors if they are occurring rapidly. UnauthorizedFunc func(error) `json:"-" yaml:"-"` }
Config is a simple top level configuration object for client configuration.
func (*Config) Address ¶ added in v0.1.0
Address returns the API server address. The canonical value will be slash-terminated, however it is not guaranteed and callers are responsible for sanitizing the value.
func (*Config) TokenSource ¶ added in v0.1.0
func (cfg *Config) TokenSource(ctx context.Context) oauth2.TokenSource
TokenSource returns a new source for obtaining tokens. The token source may be nil if there is insufficient configuration available, typically this would indicate the API server does not require authorization.
Note that token source instances typically cache tokens and are safe for concurrent use; therefore it is STRONGLY recommended that this function only be called once during the lifetime of a program.
func (*Config) Transport ¶ added in v0.1.0
func (cfg *Config) Transport(tokenSource oauth2.TokenSource, base http.RoundTripper) http.RoundTripper
Transport wraps the supplied round tripper based on the current state of the configuration.