zbc

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2021 License: Apache-2.0 Imports: 31 Imported by: 12

Documentation

Overview

Copyright © 2018 Camunda Services GmbH (info@camunda.com)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const CaCertificatePath = "ZEEBE_CA_CERTIFICATE_PATH"
View Source
const DefaultAddressHost = "127.0.0.1"
View Source
const DefaultAddressPort = "26500"
View Source
const DefaultKeepAlive = 45 * time.Second
View Source
const DefaultOAuthCacheFile = "credentials"
View Source
const DefaultOAuthCacheFileDir = ".camunda"
View Source
const DefaultRequestTimeout = 15 * time.Second
View Source
const ErrFileNotFound = Error("file not found")

ErrFileNotFound is returned whenever a file can't be found at the provided path. Use this value to do error comparison.

View Source
const ErrOAuthCredentialsCacheFolderIsNotDir = Error("OAuth credentials cache folder is not a directory, cannot create cache file under it")
View Source
const ErrOAuthCredentialsCacheIsDir = Error("OAuth credentials cache must be a file, not a directory")
View Source
const GatewayAddressEnvVar = "ZEEBE_ADDRESS"
View Source
const GatewayHostEnvVar = "ZEEBE_HOST"
View Source
const GatewayPortEnvVar = "ZEEBE_PORT"
View Source
const InsecureEnvVar = "ZEEBE_INSECURE_CONNECTION"
View Source
const KeepAliveEnvVar = "ZEEBE_KEEP_ALIVE"
View Source
const OAuthAuthorizationUrlEnvVar = "ZEEBE_AUTHORIZATION_SERVER_URL"
View Source
const OAuthCachePathEnvVar = "ZEEBE_CLIENT_CONFIG_PATH"
View Source
const OAuthClientIdEnvVar = "ZEEBE_CLIENT_ID"
View Source
const OAuthClientSecretEnvVar = "ZEEBE_CLIENT_SECRET"

#nosec 101

View Source
const OAuthDefaultAuthzURL = "https://login.cloud.camunda.io/oauth/token/"

OAuthDefaultAuthzURL points to the expected default URL for this credentials provider, the Camunda Cloud endpoint.

View Source
const OAuthDefaultRequestTimeout = 10 * time.Second

OAuthDefaultRequestTimeout is the default timeout for OAuth requests

View Source
const OAuthRequestTimeoutEnvVar = "ZEEBE_AUTH_REQUEST_TIMEOUT"
View Source
const OAuthTokenAudienceEnvVar = "ZEEBE_TOKEN_AUDIENCE"

#nosec 101

Variables

View Source
var DefaultOauthYamlCachePath = getDefaultOAuthYamlCredentialsCachePath()

Functions

This section is empty.

Types

type Client

type Client interface {
	NewTopologyCommand() *commands.TopologyCommand
	NewDeployProcessCommand() *commands.DeployCommand

	NewCreateInstanceCommand() commands.CreateInstanceCommandStep1
	NewCancelInstanceCommand() commands.CancelInstanceStep1
	NewSetVariablesCommand() commands.SetVariablesCommandStep1
	NewResolveIncidentCommand() commands.ResolveIncidentCommandStep1

	NewPublishMessageCommand() commands.PublishMessageCommandStep1

	NewActivateJobsCommand() commands.ActivateJobsCommandStep1
	NewCompleteJobCommand() commands.CompleteJobCommandStep1
	NewFailJobCommand() commands.FailJobCommandStep1
	NewUpdateJobRetriesCommand() commands.UpdateJobRetriesCommandStep1
	NewThrowErrorCommand() commands.ThrowErrorCommandStep1

	NewJobWorker() worker.JobWorkerBuilderStep1

	Close() error
}

func NewClient

func NewClient(config *ClientConfig) (Client, error)

type ClientConfig

type ClientConfig struct {
	GatewayAddress         string
	UsePlaintextConnection bool
	CaCertificatePath      string
	CredentialsProvider    CredentialsProvider

	// KeepAlive can be used configure how often keep alive messages should be sent to the gateway. These will be sent
	// whether or not there are active requests. Negative values will result in error and zero will result in the default
	// of 45 seconds being used
	KeepAlive time.Duration

	DialOpts []grpc.DialOption
}

type ClientImpl

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

func (*ClientImpl) Close

func (c *ClientImpl) Close() error

func (*ClientImpl) NewActivateJobsCommand

func (c *ClientImpl) NewActivateJobsCommand() commands.ActivateJobsCommandStep1

func (*ClientImpl) NewCancelInstanceCommand

func (c *ClientImpl) NewCancelInstanceCommand() commands.CancelInstanceStep1

func (*ClientImpl) NewCompleteJobCommand

func (c *ClientImpl) NewCompleteJobCommand() commands.CompleteJobCommandStep1

func (*ClientImpl) NewCreateInstanceCommand

func (c *ClientImpl) NewCreateInstanceCommand() commands.CreateInstanceCommandStep1

func (*ClientImpl) NewDeployProcessCommand

func (c *ClientImpl) NewDeployProcessCommand() *commands.DeployCommand

func (*ClientImpl) NewFailJobCommand

func (c *ClientImpl) NewFailJobCommand() commands.FailJobCommandStep1

func (*ClientImpl) NewJobWorker

func (c *ClientImpl) NewJobWorker() worker.JobWorkerBuilderStep1

func (*ClientImpl) NewPublishMessageCommand

func (c *ClientImpl) NewPublishMessageCommand() commands.PublishMessageCommandStep1

func (*ClientImpl) NewResolveIncidentCommand

func (c *ClientImpl) NewResolveIncidentCommand() commands.ResolveIncidentCommandStep1

func (*ClientImpl) NewSetVariablesCommand

func (c *ClientImpl) NewSetVariablesCommand() commands.SetVariablesCommandStep1

func (*ClientImpl) NewThrowErrorCommand

func (c *ClientImpl) NewThrowErrorCommand() commands.ThrowErrorCommandStep1

func (*ClientImpl) NewTopologyCommand

func (c *ClientImpl) NewTopologyCommand() *commands.TopologyCommand

func (*ClientImpl) NewUpdateJobRetriesCommand

func (c *ClientImpl) NewUpdateJobRetriesCommand() commands.UpdateJobRetriesCommandStep1

type CredentialsProvider

type CredentialsProvider interface {
	// Takes a map of gRPC headers as defined in credentials.PerRPCCredentials and adds credentials to them.
	ApplyCredentials(ctx context.Context, headers map[string]string) error
	// Returns true if the request should be retried, false otherwise.
	ShouldRetryRequest(ctx context.Context, err error) bool
}

CredentialsProvider is responsible for adding credentials to each gRPC call's headers.

type Error

type Error string

func (Error) Error

func (e Error) Error() string

type OAuthCredentialsCache

type OAuthCredentialsCache interface {
	// Refresh should clear and re-populate the cache from defaults
	Refresh() error
	// Get should return the cached credentials for the given audience, or nil
	Get(audience string) *oauth2.Token
	// Update should set the credentials as the cached credentials for the given audience
	Update(audience string, token *oauth2.Token) error
}

OAuthCredentialsCache is used to cache results of fetching OAuth credentials

func NewOAuthYamlCredentialsCache

func NewOAuthYamlCredentialsCache(path string) (OAuthCredentialsCache, error)

type OAuthCredentialsProvider

type OAuthCredentialsProvider struct {
	Audience    string
	TokenConfig *clientcredentials.Config
	Cache       OAuthCredentialsCache
	// contains filtered or unexported fields
}

OAuthCredentialsProvider is a built-in CredentialsProvider that contains credentials obtained from an OAuth authorization server, including a token prefix and an access token. Using these values it sets the 'Authorization' header of each gRPC call.

func NewOAuthCredentialsProvider

func NewOAuthCredentialsProvider(config *OAuthProviderConfig) (*OAuthCredentialsProvider, error)

NewOAuthCredentialsProvider requests credentials from an authorization server and uses them to create an OAuthCredentialsProvider.

func (*OAuthCredentialsProvider) ApplyCredentials

func (p *OAuthCredentialsProvider) ApplyCredentials(ctx context.Context, headers map[string]string) error

ApplyCredentials takes a map of headers as input and adds an access token prefixed by a token type to the 'Authorization' header of a gRPC call.

func (*OAuthCredentialsProvider) ShouldRetryRequest

func (p *OAuthCredentialsProvider) ShouldRetryRequest(ctx context.Context, err error) bool

ShouldRetryRequest checks if the error is UNAUTHENTICATED and, if so, attempts to refresh the access token. If the new credentials are different from the stored ones, returns true. If the credentials are the same, returns false.

type OAuthProviderConfig

type OAuthProviderConfig struct {
	// The client identifier used to request an access token. Can be overridden with the environment variable 'ZEEBE_CLIENT_ID'.
	ClientID string
	// The client secret used to request an access token. Can be overridden with the environment variable 'ZEEBE_CLIENT_SECRET'.
	ClientSecret string
	// The audience to which the access token will be sent. Can be overridden with the environment variable 'ZEEBE_TOKEN_AUDIENCE'.
	Audience string
	// The URL for the authorization server from which the access token will be requested. Can be overridden with
	// the environment variable 'ZEEBE_AUTHORIZATION_SERVER_URL'.
	AuthorizationServerURL string
	// Cache to read/write credentials from; if none given, defaults to an oauthYamlCredentialsCache instance with the
	// path '$HOME/.camunda/credentials' as default (can be overridden by 'ZEEBE_CLIENT_CONFIG_PATH')
	Cache OAuthCredentialsCache
	// Timeout is the maximum duration of an OAuth request. The default value is 10 seconds
	Timeout time.Duration
}

OAuthProviderConfig configures an OAuthCredentialsProvider, containing the required data to request an access token from an OAuth authorization server which will be appended to each gRPC call's headers.

Jump to

Keyboard shortcuts

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