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,
/* 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"
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);
- }
- }
-}