Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAuthenticator ¶
func NewAuthenticator(provider TokenProvider) auth.Authenticator
NewAuthenticator creates an authenticator from a token provider
Types ¶
type CachedTokenProvider ¶
type CachedTokenProvider struct {
// RefreshThreshold determines when to refresh (default 5 minutes before expiry)
RefreshThreshold time.Duration
// contains filtered or unexported fields
}
CachedTokenProvider wraps another provider and caches tokens
func NewCachedTokenProvider ¶
func NewCachedTokenProvider(provider TokenProvider) *CachedTokenProvider
NewCachedTokenProvider creates a caching wrapper around any token provider
func (*CachedTokenProvider) ClearCache ¶
func (p *CachedTokenProvider) ClearCache()
ClearCache clears the cached token
func (*CachedTokenProvider) GetToken ¶
func (p *CachedTokenProvider) GetToken(ctx context.Context) (*Token, error)
GetToken retrieves a token, using cache if available and valid
func (*CachedTokenProvider) Name ¶
func (p *CachedTokenProvider) Name() string
Name returns the provider name
type ExternalTokenProvider ¶
type ExternalTokenProvider struct {
// contains filtered or unexported fields
}
ExternalTokenProvider provides tokens from an external source (passthrough). This provider calls a user-supplied function to retrieve tokens on-demand.
func NewExternalTokenProvider ¶
func NewExternalTokenProvider(tokenSource func() (string, error)) *ExternalTokenProvider
NewExternalTokenProvider creates a provider that gets tokens from an external function
func NewExternalTokenProviderWithType ¶
func NewExternalTokenProviderWithType(tokenSource func() (string, error), tokenType string) *ExternalTokenProvider
NewExternalTokenProviderWithType creates a provider with a custom token type
func (*ExternalTokenProvider) GetToken ¶
func (p *ExternalTokenProvider) GetToken(ctx context.Context) (*Token, error)
GetToken retrieves the token from the external source
func (*ExternalTokenProvider) Name ¶
func (p *ExternalTokenProvider) Name() string
Name returns the provider name
type FederationProvider ¶
type FederationProvider struct {
// contains filtered or unexported fields
}
FederationProvider wraps another token provider and automatically handles token exchange
func NewFederationProvider ¶
func NewFederationProvider(baseProvider TokenProvider, databricksHost string) *FederationProvider
NewFederationProvider creates a federation provider that wraps another provider It automatically detects when token exchange is needed and falls back gracefully
func NewFederationProviderWithClientID ¶
func NewFederationProviderWithClientID(baseProvider TokenProvider, databricksHost, clientID string) *FederationProvider
NewFederationProviderWithClientID creates a provider for SP-wide federation (M2M)
func (*FederationProvider) GetToken ¶
func (p *FederationProvider) GetToken(ctx context.Context) (*Token, error)
GetToken gets token from base provider and exchanges if needed
func (*FederationProvider) Name ¶
func (p *FederationProvider) Name() string
Name returns the provider name
type StaticTokenProvider ¶
type StaticTokenProvider struct {
// contains filtered or unexported fields
}
StaticTokenProvider provides a static token that never changes
func NewStaticTokenProvider ¶
func NewStaticTokenProvider(token string) *StaticTokenProvider
NewStaticTokenProvider creates a provider with a static token
func NewStaticTokenProviderWithType ¶
func NewStaticTokenProviderWithType(token string, tokenType string) *StaticTokenProvider
NewStaticTokenProviderWithType creates a provider with a static token and custom type
func (*StaticTokenProvider) GetToken ¶
func (p *StaticTokenProvider) GetToken(ctx context.Context) (*Token, error)
GetToken returns the static token
func (*StaticTokenProvider) Name ¶
func (p *StaticTokenProvider) Name() string
Name returns the provider name
type Token ¶
type Token struct {
AccessToken string
TokenType string
ExpiresAt time.Time
RefreshToken string
Scopes []string
}
Token represents an access token with metadata
func (*Token) SetAuthHeader ¶
SetAuthHeader sets the Authorization header on an HTTP request
type TokenProvider ¶
type TokenProvider interface {
// GetToken retrieves a valid access token
GetToken(ctx context.Context) (*Token, error)
// Name returns the provider name for logging/debugging
Name() string
}
TokenProvider is the interface for providing tokens from various sources
type TokenProviderAuthenticator ¶
type TokenProviderAuthenticator struct {
// contains filtered or unexported fields
}
TokenProviderAuthenticator implements auth.Authenticator using a TokenProvider.
Authentication Flow: 1. On each Authenticate() call, retrieves a token from the configured TokenProvider 2. The provider may implement its own caching and refresh logic 3. Validates the returned token is non-empty 4. Sets the Authorization header with the token type and value
The authenticator delegates all token management (caching, refresh, expiry) to the underlying TokenProvider implementation.
func (*TokenProviderAuthenticator) Authenticate ¶
func (a *TokenProviderAuthenticator) Authenticate(r *http.Request) error
Authenticate implements auth.Authenticator