Skip to content

Commit d41d45d

Browse files
authored
Ignore X.509 users in scram secret collision validation (#123)
# Summary During validation, users without the scramCredentialsSecretName parameter are [added](https://github.com/mongodb/mongodb-kubernetes/blob/7fa6687dd12bc523f6d5df834672c849b1b737ed/mongodb-community-operator/controllers/validation/validation.go#L95) to a dictionary with an empty key, which leads to the error mentioned in issue #122. Closes #122 ## Reminder (Please remove this when merging) - Please try to Approve or Reject Changes the PR, keep PRs in review as short as possible - Our Short Guide for PRs: [Link](https://docs.google.com/document/d/1T93KUtdvONq43vfTfUt8l92uo4e4SEEvFbIEKOxGr44/edit?tab=t.0) - Remember the following Communication Standards - use comment prefixes for clarity: * **blocking**: Must be addressed before approval. * **follow-up**: Can be addressed in a later PR or ticket. * **q**: Clarifying question. * **nit**: Non-blocking suggestions. * **note**: Side-note, non-actionable. Example: Praise * --> no prefix is considered a question --------- Signed-off-by: Vadim Aleksandrov <[email protected]>
1 parent f29ac63 commit d41d45d

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

mongodb-community-operator/controllers/validation/validation.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,16 @@ func validateUsers(mdb mdbv1.MongoDBCommunity) error {
8585

8686
// Ensure no collisions in the secret holding scram credentials
8787
scramSecretName := user.ScramCredentialsSecretName
88-
if previousUser, exists := scramSecretNameMap[scramSecretName]; exists {
89-
scramSecretNameCollisions = append(scramSecretNameCollisions,
90-
fmt.Sprintf(`[scram secret name: "%s" for user: "%s" and user: "%s"]`,
91-
scramSecretName,
92-
previousUser.Username,
93-
user.Username))
94-
} else {
95-
scramSecretNameMap[scramSecretName] = user
88+
if scramSecretName != "" {
89+
if previousUser, exists := scramSecretNameMap[scramSecretName]; exists {
90+
scramSecretNameCollisions = append(scramSecretNameCollisions,
91+
fmt.Sprintf(`[scram secret name: "%s" for user: "%s" and user: "%s"]`,
92+
scramSecretName,
93+
previousUser.Username,
94+
user.Username))
95+
} else {
96+
scramSecretNameMap[scramSecretName] = user
97+
}
9698
}
9799

98100
if user.Database == constants.ExternalDB {

0 commit comments

Comments
 (0)