Documentation
¶
Overview ¶
Package auth is an internal package that provides authentication utilities.
IMPORTANT: This package is not meant to be used directly by consumers of the SDK and is subject to change without notice.
Package auth is an internal package that provides authentication utilities.
IMPORTANT: This package is not meant to be used directly by consumers of the SDK and is subject to change without notice.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Credentials ¶ added in v0.80.0
Credentials is anything that can return authentication headers.
type CredentialsFn ¶ added in v0.80.0
CredentialsFn is an adapter to allow the use of ordinary functions as Credentials.
Example:
creds := CredentialsFn(func(ctx context.Context) (map[string]string, error) {
return map[string]string{"Authorization": "Bearer " + token}, nil
})
func (CredentialsFn) AuthHeaders ¶ added in v0.80.0
type OAuthCredentials ¶ added in v0.80.0
type OAuthCredentials interface {
Credentials
TokenSource
}
OAuthCredentials is a Credentials and TokenSource that can be used to authenticate with OAuth.
type Option ¶
type Option func(*cachedTokenSource)
func WithAsyncRefresh ¶
WithAsyncRefresh enables or disables the asynchronous token refresh.
func WithCachedToken ¶
WithCachedToken sets the initial token to be used by a cached token source.
type TokenSource ¶ added in v0.58.0
type TokenSource interface {
// Token returns a token or an error. Token must be safe for concurrent use
// by multiple goroutines. The returned Token must not be modified.
Token(context.Context) (*oauth2.Token, error)
}
A TokenSource is anything that can return a token.
func NewCachedTokenSource ¶
func NewCachedTokenSource(ts TokenSource, opts ...Option) TokenSource
NewCachedTokenProvider wraps a TokenSource to cache the tokens it returns. By default, the cache will refresh tokens asynchronously a few minutes before they expire.
The token cache is safe for concurrent use by multiple goroutines and will guarantee that only one token refresh is triggered at a time.
The token cache does not take care of retries in case the token source returns and error; it is the responsibility of the provided token source to handle retries appropriately.
If the TokenSource is already a cached token source (obtained by calling this function), it is returned as is.
type TokenSourceFn ¶ added in v0.58.0
TokenSourceFn is an adapter to allow the use of ordinary functions as TokenSource.
Example:
ts := TokenSourceFn(func(ctx context.Context) (*oauth2.Token, error) {
return &oauth2.Token{}, nil
})
Directories
¶
| Path | Synopsis |
|---|---|
|
Package dataplane is an experimental package that provides a token source to directly access Databricks data plane.
|
Package dataplane is an experimental package that provides a token source to directly access Databricks data plane. |
|
Package oidc provides utilities for working with OIDC ID tokens.
|
Package oidc provides utilities for working with OIDC ID tokens. |