Skip to content

Conversation

@hwware
Copy link
Contributor

@hwware hwware commented Mar 5, 2025

Current ACL WHOAMI can only display the username for the current connection.
It need to call ACL LIST to get the active ACL rules, thus there are 2 disadvantages:

  1. CALL 2 commands to get ACL rules for the current connection
  2. ACL LIST will display all users and their ACL rules, it is not necessary,

This PR allows the current connection to call once "ACL WHOAMI FULL" to get all information.

@hwware hwware added enhancement New feature or request needs-doc-pr This change needs to update a documentation page. Remove label once doc PR is open. labels Mar 5, 2025
@hwware hwware added this to Valkey 9.0 Mar 5, 2025
Signed-off-by: hwware <wen.hui.ware@gmail.com>
@hwware hwware force-pushed the acl-WHOAMI-extension branch from a88175a to 8b23382 Compare March 5, 2025 16:12
@codecov
Copy link

codecov bot commented Mar 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.98%. Comparing base (2c9db1a) to head (8b23382).

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #1821      +/-   ##
============================================
- Coverage     71.03%   70.98%   -0.05%     
============================================
  Files           123      123              
  Lines         65665    65672       +7     
============================================
- Hits          46645    46618      -27     
- Misses        19020    19054      +34     
Files with missing lines Coverage Δ
src/acl.c 90.74% <100.00%> (+0.04%) ⬆️
src/commands.def 100.00% <ø> (ø)

... and 12 files with indirect coverage changes

Copy link
Collaborator

@hpatro hpatro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the use case for this ?

} else if (!strcasecmp(sub, "whoami") && (c->argc == 2 || c->argc == 3)) {
if (c->user != NULL) {
addReplyBulkCBuffer(c, c->user->name, sdslen(c->user->name));
if (c->argc == 3) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generally don't like variadic arguments that change the type of response. So would also somewhat prefer another command.

Also, do we want this to be a variant of ACL GETUSER instead? Somewhat related to this issue, #1807.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another command? you mean a new command? I am afraid the user need to remember one more.
I guess this command is not same as ACL GETUSER, because this command only apply to current connection, even user do not know the username either.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this command is not same as ACL GETUSER, because this command only apply to current connection, even user do not know the username either.

A new command, like ACL GETMYSELF, is what I'm suggesting. I agree it's one more command.

@hwware
Copy link
Contributor Author

hwware commented Mar 6, 2025

What's the use case for this ?

As the top comment describe, I thought

@hpatro
Copy link
Collaborator

hpatro commented Mar 6, 2025

What's the use case for this ?

As the top comment describe, I thought

I mean it's not an expensive operation and don't see what's the pain behind doing it one after another.

@zuiderkwast
Copy link
Contributor

WHOAMI comes from the UNIX command whoami. In UNIX it displays the username and nothing else.

  • Adding a parameter that modifies the type of the response is extra complexity and logic for client libraries to handle.
  • The alternative, adding a new subcommand, is also extra complexity and more to remember.

I think we don't need this extra complexity. It is OK to call 2 commands to get the information. We don't need to optimize this use case for performace. For ease of use, it can be improved by external admin tools.

@madolson madolson moved this to Optional for next release candidate in Valkey 9.0 Jul 21, 2025
@madolson madolson moved this from Optional for next release candidate to Todo in Valkey 9.0 Aug 18, 2025
@madolson madolson moved this from Todo to In Progress in Valkey 9.0 Aug 18, 2025
@zuiderkwast zuiderkwast removed this from Valkey 9.0 Dec 9, 2025
@zuiderkwast zuiderkwast moved this to Optional for next release candidate in Valkey 9.1 Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request needs-doc-pr This change needs to update a documentation page. Remove label once doc PR is open.

Projects

Status: Optional for next release candidate

Development

Successfully merging this pull request may close these issues.

4 participants