]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-oauth2: Move oauth2_request_set_headers() to oauth2-request.c.
authorStephan Bosch <stephan.bosch@open-xchange.com>
Fri, 5 Jun 2020 19:15:47 +0000 (21:15 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Mon, 7 Dec 2020 08:59:28 +0000 (08:59 +0000)
src/lib-oauth2/oauth2-request.c
src/lib-oauth2/oauth2.c

index 58cebed07a633728c899f371b52046545ea1f086..96d37abd394479013f5decee29bd9bc0d8f168b1 100644 (file)
@@ -159,6 +159,33 @@ oauth2_request_response(const struct http_response *response,
        oauth2_parse_json(req);
 }
 
+void oauth2_request_set_headers(struct oauth2_request *req,
+                               const struct oauth2_request_input *input)
+{
+       if (!req->set->send_auth_headers)
+               return;
+       if (input->service != NULL) {
+               http_client_request_add_header(
+                       req->req, "X-Dovecot-Auth-Service", input->service);
+       }
+       if (input->local_ip.family != 0) {
+               const char *addr;
+               if (net_ipport2str(&input->local_ip, input->local_port,
+                                  &addr) == 0)  {
+                       http_client_request_add_header(
+                               req->req, "X-Dovecot-Auth-Local", addr);
+               }
+       }
+       if (input->remote_ip.family != 0) {
+               const char *addr;
+               if (net_ipport2str(&input->remote_ip, input->remote_port,
+                                  &addr) == 0) {
+                       http_client_request_add_header(
+                               req->req, "X-Dovecot-Auth-Remote", addr);
+               }
+       }
+}
+
 static struct oauth2_request *
 oauth2_request_start(const struct oauth2_settings *set,
                     const struct oauth2_request_input *input,
index 37f533aa3fe7b9a9e0529f38f06f423b40675990..27ab27d4f48bef5227788d0d68dabc9e91dfe821 100644 (file)
@@ -1,8 +1,8 @@
 /* Copyright (c) 2017-2018 Dovecot authors, see the included COPYING file */
 
 #include "lib.h"
+#include "buffer.h"
 #include "istream.h"
-#include "http-client.h"
 #include "json-tree.h"
 #include "oauth2.h"
 #include "oauth2-private.h"
@@ -40,30 +40,3 @@ bool oauth2_valid_token(const char *token)
                return FALSE;
        return TRUE;
 }
-
-void oauth2_request_set_headers(struct oauth2_request *req,
-                               const struct oauth2_request_input *input)
-{
-       if (!req->set->send_auth_headers)
-               return;
-       if (input->service != NULL) {
-               http_client_request_add_header(
-                       req->req, "X-Dovecot-Auth-Service", input->service);
-       }
-       if (input->local_ip.family != 0) {
-               const char *addr;
-               if (net_ipport2str(&input->local_ip, input->local_port,
-                                  &addr) == 0)  {
-                       http_client_request_add_header(
-                               req->req, "X-Dovecot-Auth-Local", addr);
-               }
-       }
-       if (input->remote_ip.family != 0) {
-               const char *addr;
-               if (net_ipport2str(&input->remote_ip, input->remote_port,
-                                  &addr) == 0) {
-                       http_client_request_add_header(
-                               req->req, "X-Dovecot-Auth-Remote", addr);
-               }
-       }
-}