encryption

package
v0.0.0-...-94a9b73 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

README

Steps to run this sample:

  1. You need a Temporal service running. See details in README.md
  2. Compile the encryption plugin for tctl
go build -o ../bin/encryption-plugin plugin/main.go
  1. Run the following command to start the worker
go run worker/main.go
  1. Run the following command to start the example
go run starter/main.go
  1. Run the following command and see the encrypted payloads
export PATH="../bin:$PATH" TEMPORAL_CLI_PLUGIN_DATA_CONVERTER=encryption-plugin
tctl workflow show --wid encryption_workflowID

Note: plugins should normally be available in your PATH, we include the current directory in the path here for ease of testing.

Documentation

Index

Constants

View Source
const (
	// MetadataEncodingEncrypted is "binary/encrypted"
	MetadataEncodingEncrypted = "binary/encrypted"

	// MetadataEncryptionKeyID is "encryption-key-id"
	MetadataEncryptionKeyID = "encryption-key-id"
)

Variables

View Source
var PropagateKey = contextKey{}

PropagateKey is the key used to store the value in the Context object

Functions

func Activity

func Activity(ctx context.Context, info map[string]string) (string, error)

func NewContextPropagator

func NewContextPropagator() workflow.ContextPropagator

NewContextPropagator returns a context propagator that propagates a set of string key-value pairs across a workflow

func Workflow

func Workflow(ctx workflow.Context, name string) (string, error)

Workflow is a standard workflow definition. Note that the Workflow and Activity don't need to care that their inputs/results are being encrypted/decrypted.

Types

type Codec

type Codec struct {
	KeyID string
}

Codec implements PayloadCodec using AES Crypt.

func (*Codec) Decode

func (e *Codec) Decode(payloads []*commonpb.Payload) ([]*commonpb.Payload, error)

Decode implements converter.PayloadCodec.Decode.

func (*Codec) Encode

func (e *Codec) Encode(payloads []*commonpb.Payload) ([]*commonpb.Payload, error)

Encode implements converter.PayloadCodec.Encode.

type CryptContext

type CryptContext struct {
	KeyID string `json:"keyId"`
}

CryptConfig is a struct holding values

type DataConverter

type DataConverter struct {
	converter.DataConverter
	// contains filtered or unexported fields
}

func NewEncryptionDataConverter

func NewEncryptionDataConverter(dataConverter converter.DataConverter, options DataConverterOptions) *DataConverter

NewEncryptionDataConverter creates a new instance of EncryptionDataConverter wrapping a DataConverter

func (*DataConverter) WithContext

func (dc *DataConverter) WithContext(ctx context.Context) converter.DataConverter

TODO: Implement workflow.ContextAware in EncodingDataConverter Note that you only need to implement this function if you need to vary the encryption KeyID per workflow.

func (*DataConverter) WithWorkflowContext

func (dc *DataConverter) WithWorkflowContext(ctx workflow.Context) converter.DataConverter

TODO: Implement workflow.ContextAware in CodecDataConverter Note that you only need to implement this function if you need to vary the encryption KeyID per workflow.

type DataConverterOptions

type DataConverterOptions struct {
	KeyID string
	// Enable ZLib compression before encryption.
	Compress bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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