]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: db-oauth2 - If active attribute is present in request, check it
authorAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 29 Oct 2020 09:37:22 +0000 (11:37 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Tue, 3 Nov 2020 18:29:52 +0000 (20:29 +0200)
If the attribute is missing, do not assume it's false.

src/auth/db-oauth2.c

index 7a3a8ed461900a4271e56950c57ef217e9ad4241..463e4555c8872caafbf48fc510ec608a27ae0180 100644 (file)
@@ -540,11 +540,12 @@ static bool
 db_oauth2_user_is_enabled(struct db_oauth2_request *req,
                          enum passdb_result *result_r, const char **error_r)
 {
-       if (*req->db->set.active_attribute != '\0') {
-               const char *active_value = auth_fields_find(req->fields, req->db->set.active_attribute);
-               if (active_value == NULL ||
-                   (*req->db->set.active_value != '\0' &&
-                    strcmp(req->db->set.active_value, active_value) != 0)) {
+       if (*req->db->set.active_attribute != '\0' &&
+           *req->db->set.active_value != '\0') {
+               const char *active_value =
+                       auth_fields_find(req->fields, req->db->set.active_attribute);
+               if (active_value != NULL &&
+                   strcmp(req->db->set.active_value, active_value) != 0) {
                        *error_r = "Provided token is not valid";
                        *result_r = PASSDB_RESULT_PASSWORD_MISMATCH;
                        return FALSE;