/* Copyright (c) 2016-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "net.h"
#include "str.h"
#include "istream.h"
#include "ioloop.h"
#include "base64.h"
#include "hex-binary.h"
#include "hash-method.h"
#include "http-url.h"
#include "http-client.h"
#include "json-parser.h"
#include "auth-request.h"
#include "auth-penalty.h"
#include "auth-settings.h"
#include "auth-policy.h"
#include "iostream-ssl.h"
.max_connect_attempts = 1,
.max_idle_time_msecs = 10000,
.max_parallel_connections = 100,
.debug = 0,
};
static char *auth_policy_json_template;
struct policy_lookup_ctx {
const char *url;
bool expect_result;
int result;
const char *message;
void *callback_context;
enum {
POLICY_RESULT = 0,
} parse_state;
bool parse_error;
};
struct policy_template_keyvalue {
const char *key;
const char *value;
};
static
const struct policy_template_keyvalue *b)
{
}
static
{
}
static
{
const char *ptr;
}
}
static
{
}
static
{
return;
}
return;
}
/* nothing to do, again */
return;
}
break;
}
break;
}
break;
}
}
}
void auth_policy_init(void)
{
if (global_auth_settings->debug)
/* prepare template */
const char **ptr;
} else {
}
}
i_fatal("auth_policy_request_attributes contains invalid value");
}
/* then we sort it */
/* and build a template string */
}
}
void auth_policy_deinit(void)
{
if (http_client != NULL)
}
static
{
}
}
static
{
const char *value;
int ret;
if (type != JSON_TYPE_OBJECT_KEY)
continue;
else
continue;
break;
if (type != JSON_TYPE_STRING)
break;
if (*value != '\0')
} else {
break;
}
}
return;
"Error reading policy server result: %s",
"Policy server result was too short");
} else if (ret == 1) {
"Policy server response was malformed");
} else {
"Policy server response JSON parse error: %s", error);
}
if (context->parse_error) {
}
/* set message here */
"Policy response %d with message: %s",
}
} else {
}
auth_request_log_info(context->request, "policy", "Authentication failure due to policy server refusal%s%s",
}
}
}
static
void *ctx)
{
"Policy server HTTP error: %s",
return;
}
if (context->expect_result)
"Policy server result was empty");
return;
}
if (context->expect_result) {
} else {
}
}
static
{
const char *error;
return;
}
const char *ptr;
} else {
}
}
/* allow empty password */
}
i_stream_unref(&is);
}
static
{
}
static
const char *hashed_password, const char *requested_username)
{
&count);
return table;
}
static
const char *password, bool include_success)
{
unsigned char *ptr;
const char *requested_username;
else
requested_username = "";
/* use +1 to make sure \0 gets included */
}
const char *error;
auth_policy_escape_function, &error) <= 0) {
"Failed to expand auth policy template: %s", error);
}
if (include_success) {
else
}
else
}
static
{
else
}
{
return;
}
T_BEGIN {
} T_END;
}
{
return;
return;
T_BEGIN {
} T_END;
}