update(requirepass): behave as redis requirepass (#1996)

* requirepass also updates ACL default user password
* update config set requirepass to include the new behaviour
* add tests
* fix non existent default user when loading empty files
This commit is contained in:
Kostas Kyrimis 2023-10-09 16:34:42 +03:00 committed by GitHub
parent eb50741855
commit 5471827448
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 55 additions and 11 deletions

View file

@ -678,7 +678,6 @@ void Service::Init(util::AcceptServer* acceptor, std::vector<facade::Listener*>
config_registry.Register("dbnum"); // equivalent to databases in redis.
config_registry.RegisterMutable("dir"); // TODO: to add validation for dir
config_registry.RegisterMutable("requirepass");
config_registry.RegisterMutable("masterauth");
config_registry.RegisterMutable("tcp_keepalive");
config_registry.RegisterMutable("replica_partial_sync");
@ -1238,10 +1237,10 @@ facade::ConnectionContext* Service::CreateContext(util::FiberSocketBase* peer,
facade::Connection* owner) {
ConnectionContext* res = new ConnectionContext{peer, owner};
if (owner->IsPrivileged() && !RequirePrivilegedAuth()) {
res->req_auth = false;
} else {
if (owner->IsPrivileged() && RequirePrivilegedAuth()) {
res->req_auth = !GetPassword().empty();
} else {
res->req_auth = !user_registry_.AuthUser("default", "");
}
// a bit of a hack. I set up breaker callback here for the owner.