From: Stephan Bosch Date: Fri, 5 Jun 2020 19:15:47 +0000 (+0200) Subject: lib-oauth2: Move oauth2_request_set_headers() to oauth2-request.c. X-Git-Tag: 2.3.14.rc1~245 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cd3b73910fc4d0d0b99db98d17f08d4d0996e19f;p=thirdparty%2Fdovecot%2Fcore.git lib-oauth2: Move oauth2_request_set_headers() to oauth2-request.c. --- diff --git a/src/lib-oauth2/oauth2-request.c b/src/lib-oauth2/oauth2-request.c index 58cebed07a..96d37abd39 100644 --- a/src/lib-oauth2/oauth2-request.c +++ b/src/lib-oauth2/oauth2-request.c @@ -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, diff --git a/src/lib-oauth2/oauth2.c b/src/lib-oauth2/oauth2.c index 37f533aa3f..27ab27d4f4 100644 --- a/src/lib-oauth2/oauth2.c +++ b/src/lib-oauth2/oauth2.c @@ -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); - } - } -}