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

credsutil: Include underscore as part of reqStr #3037

Merged
merged 3 commits into from
Aug 3, 2017
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
1 change: 1 addition & 0 deletions plugins/database/cassandra/cassandra.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions plugins/helper/database/credsutil/credsutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down