Skip to content

Commit

Permalink
wip: kms part 1, core encryption functionality and deprecations. (#2312)
Browse files Browse the repository at this point in the history
Related #2290 

Doesn't change any functionality in the system yet. It is just a
refactor and new encryption types, with tests.

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
gak and github-actions[bot] authored Aug 11, 2024
1 parent 716e666 commit b42b52c
Show file tree
Hide file tree
Showing 8 changed files with 444 additions and 36 deletions.
3 changes: 3 additions & 0 deletions backend/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ func (c *CommonConfig) Validate() error {
return nil
}

// EncryptionKeys for the controller config.
// Deprecated: Will remove this at some stage.
type EncryptionKeys struct {
Logs string `name:"log-key" help:"Key for sensitive log data in internal FTL tables." env:"FTL_LOG_ENCRYPTION_KEY"`
Async string `name:"async-key" help:"Key for sensitive async call data in internal FTL tables." env:"FTL_ASYNC_ENCRYPTION_KEY"`
Expand Down Expand Up @@ -133,6 +135,7 @@ type Config struct {
ModuleUpdateFrequency time.Duration `help:"Frequency to send module updates." default:"30s"`
EventLogRetention *time.Duration `help:"Delete call logs after this time period. 0 to disable" env:"FTL_EVENT_LOG_RETENTION" default:"24h"`
ArtefactChunkSize int `help:"Size of each chunk streamed to the client." default:"1048576"`
KMSURI *url.URL `help:"URI for KMS key e.g. aws-kms://arn:aws:kms:ap-southeast-2:12345:key/0000-1111" env:"FTL_KMS_URI"`
EncryptionKeys
CommonConfig
}
Expand Down
10 changes: 3 additions & 7 deletions common/configuration/asm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@ import (
"sort"
"testing"

"connectrpc.com/connect"
"github.com/TBD54566975/ftl/backend/controller/leases"
ftlv1 "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1"
"github.com/TBD54566975/ftl/internal/log"
"github.com/TBD54566975/ftl/internal/slices"
"github.com/TBD54566975/ftl/testutils"

"connectrpc.com/connect"
"github.com/alecthomas/assert/v2"
"github.com/alecthomas/types/optional"
. "github.com/alecthomas/types/optional"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/aws/aws-sdk-go-v2/service/secretsmanager"
"github.com/aws/aws-sdk-go-v2/service/secretsmanager/types"
)
Expand All @@ -38,10 +37,7 @@ func setUp(ctx context.Context, t *testing.T, router optional.Option[Router[Secr
router = optional.Some[Router[Secrets]](ProjectConfigResolver[Secrets]{Config: projectPath})
}

cc := aws.NewCredentialsCache(credentials.NewStaticCredentialsProvider("test", "test", ""))
cfg, err := config.LoadDefaultConfig(ctx, config.WithCredentialsProvider(cc), config.WithRegion("us-west-2"))
assert.NoError(t, err)

cfg := testutils.NewLocalstackConfig(t, ctx)
externalClient := secretsmanager.NewFromConfig(cfg, func(o *secretsmanager.Options) {
o.BaseEndpoint = aws.String("http://localhost:4566")
})
Expand Down
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ require (
github.com/alecthomas/participle/v2 v2.1.1
github.com/alecthomas/types v0.16.0
github.com/amacneil/dbmate/v2 v2.19.0
github.com/aws/aws-sdk-go v1.44.267
github.com/aws/aws-sdk-go-v2 v1.30.3
github.com/aws/aws-sdk-go-v2/config v1.27.27
github.com/aws/aws-sdk-go-v2/credentials v1.17.27
github.com/aws/aws-sdk-go-v2/service/kms v1.35.3
github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.32.4
github.com/aws/smithy-go v1.20.3
github.com/beevik/etree v1.4.1
Expand All @@ -44,6 +46,7 @@ require (
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1
github.com/sqlc-dev/pqtype v0.3.0
github.com/swaggest/jsonschema-go v0.3.72
github.com/tink-crypto/tink-go-awskms v0.0.0-20230616072154-ba4f9f22c3e9
github.com/tink-crypto/tink-go/v2 v2.2.0
github.com/titanous/json5 v1.0.0
github.com/tliron/commonlog v0.2.17
Expand Down Expand Up @@ -87,6 +90,7 @@ require (
github.com/gorilla/websocket v1.5.1 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
Expand Down
29 changes: 29 additions & 0 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b42b52c

Please sign in to comment.