Documentation
¶
Index ¶
- type DynamoDBKeyConverter
- type EncryptionOption
- func WithAES(key []byte) EncryptionOption
- func WithChaCha20Poly1305(key []byte) EncryptionOption
- func WithKeyFromLambdaExtensionSecrets(secretId string, optFns ...func(*endec.SecretsManagerEndecOptions)) EncryptionOption
- func WithKeyFromSecretsManager(client endec.GetSecretValueAPIClient, secretId string, ...) EncryptionOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DynamoDBKeyConverter ¶
type DynamoDBKeyConverter struct { // Endec controls how the tokens are encrypted/decrypted. // // By default, there is no encryption. Prefer NewDynamoDBKeyConverter instead. Endec endec.Endec // EncodeToString controls how the decrypted binary token is encoded to string. // // If Endec is not nil, [base64.RawURLEncoding.EncodeToString] will be used as the default EncodeToString. // If Endec is nil, EncodeToString is used only if EncodeToString is non-nil. EncodeToString func([]byte) string // DecodeString controls how the encrypted string token is decoded. // // If Endec is not nil, [base64.RawURLEncoding.DecodeString] will be used as the default DecodeString. // If Endec is nil, DecodeString is used only if DecodeString is non-nil. DecodeString func(string) ([]byte, error) }
DynamoDBKeyConverter converts from DynamoDB's last evaluated key to pagination token and vice versa, intended to be used for query and scan operations.
Per specifications, only three data types (S, N, or B) can be partition key or sort key. The pagination token will be the DynamoDB JSON blob of the evaluated key, which should have no more than 2 entries.
The zero value struct is ready for use which will encode/decode keys without any encryption. Prefer NewDynamoDBKeyConverter instead which provides ways to encrypt/decrypt the token, making it the token opaque.
func NewDynamoDBKeyConverter ¶
func NewDynamoDBKeyConverter(opt EncryptionOption, optFns ...func(*DynamoDBKeyConverter)) (*DynamoDBKeyConverter, error)
NewDynamoDBKeyConverter returns a new DynamoDBKeyConverter that uses encryption/decryption to produce opaque tokens.
If you have static key, pass WithAES or WithChaCha20Poly1305. If you want to retrieve secret binary from AWS Secrets Hasher, pass WithKeyFromSecretsManager. If you are running in AWS Lambda with AWS Parameters and Secrets Lambda Extension (https://docs.aws.amazon.com/secretsmanager/latest/userguide/retrieving-secrets_lambda.html) enabled, pass WithKeyFromLambdaExtensionSecrets.
func (DynamoDBKeyConverter) DecodeToken ¶
func (c DynamoDBKeyConverter) DecodeToken(ctx context.Context, token string) (key map[string]types.AttributeValue, err error)
DecodeToken decodes the given opaque token to an exclusive start key.
func (DynamoDBKeyConverter) EncodeKey ¶
func (c DynamoDBKeyConverter) EncodeKey(ctx context.Context, key map[string]types.AttributeValue) (string, error)
EncodeKey encodes the given last evaluated key to an opaque token.
type EncryptionOption ¶
type EncryptionOption func(*options) error
EncryptionOption makes it easy to specify both the secret key and the encryption algorithm in a user-friendly manner.
func WithAES ¶
func WithAES(key []byte) EncryptionOption
WithAES makes the DynamoDBKeyConverter uses WithAES encryption with the given key.
func WithChaCha20Poly1305 ¶
func WithChaCha20Poly1305(key []byte) EncryptionOption
WithChaCha20Poly1305 makes the DynamoDBKeyConverter uses ChaCha20-Poly1305 encryption with the given key.
func WithKeyFromLambdaExtensionSecrets ¶
func WithKeyFromLambdaExtensionSecrets(secretId string, optFns ...func(*endec.SecretsManagerEndecOptions)) EncryptionOption
WithKeyFromLambdaExtensionSecrets makes the DynamoDBKeyConverter uses key from AWS Parameters and Secrets Lambda Extension (https://docs.aws.amazon.com/secretsmanager/latest/userguide/retrieving-secrets_lambda.html) using the default client lambda.DefaultParameterSecretsExtensionClient.
If you want to change the encryption suite or customises the endec.SecretsManagerEndec further, see endec.SecretsManagerEndecOptions.
func WithKeyFromSecretsManager ¶
func WithKeyFromSecretsManager(client endec.GetSecretValueAPIClient, secretId string, optFns ...func(*endec.SecretsManagerEndecOptions)) EncryptionOption
WithKeyFromSecretsManager makes the DynamoDBKeyConverter uses key from AWS Secrets Manager.
If you want to change the encryption suite or customises the endec.SecretsManagerEndec further, see endec.SecretsManagerEndecOptions.