auth

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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.

func (*ClientCredentialsTokenProvider) Token

Token returns the cached access token while more than 60 seconds of its lifetime remain, otherwise it requests a new one from the token endpoint.

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.

func (*StaticTokenProvider) Token

type TokenProvider

type TokenProvider interface {
	Token(ctx context.Context) (string, error)
}

TokenProvider returns a valid access token for the next request. The provider is invoked on every request and is responsible for caching.

type TokenProviderFunc

type TokenProviderFunc func(ctx context.Context) (string, error)

TokenProviderFunc adapts a plain function to the TokenProvider interface.

func (TokenProviderFunc) Token

func (f TokenProviderFunc) Token(ctx context.Context) (string, error)

Jump to

Keyboard shortcuts

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