auth

package
v1.3.13 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

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

type AuthProviderInvalidator func(ctx context.Context)

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 NewManager(ctx context.Context, opts *Inputs) (*Manager, error)

func (*Manager) GetAuth added in v1.3.12

func (r *Manager) GetAuth(
	ctx context.Context,
	newerThan time.Time,
) (*AuthSnapshot, error)

GetAuth returns a token and effective environment from the same credential snapshot, refreshing both atomically when the token goes stale.

func (*Manager) GetConfig added in v1.2.97

func (r *Manager) GetConfig() *config.Manager

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.

Jump to

Keyboard shortcuts

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