]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: db-oauth2 - Use common code for lookup and password grant
authorAki Tuomi <aki.tuomi@open-xchange.com>
Tue, 26 May 2020 06:53:26 +0000 (09:53 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 27 May 2020 07:51:31 +0000 (10:51 +0300)
src/auth/db-oauth2.c

index d484c0a5ddc024d8f36a8ae7882575bb81281666..2c449315cca6e5d10643e0a700a79f2130bc9cbe 100644 (file)
@@ -711,26 +711,15 @@ db_oauth2_lookup_passwd_grant(struct oauth2_request_result *result,
                                error = "Internal error";
                } else
                        error = result->error;
+               db_oauth2_callback(req, passdb_result, error);
        } else {
-               db_oauth2_fields_merge(req, result->fields);
-               if (*req->db->set.introspection_url != '\0' &&
-                   (req->db->set.force_introspection ||
-                    !db_oauth2_have_all_fields(req))) {
-                       auth_request_log_debug(req->auth_request, AUTH_SUBSYS_DB,
-                                              "oauth2: Introspection needed after token validation");
-                       req->token = auth_fields_find(req->fields, "access_token");
-                       if (req->token != NULL)
-                               db_oauth2_lookup_introspect(req);
-                       else {
-                               passdb_result = PASSDB_RESULT_INTERNAL_FAILURE;
-                               error = "Internal error";
-                               db_oauth2_callback(req, passdb_result, error);
-                       }
-                       return;
-               }
-               db_oauth2_process_fields(req, &passdb_result, &error);
+               /* make sure token is NULL if no access_token is found */
+               req->token = NULL;
+               array_foreach(result->fields, f)
+                       if (strcmp(f->name, "access_token") == 0)
+                               req->token = p_strdup(req->pool, f->value);
+               db_oauth2_lookup_continue(result, req);
        }
-       db_oauth2_callback(req, passdb_result, error);
 }
 
 #undef db_oauth2_lookup