auth-policy.c revision 1db4d7625835a673dcb864374174bd342107a47c
#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"
#define AUTH_POLICY_DNS_SOCKET_PATH "dns-client"
static struct http_client_settings http_client_set = {
.max_connect_attempts = 1,
.max_idle_time_msecs = 10000,
.max_parallel_connections = 100,
.debug = 0,
};
static char *auth_policy_json_template;
static struct http_client *http_client;
struct policy_lookup_ctx {
struct auth_request *request;
struct http_client_request *http_request;
struct json_parser *parser;
const struct auth_settings *set;
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
int auth_policy_attribute_comparator(const struct policy_template_keyvalue *a,
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 struct policy_template_keyvalue *kvptr;
const char **ptr;
struct policy_template_keyvalue pair;
} else {
}
}
i_fatal("auth_policy_request_attributes contains invalid value");
}
/* then we sort it */
/* and build a template string */
const char *prevkey = "";
}
}
void auth_policy_deinit(void)
{
if (http_client != NULL)
}
static
void auth_policy_finish(void *ctx)
{
const char *error ATTR_UNUSED;
}
}
static
{
const char *value;
int ret;
if (type != JSON_TYPE_OBJECT_KEY)
break;
else break;
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 {
const char *error = "unknown";
"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)
{
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
const char *auth_policy_escape_function(const char *string,
{
}
static
const char *hashed_password)
{
struct var_expand_table *table;
unsigned int count = 1;
&count);
return table;
}
static
const char *password, bool include_success)
{
const struct var_expand_table *var_table;
unsigned char *ptr;
/* use +1 to make sure \0 gets included */
/* truncate it to closest byte boundary */
/* remainding bits */
/* right shift everything and left-pad with 0 */
if (bits > 0) {
}
}
if (include_success) {
else
}
}
static
{
else
}
{
return;
}
T_BEGIN {
} T_END;
}
{
return;
return;
T_BEGIN {
} T_END;
}