Add more logging to worker auth rotation and test flags

This makes it much easier to figure out when and why rotation is
happening and control it for tests/debugging.

Remove cert skew

Cherry-picked from release/0.12.x
This commit is contained in:
Jeff Mitchell committed 2023-05-19 17:14:33 -04:00
1 parent 253d191440
commit 77fd51fb12
10 files changed
+327 -69

No files matched your search

+49 -45
View File
@@ -65,45 +65,46 @@ type Command struct {
controller *controller.Controller
worker *worker.Worker
flagLogLevel string
flagLogFormat string
flagCombineLogs bool
flagLoginName string
flagPassword string
flagUnprivilegedLoginName string
flagUnprivilegedPassword string
flagIdSuffix string
flagSecondaryIdSuffix string
flagHostAddress string
flagTargetDefaultPort int
flagTargetSessionMaxSeconds int
flagTargetSessionConnectionLimit int
flagControllerAPIListenAddr string
flagControllerClusterListenAddr string
flagControllerPublicClusterAddr string
flagControllerOnly bool
flagWorkerAuthKey string
flagWorkerProxyListenAddr string
flagWorkerPublicAddr string
flagOpsListenAddr string
flagUiPassthroughDir string
flagRecoveryKey string
flagDatabaseUrl string
flagContainerImage string
flagDisableDatabaseDestruction bool
flagEventFormat string
flagAudit string
flagObservations string
flagSysEvents string
flagEveryEventAllowFilters []string
flagEveryEventDenyFilters []string
flagCreateLoopbackHostPlugin bool
flagPluginExecutionDir string
flagWorkerAuthMethod string
flagWorkerAuthStorageDir string
flagWorkerAuthStorageSkipCleanup bool
flagWorkerAuthRotationInterval time.Duration
flagWorkerAuthDebuggingEnabled bool
flagLogLevel string
flagLogFormat string
flagCombineLogs bool
flagLoginName string
flagPassword string
flagUnprivilegedLoginName string
flagUnprivilegedPassword string
flagIdSuffix string
flagSecondaryIdSuffix string
flagHostAddress string
flagTargetDefaultPort int
flagTargetSessionMaxSeconds int
flagTargetSessionConnectionLimit int
flagControllerAPIListenAddr string
flagControllerClusterListenAddr string
flagControllerPublicClusterAddr string
flagControllerOnly bool
flagWorkerAuthKey string
flagWorkerProxyListenAddr string
flagWorkerPublicAddr string
flagOpsListenAddr string
flagUiPassthroughDir string
flagRecoveryKey string
flagDatabaseUrl string
flagContainerImage string
flagDisableDatabaseDestruction bool
flagEventFormat string
flagAudit string
flagObservations string
flagSysEvents string
flagEveryEventAllowFilters []string
flagEveryEventDenyFilters []string
flagCreateLoopbackHostPlugin bool
flagPluginExecutionDir string
flagWorkerAuthMethod string
flagWorkerAuthStorageDir string
flagWorkerAuthStorageSkipCleanup bool
flagWorkerAuthWorkerRotationInterval time.Duration
flagWorkerAuthCaCertificateLifetime time.Duration
flagWorkerAuthDebuggingEnabled bool
}
func (c *Command) Synopsis() string {
@@ -385,8 +386,13 @@ func (c *Command) Flags() *base.FlagSets {
})
f.DurationVar(&base.DurationVar{
Name: "worker-auth-rotation-interval",
Target: &c.flagWorkerAuthRotationInterval,
Name: "worker-auth-worker-rotation-interval",
Target: &c.flagWorkerAuthWorkerRotationInterval,
Hidden: true,
})
f.DurationVar(&base.DurationVar{
Name: "worker-auth-ca-certificate-lifetime",
Target: &c.flagWorkerAuthCaCertificateLifetime,
Hidden: true,
})
@@ -708,6 +714,7 @@ func (c *Command) Run(args []string) int {
conf := &controller.Config{
RawConfig: c.Config,
Server: c.Server,
TestOverrideWorkerAuthCaCertificateLifetime: c.flagWorkerAuthCaCertificateLifetime,
}
var err error
@@ -742,10 +749,7 @@ func (c *Command) Run(args []string) int {
c.UI.Error(fmt.Errorf("Error initializing worker: %w", err).Error())
return base.CommandCliError
}
if c.flagWorkerAuthRotationInterval > 0 {
c.worker.TestOverrideAuthRotationPeriod = c.flagWorkerAuthRotationInterval
}
c.worker.TestOverrideAuthRotationPeriod = c.flagWorkerAuthWorkerRotationInterval
if c.flagWorkerAuthMethod == PkiRandomWorkerAuthMechanism {
// Flip a coin. Use one method or the other; it's transparent to