Documentation
¶
Index ¶
- type AuthProvider
- type AuthProviderInvalidator
- type AuthSnapshot
- type Inputs
- type Manager
- func (r *Manager) GetAuth(ctx context.Context, newerThan time.Time) (*AuthSnapshot, error)
- func (r *Manager) GetConfig() *config.Manager
- func (r *Manager) GetJWT(ctx context.Context, newerThan time.Time) (*serverv1.GetTokenResponse, error)
- func (r *Manager) RefreshAuthAfterRejection(ctx context.Context, rejected *AuthSnapshot, newerThan time.Time) (*AuthSnapshot, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthProvider ¶ added in v1.3.12
type AuthProvider func(ctx context.Context) (*AuthSnapshot, error)
AuthProvider returns a currently-valid authentication snapshot. It is called whenever the cached token goes stale, in place of the client-credentials exchange. Token and EnvironmentID must be resolved atomically from the same credential state. Implementations must not call back into the client that owns this Manager; they are invoked while its lock is held.
type AuthProviderInvalidator ¶ added in v1.3.13
AuthProviderInvalidator clears any cache in front of an AuthProvider. It is called before refreshing a credential that the server rejected, even when the credential's expiry says it is still valid.
type AuthSnapshot ¶ added in v1.3.12
type AuthSnapshot struct {
Token *serverv1.GetTokenResponse
EnvironmentID string
}
AuthSnapshot is the bearer token and effective environment that must be sent together on an authenticated request.
type Inputs ¶ added in v1.2.94
type Inputs struct {
// Token is a pre-issued JWT to authenticate with, instead of exchanging client
// credentials
Token *serverv1.GetTokenResponse
// AuthProvider supplies a token and effective environment whenever the cached
// token goes stale, instead of running the client-credentials exchange.
// Sufficient on its own -- the first snapshot is obtained from it if Token is
// unset. See AuthProvider.
AuthProvider AuthProvider
// AuthProviderInvalidator clears any cache owned by AuthProvider before a
// forced refresh following an authentication rejection.
AuthProviderInvalidator AuthProviderInvalidator
// HttpClient is used as the underlying http.client. Connect provides an interface for abstracting over the
// standard library version of the auth client
HttpClient connect.HTTPClient
// Manager holds the credentials for this client to use. Non-optional.
Config *config.Manager
Timeout *time.Duration
// SkipEnvironmentNameMapping controls whether to skip validating and mapping
// environment names to IDs. If true, the EnvironmentId will be used verbatim.
SkipEnvironmentNameMapping bool
// SkipEngineMapping controls whether to skip setting the query server based
// on the token's engine maps. If true, the query server will not be
// automatically resolved from the token.
SkipEngineMapping bool
}
type Manager ¶ added in v1.2.94
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶ added in v1.2.94
func (*Manager) GetAuth ¶ added in v1.3.12
GetAuth returns a token and effective environment from the same credential snapshot, refreshing both atomically when the token goes stale.
func (*Manager) GetJWT ¶ added in v1.2.94
func (r *Manager) GetJWT( ctx context.Context, newerThan time.Time, ) (*serverv1.GetTokenResponse, error)
GetJWT is a token-only convenience wrapper. Authenticated request paths should use GetAuth so the token cannot be paired with a stale environment.
func (*Manager) RefreshAuthAfterRejection ¶ added in v1.3.13
func (r *Manager) RefreshAuthAfterRejection( ctx context.Context, rejected *AuthSnapshot, newerThan time.Time, ) (*AuthSnapshot, error)
RefreshAuthAfterRejection refreshes a credential that an authenticated request sent and the server rejected. If another caller has already replaced rejected with a sufficiently fresh snapshot, that snapshot is reused.