Documentation
¶
Overview ¶
Package auth provides token providers and an authenticated HTTP client wrapper for the QuantumBPM SDK. ClientCredentialsTokenProvider fetches tokens from any OIDC provider and StaticTokenProvider supplies a fixed bearer token. Implement TokenProvider to plug in any other token source.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewClient ¶
func NewClient(baseURL string, provider TokenProvider) (*generated.ClientWithResponses, error)
NewClient returns a generated.ClientWithResponses that injects a Bearer token from the supplied TokenProvider into every request.
Types ¶
type ClientCredentials ¶
type ClientCredentials struct {
// TokenURL is the identity provider's OAuth 2.0 token endpoint. Required.
TokenURL string
// ClientID identifies the client at the identity provider. Required.
ClientID string
// ClientSecret authenticates the client. Required.
ClientSecret string
// Scopes are sent space-joined as the scope parameter. Empty sends none.
Scopes []string
// Audience is sent as the audience parameter when set. Some providers,
// such as Auth0, require it.
Audience string
// HTTPClient sends the token requests. Defaults to http.DefaultClient.
HTTPClient *http.Client
}
ClientCredentials configures a ClientCredentialsTokenProvider.
type ClientCredentialsTokenProvider ¶
type ClientCredentialsTokenProvider struct {
// contains filtered or unexported fields
}
ClientCredentialsTokenProvider fetches access tokens from any OIDC provider with the OAuth 2.0 client credentials grant. The token is cached and replaced once less than 60 seconds of its lifetime remain. It is safe for concurrent use.
func NewClientCredentialsTokenProvider ¶
func NewClientCredentialsTokenProvider(cfg ClientCredentials) *ClientCredentialsTokenProvider
NewClientCredentialsTokenProvider builds a provider from cfg. A missing TokenURL, ClientID or ClientSecret is reported by Token.
type StaticTokenProvider ¶
type StaticTokenProvider struct {
// contains filtered or unexported fields
}
StaticTokenProvider returns the same bearer token on every call. Use it for Enterprise deployments that issue long-lived API keys, or in tests where a pre-acquired token is supplied directly.
func NewStaticTokenProvider ¶
func NewStaticTokenProvider(token string) *StaticTokenProvider
NewStaticTokenProvider wraps token in a TokenProvider.
type TokenProvider ¶
TokenProvider returns a valid access token for the next request. The provider is invoked on every request and is responsible for caching.