我面临一个特殊的问题。
在我的 redis.conf 文件中,首先我通过设置启用密码身份验证:
requirepass admin
当我通过 CLI 连接到 Redis 时,我需要在继续任何操作之前验证自己的身份,所以到目前为止一切都很好:
127.0.0.1:6379> get name
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth admin
OK
127.0.0.1:6379> get name
"sahay"
现在,我尝试通过运行创建 ACL 用户:
127.0.0.1:6379> acl setuser nonadminuser on >generalpassword +@all -@dangerous ~*
OK
到目前为止一切顺利,现在我想将这个新用户保留到 ACL 文件,所以我运行:
127.0.0.1:6379> acl save
(error) ERR This Redis instance is not configured to use an ACL file. You may want to specify users via the ACL SETUSER command and then issue a CONFIG REWRITE (assuming you have a Redis configuration file set) in order to store users in the Redis configuration.
这也可以,因为我没有在我的redis.conf中设置任何aclfile配置。
因此,我停止我的 redis 服务器并将此行添加到我的 redis.conf 文件中:
aclfile /Ankit/redis_installation/redis-stable/acl_users.acl
我还在上述目录中创建了一个 acl_users.acl 文件,因为没有它,Redis 会抛出不存在此类文件的错误。
现在到了奇怪的部分。当我启动 redis 并通过 CLI 连接到它时,它不会要求我进行身份验证!尽管
requirepass admin
在redis.conf文件中设置。事实上,当我尝试运行密码时它会抛出错误。
127.0.0.1:6379> get name
"sahay"
127.0.0.1:6379> auth admin
(error) ERR AUTH <password> called without any password configured for the default user. Are you sure your configuration is correct?
此外,当我现在保存 ACL 时(创建新用户后),该新用户将被创建并保留在 acl 文件中,但奇怪的是默认用户存储为“nopass”
为什么即使配置文件有 requirepass 子句,默认用户也配置为 nopass?
最佳答案
requirepass 与 ACL 功能不兼容。如果您配置了 ACL 规则,requirepass 将被忽略。这就是为什么您可以以默认用户身份操作 Redis,而无需发送 auth
命令。
使用ACL功能,您需要明确为默认用户设置规则。
user default on +@all ~* >password
关于redis - 无法将 ACL 用户保留在 Redis 的 ACL 文件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75476891/