#include "auth-common.h"
#include "iostream-ssl.h"
-#define AUTH_POLICY_DNS_SOCKET_PATH "dns-client"
-
-static struct http_client_settings http_client_set = {
- .dns_client_socket_path = AUTH_POLICY_DNS_SOCKET_PATH,
- .max_connect_attempts = 1,
- .max_idle_time_msecs = 10000,
- .max_parallel_connections = 100,
- .user_agent = "dovecot/auth-policy-client"
-};
-
static char *auth_policy_json_template;
static struct http_client *http_client;
void auth_policy_init(void)
{
- http_client_set.pool = null_pool;
- http_client_set.request_absolute_timeout_msecs =
- global_auth_settings->policy_server_timeout_msecs;
-
- http_client = http_client_init(&http_client_set, auth_event);
+ const char *error;
+ struct event *event = event_create(auth_event);
+ event_set_ptr(event, SETTINGS_EVENT_FILTER_NAME, "auth_policy");
+ if (http_client_init_auto(event, &http_client, &error) < 0)
+ i_fatal("%s", error);
+ event_unref(&event);
/* prepare template */
DEF(TIME, failure_delay),
DEF(TIME_MSECS, internal_failure_delay),
+ { .type = SET_FILTER_NAME, .key = "auth_policy", },
DEF(STR, policy_server_url),
DEF(STR, policy_server_api_header),
- DEF(UINT, policy_server_timeout_msecs),
DEF(STR, policy_hash_mech),
DEF(STR, policy_hash_nonce),
DEF(STR_NOVARS, policy_request_attributes),
.policy_server_url = "",
.policy_server_api_header = "",
- .policy_server_timeout_msecs = 2000,
.policy_hash_mech = "sha256",
.policy_hash_nonce = "",
.policy_request_attributes = "login=%{requested_username} pwhash=%{hashed_password} remote=%{rip} device_id=%{client_id} protocol=%{protocol} session_id=%{session} fail_type=%{fail_type}",
{ NULL, NULL }
};
+static const struct setting_keyvalue auth_default_filter_settings_keyvalue[] = {
+ { "auth_policy/http_client_request_absolute_timeout", "2s" },
+ { "auth_policy/http_client_max_idle_time", "10s" },
+ { "auth_policy/http_client_max_parallel_connections", "100" },
+ { "auth_policy/http_client_user_agent", "dovecot/auth-policy-client" },
+ { NULL, NULL }
+};
+
const struct setting_parser_info auth_setting_parser_info = {
.name = "auth",
.defines = auth_setting_defines,
.defaults = &auth_default_settings,
.default_settings = auth_default_settings_keyvalue,
+ .default_filter_settings = auth_default_filter_settings_keyvalue,
.struct_size = sizeof(struct auth_settings),
.pool_offset1 = 1 + offsetof(struct auth_settings, pool),