]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: Allow authentication succeed without passdb
authorAki Tuomi <aki.tuomi@open-xchange.com>
Tue, 27 Feb 2024 13:16:42 +0000 (15:16 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 17 Jan 2025 08:39:58 +0000 (10:39 +0200)
src/auth/auth-request.c

index 8764727050b3c071517c2b5eda9b6c9dc06f0993..4fa80365d04b4a3402b3bd7ecb4c8a9a85487994 100644 (file)
@@ -1543,6 +1543,14 @@ auth_request_lookup_credentials_policy_continue(
        request->passdb = passdb;
 
        if (passdb == NULL) {
+               if (request->passdb_success) {
+                       /* This is coming from mech that has already validated
+                          credentials, so we can just continue as success. */
+                       result = PASSDB_RESULT_OK;
+                       request->passdb_result = result;
+                       callback(result, NULL, 0, request);
+                       return;
+               }
                e_error(request->event, "All password databases were skipped");
                callback(PASSDB_RESULT_INTERNAL_FAILURE, NULL, 0, request);
                return;
@@ -2032,7 +2040,10 @@ void auth_request_set_field(struct auth_request *request,
        i_assert(*name != '\0');
        i_assert(value != NULL);
 
-       i_assert(request->passdb != NULL);
+       /* Allow passdb to be NULL if it has already succeeded,
+          this happens mostly with mechs that already know the user
+          account is valid. */
+       i_assert(request->passdb != NULL || request->passdb_success);
 
        if (name_len > 10 && strcmp(name+name_len-10, ":protected") == 0) {
                /* set this field only if it hasn't been set before */