Skip to content

Commit 38c2d5c

Browse files
committed
settings: revert "set MinPasswordLength to 14 for FIPS builds"
This reverts commit 26437b9. Epic: none Release not: None
1 parent 1f85128 commit 38c2d5c

File tree

8 files changed

+10
-58
lines changed

8 files changed

+10
-58
lines changed

pkg/ccl/securityccl/fipsccl/fipscclbase/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ go_library(
55
srcs = [
66
"build_boring.go", # keep
77
"build_noboring.go",
8-
"consts.go",
98
],
109
cgo = True,
1110
importpath = "github.com/cockroachdb/cockroach/pkg/ccl/securityccl/fipsccl/fipscclbase",

pkg/ccl/securityccl/fipsccl/fipscclbase/consts.go

Lines changed: 0 additions & 9 deletions
This file was deleted.

pkg/cli/clisqlclient/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ go_library(
2222
visibility = ["//visibility:public"],
2323
deps = [
2424
"//pkg/build",
25-
"//pkg/ccl/securityccl/fipsccl/fipscclbase",
2625
"//pkg/cli/clicfg",
2726
"//pkg/cli/clierror",
2827
"//pkg/security/pprompt",

pkg/cli/clisqlclient/conn.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717

1818
"github.com/cockroachdb/cockroach-go/v2/crdb"
1919
"github.com/cockroachdb/cockroach/pkg/build"
20-
"github.com/cockroachdb/cockroach/pkg/ccl/securityccl/fipsccl/fipscclbase"
2120
"github.com/cockroachdb/cockroach/pkg/cli/clierror"
2221
"github.com/cockroachdb/cockroach/pkg/security/pprompt"
2322
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode"
@@ -44,7 +43,7 @@ type sqlConn struct {
4443
conn *pgx.Conn
4544
reconnecting bool
4645

47-
// passwordMissing is true if the url is missing a password.
46+
// passwordMissing is true iff the url is missing a password.
4847
passwordMissing bool
4948

5049
// alwaysInferResultTypes is true iff the client should always use the
@@ -184,10 +183,6 @@ func (c *sqlConn) EnsureConn(ctx context.Context) error {
184183
if err != nil {
185184
return wrapConnError(err)
186185
}
187-
// Under FIPS 140-3 mode, the password must be at least 14 characters long.
188-
if fipscclbase.IsFIPSReady() && !c.passwordMissing && len(base.Password) < fipscclbase.FIPSMinPasswordLength {
189-
return errors.Newf("password must be at least %d characters long", fipscclbase.FIPSMinPasswordLength)
190-
}
191186
// Add a notice handler - re-use the cliOutputError function in this case.
192187
base.OnNotice = func(_ *pgconn.PgConn, notice *pgconn.Notice) {
193188
c.handleNotice(notice)
@@ -774,10 +769,6 @@ func (c *sqlConn) fillPassword() error {
774769
if err != nil {
775770
return err
776771
}
777-
// Under FIPS 140-3 mode, the password must be at least 14 characters long.
778-
if fipscclbase.IsFIPSReady() && len(pwd) < fipscclbase.FIPSMinPasswordLength {
779-
return errors.Newf("password must be at least %d characters long", fipscclbase.FIPSMinPasswordLength)
780-
}
781772
connURL.User = url.UserPassword(connURL.User.Username(), pwd)
782773
c.url = connURL.String()
783774
c.passwordMissing = false

pkg/cli/democluster/demo_cluster.go

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ package democluster
77

88
import (
99
"context"
10-
"crypto/rand"
1110
gosql "database/sql"
1211
"fmt"
1312
"io"
@@ -380,12 +379,7 @@ func (c *transientCluster) Start(ctx context.Context) (err error) {
380379
return err
381380
}
382381

383-
st := c.firstServer.ClusterSettings()
384-
minPasswordLength := security.MinPasswordLength.Get(&st.SV)
385-
demoPassword, err := genDemoPassword(demoUsername, minPasswordLength)
386-
if err != nil {
387-
return errors.Wrap(err, "failed to generate demo password")
388-
}
382+
demoPassword := genDemoPassword(demoUsername)
389383

390384
// Step 8: initialize tenant servers, if enabled.
391385
phaseCtx = logtags.AddTag(ctx, "phase", 8)
@@ -2127,21 +2121,10 @@ func (c *transientCluster) addDemoLoginToURL(uiURL *url.URL, includeTenantName b
21272121
//
21282122
// The password can be overridden via the env var
21292123
// COCKROACH_DEMO_PASSWORD for the benefit of test automation.
2130-
func genDemoPassword(username string, minPasswordLength int64) (string, error) {
2131-
if password := envutil.EnvOrDefaultString("COCKROACH_DEMO_PASSWORD", ""); password != "" {
2132-
if len(password) < int(minPasswordLength) {
2133-
return "", errors.Newf("password is too short: %s", password)
2134-
}
2135-
return password, nil
2136-
}
2124+
func genDemoPassword(username string) string {
21372125
mypid := os.Getpid()
2138-
password := fmt.Sprintf("%s%d", username, mypid)
2139-
// If the password is too short, append random characters until it is long enough.
2140-
for len(password) < int(minPasswordLength) {
2141-
randText := strings.ToLower(rand.Text())
2142-
password += string(randText[0])
2143-
}
2144-
return password, nil
2126+
candidatePassword := fmt.Sprintf("%s%d", username, mypid)
2127+
return envutil.EnvOrDefaultString("COCKROACH_DEMO_PASSWORD", candidatePassword)
21452128
}
21462129

21472130
// lockDir uses a file lock to prevent concurrent writes to the

pkg/cli/interactive_tests/test_demo.tcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,11 @@ eexpect eof
169169
end_test
170170

171171
start_test "Check that the user can override the password."
172-
set ::env(COCKROACH_DEMO_PASSWORD) "hunter2hunter2hunter2hunter2"
172+
set ::env(COCKROACH_DEMO_PASSWORD) "hunter2"
173173
spawn $argv demo --no-line-editor --insecure=false --no-example-database --log-dir=logs
174174
eexpect "Connection parameters"
175175
eexpect "(sql)"
176-
eexpect "postgresql://demo:hunter2hunter2hunter2hunter2@"
176+
eexpect "postgresql://demo:hunter2@"
177177
eexpect "defaultdb>"
178178
send_eof
179179
eexpect eof

pkg/roachprod/install/cockroach.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ const (
752752
AuthRootCert
753753

754754
DefaultUser = "roachprod"
755-
DefaultPassword = "cockroachpassword"
755+
DefaultPassword = "cockroachdb"
756756

757757
DefaultAuthModeEnv = "ROACHPROD_DEFAULT_AUTH_MODE"
758758
)

pkg/security/password.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"runtime"
1212
"sync"
1313

14-
"github.com/cockroachdb/cockroach/pkg/ccl/securityccl/fipsccl/fipscclbase"
1514
"github.com/cockroachdb/cockroach/pkg/security/password"
1615
"github.com/cockroachdb/cockroach/pkg/settings"
1716
"github.com/cockroachdb/cockroach/pkg/util/envutil"
@@ -138,16 +137,6 @@ var AutoDetectPasswordHashes = settings.RegisterBoolSetting(
138137
true,
139138
)
140139

141-
// By default, the minimum password length is 1. In FIPS 140-3 mode, where HMAC
142-
// is required to have a key of at least 112 bits, the minimum password length
143-
// is 14 characters.
144-
var defaultMinPasswordLength = func() int64 {
145-
if fipscclbase.IsFIPSReady() {
146-
return fipscclbase.FIPSMinPasswordLength
147-
}
148-
return 1
149-
}()
150-
151140
// MinPasswordLength is the cluster setting that configures the
152141
// minimum SQL password length.
153142
var MinPasswordLength = settings.RegisterIntSetting(
@@ -156,8 +145,8 @@ var MinPasswordLength = settings.RegisterIntSetting(
156145
"the minimum length accepted for passwords set in cleartext via SQL. "+
157146
"Note that a value lower than 1 is ignored: passwords cannot be empty in any case. "+
158147
"This setting only applies when adding new users or altering an existing user's password; it will not affect existing logins.",
159-
defaultMinPasswordLength,
160-
settings.IntWithMinimum(defaultMinPasswordLength),
148+
1,
149+
settings.NonNegativeInt,
161150
settings.WithPublic)
162151

163152
// AutoUpgradePasswordHashes is the cluster setting that configures whether to

0 commit comments

Comments
 (0)