-
Notifications
You must be signed in to change notification settings - Fork 30
[CLOUDP-349630] Don't generate scramshacreds if MongoDBUser's password is not changed
#628
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
base: master
Are you sure you want to change the base?
Changes from all commits
4aea447
bc827e9
d21781a
81b06d4
82552bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -333,7 +333,7 @@ func AddMongoDBUserController(ctx context.Context, mgr manager.Manager, memberCl | |
| // toOmUser converts a MongoDBUser specification and optional password into an | ||
| // automation config MongoDB user. If the user has no password then a blank | ||
| // password should be provided. | ||
| func toOmUser(spec userv1.MongoDBUserSpec, password string) (om.MongoDBUser, error) { | ||
| func toOmUser(spec userv1.MongoDBUserSpec, password string, ac *om.AutomationConfig) (om.MongoDBUser, error) { | ||
| user := om.MongoDBUser{ | ||
| Database: spec.Database, | ||
| Username: spec.Username, | ||
|
|
@@ -344,7 +344,7 @@ func toOmUser(spec userv1.MongoDBUserSpec, password string) (om.MongoDBUser, err | |
|
|
||
| // only specify password if we're dealing with non-x509 users | ||
| if spec.Database != authentication.ExternalDB { | ||
| if err := authentication.ConfigureScramCredentials(&user, password); err != nil { | ||
| if err := authentication.ConfigureScramCredentials(&user, password, ac); err != nil { | ||
| return om.MongoDBUser{}, xerrors.Errorf("error generating SCRAM credentials: %w", err) | ||
| } | ||
| } | ||
|
|
@@ -385,7 +385,7 @@ func (r *MongoDBUserReconciler) handleScramShaUser(ctx context.Context, user *us | |
| auth.RemoveUser(user.Status.Username, user.Status.Database) | ||
| } | ||
|
|
||
| desiredUser, err := toOmUser(user.Spec, password) | ||
| desiredUser, err := toOmUser(user.Spec, password, ac) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
@@ -421,18 +421,18 @@ func (r *MongoDBUserReconciler) handleScramShaUser(ctx context.Context, user *us | |
| } | ||
|
|
||
| func (r *MongoDBUserReconciler) handleExternalAuthUser(ctx context.Context, user *userv1.MongoDBUser, conn om.Connection, log *zap.SugaredLogger) (reconcile.Result, error) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @lucian-tosa, |
||
| desiredUser, err := toOmUser(user.Spec, "") | ||
| if err != nil { | ||
| return r.updateStatus(ctx, user, workflow.Failed(xerrors.Errorf("error updating user %w", err)), log) | ||
| } | ||
|
|
||
| shouldRetry := false | ||
| updateFunction := func(ac *om.AutomationConfig) error { | ||
| if !externalAuthMechanismsAvailable(ac.Auth.DeploymentAuthMechanisms) { | ||
| shouldRetry = true | ||
| return xerrors.Errorf("no external authentication mechanisms (LDAP or x509) have been configured") | ||
| } | ||
|
|
||
| desiredUser, err := toOmUser(user.Spec, "", ac) | ||
| if err != nil { | ||
| return xerrors.Errorf("errorr updating user %w", err) | ||
| } | ||
|
|
||
| auth := ac.Auth | ||
| if user.ChangedIdentifier() { | ||
| auth.RemoveUser(user.Status.Username, user.Status.Database) | ||
|
|
@@ -442,7 +442,7 @@ func (r *MongoDBUserReconciler) handleExternalAuthUser(ctx context.Context, user | |
| return nil | ||
| } | ||
|
|
||
| err = conn.ReadUpdateAutomationConfig(updateFunction, log) | ||
| err := conn.ReadUpdateAutomationConfig(updateFunction, log) | ||
| if err != nil { | ||
| if shouldRetry { | ||
| return r.updateStatus(ctx, user, workflow.Pending("%s", err.Error()).WithRetry(10), log) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.