Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add feature gate for checking for blank admin/determined password [DET-10197] #9425

Merged
merged 2 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading