Initial BYOW auth PoC (#29)

This commit is contained in:
Jeff Mitchell committed 2022-05-09 13:28:17 -04:00
1 parent 8ed560fc3e
commit f748af7b02
21 files changed
+707 -404

No files matched your search

@@ -62,6 +62,7 @@ kms "aead" {
listener "tcp" {
purpose = "api"
address = "127.0.0.1:9500"
tls_cert_file = "%s/bundle.pem"
tls_key_file = "%s/bundle.pem"
cors_enabled = true
@@ -69,10 +70,12 @@ listener "tcp" {
}
listener "tcp" {
address = "127.0.0.1:9501"
purpose = "cluster"
}
listener "tcp" {
address = "127.0.0.1:9502"
purpose = "proxy"
}
`
@@ -131,7 +134,7 @@ func TestServer_ReloadListener(t *testing.T) {
}()
testCertificateSerial := func(serial string) {
conn, err := tls.Dial("tcp", "127.0.0.1:9200", &tls.Config{
conn, err := tls.Dial("tcp", "127.0.0.1:9500", &tls.Config{
RootCAs: certPool,
})
require.NoError(err)
+22 -10
View File
@@ -188,10 +188,6 @@ func (c *Command) Run(args []string) int {
return base.CommandUserError
}
}
if c.WorkerAuthKms == nil {
c.UI.Error("Worker Auth KMS not found after parsing KMS blocks")
return base.CommandUserError
}
if c.Config.DefaultMaxRequestDuration != 0 {
globals.DefaultMaxRequestDuration = c.Config.DefaultMaxRequestDuration
@@ -450,12 +446,6 @@ func (c *Command) Run(args []string) int {
}
}()
c.PrintInfo(c.UI)
if err := c.ReleaseLogGate(); err != nil {
c.UI.Error(fmt.Errorf("Error releasing event gate: %w", err).Error())
return base.CommandCliError
}
if c.Config.Controller != nil {
c.EnabledPlugins = append(c.EnabledPlugins, base.EnabledPluginHostAws, base.EnabledPluginHostAzure)
if err := c.StartController(c.Context); err != nil {
@@ -474,6 +464,28 @@ func (c *Command) Run(args []string) int {
}
return base.CommandCliError
}
if c.WorkerAuthKms == nil {
if c.worker.NodeeKeyId == "" {
retErr := fmt.Errorf("No worker key ID found at worker registration time")
if err := c.worker.Shutdown(); err != nil {
c.UI.Error(retErr.Error())
retErr = fmt.Errorf("Error shutting down worker: %w", err)
}
c.UI.Error(retErr.Error())
if err := c.controller.Shutdown(); err != nil {
c.UI.Error(fmt.Errorf("Error with controller shutdown: %w", err).Error())
}
return base.CommandCliError
}
c.InfoKeys = append(c.InfoKeys, "worker key identifier")
c.Info["worker key identifier"] = c.worker.NodeeKeyId
}
}
c.PrintInfo(c.UI)
if err := c.ReleaseLogGate(); err != nil {
c.UI.Error(fmt.Errorf("Error releasing event gate: %w", err).Error())
return base.CommandCliError
}
opsServer, err := ops.NewServer(c.Logger, c.controller, c.Listeners...)
@@ -125,6 +125,10 @@ func TestServer_ShutdownWorker(t *testing.T) {
}()
waitCh(t, workerCmd.startedCh)
// Give the worker time for initial status or we can fail because no worker
// is ready for the connection yet
time.Sleep(5 * time.Second)
// Set up the target
ctx := context.Background()
client := buildClient(t, shutdownReloadApiAddr)
@@ -60,7 +60,7 @@ kms "aead" {
listener "tcp" {
purpose = "api"
address = "127.0.0.1:9203"
address = "127.0.0.1:9403"
tls_disable = true
cors_enabled = true
cors_allowed_origins = ["*"]
@@ -68,12 +68,12 @@ listener "tcp" {
listener "tcp" {
purpose = "cluster"
address = "127.0.0.1:9204"
address = "127.0.0.1:9404"
}
listener "tcp" {
purpose = "proxy"
address = "127.0.0.1:9205"
address = "127.0.0.1:9405"
}
`
@@ -82,7 +82,7 @@ const tag1Config = `
worker {
name = "dev-worker"
description = "A default worker created in dev mode"
controllers = ["127.0.0.1:9204"]
controllers = ["127.0.0.1:9404"]
tags {
type = ["dev", "local"]
}
@@ -93,7 +93,7 @@ const tag2Config = `
worker {
name = "dev-worker"
description = "A default worker created in dev mode"
controllers = ["127.0.0.1:9204"]
controllers = ["127.0.0.1:9404"]
tags {
foo = ["bar", "baz"]
}