credsutil: Include hyphen as part of reqStr (#3037)

This commit is contained in:
Calvin Leung Huang 2017-08-03 07:34:53 -04:00 committed by Jeff Mitchell
parent 8d99192977
commit 7d55652927
2 changed files with 5 additions and 4 deletions

View File

@ -96,6 +96,7 @@ func (c *Cassandra) CreateUser(statements dbplugin.Statements, usernameConfig db
}
username, err = c.GenerateUsername(usernameConfig)
username = strings.Replace(username, "-", "_", -1)
if err != nil {
return "", "", err
}

View File

@ -19,12 +19,12 @@ type CredentialsProducer interface {
}
const (
reqStr = `A1a`
reqStr = `A1a-`
minStrLen = 10
)
// RandomAlphaNumeric returns a random string of characters [A-Za-z0-9]
// of the provided length. The string generated takes up to 3 characters
// RandomAlphaNumeric returns a random string of characters [A-Za-z0-9-]
// of the provided length. The string generated takes up to 4 characters
// of space that are predefined and prepended to ensure password
// character requirements. It also requires a min length of 10 characters.
func RandomAlphaNumeric(length int) (string, error) {
@ -40,7 +40,7 @@ func RandomAlphaNumeric(length int) (string, error) {
for size < length {
// Extend the len of the random byte slice to lower odds of having to
// re-roll.
c := length + 3
c := length + len(reqStr)
bArr := make([]byte, c)
_, err := rand.Read(bArr)
if err != nil {