Skip to content

Commit

Permalink
rpk: make mechanism flag required in user update
Browse files Browse the repository at this point in the history
Without this, a user could inadvertently change the
mechanism because we default the flag to
SCRAM-SHA-256.

(cherry picked from commit 07943e6)
  • Loading branch information
r-vasquez authored and vbotbuildovich committed Jul 19, 2024
1 parent 648a041 commit fae48b9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/go/rpk/pkg/cli/acl/user/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ func newUpdateCommand(fs afero.Fs, p *config.Params) *cobra.Command {
}

cmd.Flags().StringVar(&newPass, "new-password", "", "New user's password.")
cmd.Flags().StringVar(&mechanism, "mechanism", adminapi.ScramSha256, "SASL mechanism to use for the user you are creating (scram-sha-256, scram-sha-512, case insensitive)")
cmd.Flags().StringVar(&mechanism, "mechanism", adminapi.ScramSha256, "SASL mechanism to use for the user you are updating (scram-sha-256, scram-sha-512, case insensitive)")
cmd.MarkFlagRequired("new-password")
cmd.MarkFlagRequired("mechanism")

return cmd
}
5 changes: 3 additions & 2 deletions tests/rptest/clients/rpk.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,11 @@ def sasl_create_user_basic_mix(self,

return self._run(cmd)

def sasl_update_user(self, user, new_password):
def sasl_update_user(self, user, new_password, new_mechanism):
cmd = [
"acl", "user", "update", user, "--new-password", new_password,
"-X", "admin.hosts=" + self._redpanda.admin_endpoints()
"--mechanism", new_mechanism, "-X",
"admin.hosts=" + self._redpanda.admin_endpoints()
]
return self._run(cmd)

Expand Down
3 changes: 2 additions & 1 deletion tests/rptest/tests/rpk_acl_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ def test_create_update(self):
# We check that we can list the topics:
assert topic in topic_list

out = self._rpk.sasl_update_user(self.username, new_password)
out = self._rpk.sasl_update_user(self.username, new_password,
self.mechanism)
assert f'Updated user "{self.username}" successfully' in out

with expect_exception(
Expand Down

0 comments on commit fae48b9

Please sign in to comment.