clients

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

This package is a fork from the Community STACKIT Go Client

See: https://github.com/SchwarzIT/community-stackit-go-client

Index

Constants

View Source
const (
	// Service Account Key Flow
	// Auth flow env variables
	ServiceAccountKey     = "STACKIT_SERVICE_ACCOUNT_KEY"
	PrivateKey            = "STACKIT_PRIVATE_KEY"
	ServiceAccountKeyPath = "STACKIT_SERVICE_ACCOUNT_KEY_PATH"
	PrivateKeyPath        = "STACKIT_PRIVATE_KEY_PATH"
)
View Source
const (
	DefaultClientTimeout = time.Minute
)
View Source
const (
	FederatedTokenFileEnv = "STACKIT_FEDERATED_TOKEN_FILE" //nolint:gosec // This is not a secret, just the env variable name

)
View Source
const (
	// Service Account Token Flow
	// Auth flow env variables
	ServiceAccountToken = "STACKIT_SERVICE_ACCOUNT_TOKEN"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthFlow added in v0.21.0

type AuthFlow interface {
	RoundTrip(req *http.Request) (*http.Response, error)
	GetAccessToken() (string, error)
	// contains filtered or unexported methods
}

type KeyFlow

type KeyFlow struct {
	// contains filtered or unexported fields
}

KeyFlow handles auth with SA key

func (*KeyFlow) GetAccessToken

func (c *KeyFlow) GetAccessToken() (string, error)

GetAccessToken returns a short-lived access token and saves the access and refresh tokens in the token field

func (*KeyFlow) GetConfig

func (c *KeyFlow) GetConfig() KeyFlowConfig

GetConfig returns the flow configuration

func (*KeyFlow) GetServiceAccountEmail

func (c *KeyFlow) GetServiceAccountEmail() string

GetServiceAccountEmail returns the service account email

func (*KeyFlow) GetToken deprecated

func (c *KeyFlow) GetToken() TokenResponseBody

GetToken returns the token field

Deprecated: Use GetAccessToken instead. This will be removed after 2026-07-01.

func (*KeyFlow) Init

func (c *KeyFlow) Init(cfg *KeyFlowConfig) error

func (*KeyFlow) RoundTrip

func (c *KeyFlow) RoundTrip(req *http.Request) (*http.Response, error)

Roundtrip performs the request

func (*KeyFlow) SetToken deprecated

func (c *KeyFlow) SetToken(accessToken, refreshToken string) error

SetToken can be used to set an access and refresh token manually in the client. The other fields in the token field are determined by inspecting the token or setting default values.

Deprecated: This method will be removed in future versions. Access tokens are going to be automatically managed by the client. This will be removed after 2026-07-01.

type KeyFlowConfig

type KeyFlowConfig struct {
	ServiceAccountKey *ServiceAccountKeyResponse
	PrivateKey        string
	// Deprecated: retry options were removed to reduce complexity of the client. If this functionality is needed, you can provide your own custom HTTP client.
	ClientRetry                   *RetryConfig
	TokenUrl                      string
	BackgroundTokenRefreshContext context.Context // Functionality is enabled if this isn't nil
	HTTPTransport                 http.RoundTripper
	AuthHTTPClient                *http.Client
}

KeyFlowConfig is the flow config

type NoAuthFlow

type NoAuthFlow struct {
	// contains filtered or unexported fields
}

func (*NoAuthFlow) GetConfig

func (c *NoAuthFlow) GetConfig() NoAuthFlowConfig

GetConfig returns the flow configuration

func (*NoAuthFlow) Init

func (c *NoAuthFlow) Init(cfg NoAuthFlowConfig) error

func (*NoAuthFlow) RoundTrip

func (c *NoAuthFlow) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip performs the request

type NoAuthFlowConfig

type NoAuthFlowConfig struct {
	// Deprecated: retry options were removed to reduce complexity of the client. If this functionality is needed, you can provide your own custom HTTP client.
	ClientRetry   *RetryConfig
	HTTPTransport http.RoundTripper
}

NoAuthFlowConfig holds the configuration for the unauthenticated flow

type RetryConfig deprecated

type RetryConfig struct {
	MaxRetries       int           // Max retries
	WaitBetweenCalls time.Duration // Time to wait between requests
	RetryTimeout     time.Duration // Max time to re-try
	ClientTimeout    time.Duration // HTTP Client timeout
}

Deprecated: retry options were removed to reduce complexity of the client. If this functionality is needed, you can provide your own custom HTTP client.

func NewRetryConfig deprecated

func NewRetryConfig() *RetryConfig

Deprecated: retry options were removed to reduce complexity of the client. If this functionality is needed, you can provide your own custom HTTP client.

type ServiceAccountKeyCredentials

type ServiceAccountKeyCredentials struct {
	Aud        string    `json:"aud"`
	Iss        string    `json:"iss"`
	Kid        string    `json:"kid"`
	PrivateKey *string   `json:"privateKey,omitempty"`
	Sub        uuid.UUID `json:"sub"`
}

type ServiceAccountKeyResponse

type ServiceAccountKeyResponse struct {
	Active       bool                          `json:"active"`
	CreatedAt    time.Time                     `json:"createdAt"`
	Credentials  *ServiceAccountKeyCredentials `json:"credentials"`
	ID           uuid.UUID                     `json:"id"`
	KeyAlgorithm string                        `json:"keyAlgorithm"`
	KeyOrigin    string                        `json:"keyOrigin"`
	KeyType      string                        `json:"keyType"`
	PublicKey    string                        `json:"publicKey"`
	ValidUntil   *time.Time                    `json:"validUntil,omitempty"`
}

ServiceAccountKeyResponse is the API response when creating a new SA key

type TokenFlow

type TokenFlow struct {
	// contains filtered or unexported fields
}

TokenFlow handles auth with SA static token

func (*TokenFlow) GetConfig

func (c *TokenFlow) GetConfig() TokenFlowConfig

GetConfig returns the flow configuration

func (*TokenFlow) Init

func (c *TokenFlow) Init(cfg *TokenFlowConfig) error

func (*TokenFlow) RoundTrip

func (c *TokenFlow) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip performs the request

type TokenFlowConfig

type TokenFlowConfig struct {
	// Deprecated: ServiceAccountEmail is not required and will be removed after 12th June 2025.
	ServiceAccountEmail string
	ServiceAccountToken string
	// Deprecated: retry options were removed to reduce complexity of the client. If this functionality is needed, you can provide your own custom HTTP client.
	ClientRetry   *RetryConfig
	HTTPTransport http.RoundTripper
}

TokenFlowConfig is the flow config

type TokenResponseBody

type TokenResponseBody struct {
	AccessToken string `json:"access_token"`
	ExpiresIn   int    `json:"expires_in"`
	// Deprecated: RefreshToken is no longer used and the SDK will not attempt to refresh tokens using it but will instead use the AuthFlow implementation to get new tokens.
	// This will be removed after 2026-07-01.
	RefreshToken string `json:"refresh_token"`
	Scope        string `json:"scope"`
	TokenType    string `json:"token_type"`
}

TokenResponseBody is the API response when requesting a new token

type WorkloadIdentityFederationFlow added in v0.21.0

type WorkloadIdentityFederationFlow struct {
	// contains filtered or unexported fields
}

WorkloadIdentityFlow handles auth with Workload Identity Federation

func (*WorkloadIdentityFederationFlow) GetAccessToken added in v0.21.0

func (c *WorkloadIdentityFederationFlow) GetAccessToken() (string, error)

GetAccessToken implements AuthFlow.

func (*WorkloadIdentityFederationFlow) GetConfig added in v0.21.0

GetConfig returns the flow configuration

func (*WorkloadIdentityFederationFlow) Init added in v0.21.0

func (*WorkloadIdentityFederationFlow) RoundTrip added in v0.21.0

RoundTrip implements the http.RoundTripper interface. It gets a token, adds it to the request's authorization header, and performs the request.

type WorkloadIdentityFederationFlowConfig added in v0.21.0

type WorkloadIdentityFederationFlowConfig struct {
	TokenUrl                      string
	ClientID                      string
	TokenExpiration               string          // Not supported yet
	BackgroundTokenRefreshContext context.Context // Functionality is enabled if this isn't nil
	HTTPTransport                 http.RoundTripper
	AuthHTTPClient                *http.Client
	FederatedTokenFunction        oidcadapters.OIDCTokenFunc // Function to get the federated token
}

KeyFlowConfig is the flow config

Jump to

Keyboard shortcuts

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