Skip to content

Commit

Permalink
fix: add feature gate for checking for blank admin/determined password [
Browse files Browse the repository at this point in the history
  • Loading branch information
jesse-amano-hpe committed May 24, 2024
1 parent 6ad9d73 commit 684c38b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
9 changes: 0 additions & 9 deletions docs/release-notes/cli-requires-initial-password.rst

This file was deleted.

12 changes: 7 additions & 5 deletions master/internal/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ func (m *Master) Run(ctx context.Context, gRPCLogInitDone chan struct{}) error {
return errors.Wrap(err, "could not verify database version")
}

if isBrandNewCluster {
if isBrandNewCluster && slices.Contains(m.config.FeatureSwitches, "prevent_blank_password") {
// This has to happen before setup, to minimize risk of creating a database in a state that looks like
// there are already users, then aborting, which would allow a subsequent cluster to come up ignoring
// this check.
Expand All @@ -1157,10 +1157,12 @@ func (m *Master) Run(ctx context.Context, gRPCLogInitDone chan struct{}) error {
// This has to happen after setup, since creating the built-in users without a
// password is part of the first migration.
password := m.config.Security.InitialUserPassword
for _, username := range user.BuiltInUsers {
err := user.SetUserPassword(ctx, username, password)
if err != nil {
return fmt.Errorf("could not set password for %s: %w", username, err)
if password != "" {
for _, username := range user.BuiltInUsers {
err := user.SetUserPassword(ctx, username, password)
if err != nil {
return fmt.Errorf("could not set password for %s: %w", username, err)
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions master/internal/core_intg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ func TestRun(t *testing.T) {
}
// listen on any available port, we don't care
m.config.Port = 0
m.config.FeatureSwitches = []string{
"prevent_blank_password",
}

ctx, cancel := context.WithCancel(context.Background())
gRPCLogInitDone := make(chan struct{})
Expand Down

0 comments on commit 684c38b

Please sign in to comment.