/* Copyright (c) 2017-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "str.h"
#include "net.h"
#include "json-parser.h"
#include "istream.h"
#include "dsasl-client-private.h"
struct oauthbearer_dsasl_client {
const char *host;
const char *status;
bool output_sent;
};
static int
const char **error_r)
{
(struct oauthbearer_dsasl_client *)_client;
if (!client->output_sent) {
if (input_len > 0) {
*error_r = "Server sent non-empty initial response";
return -1;
}
} else {
/* if response is empty, authentication has *SUCCEEDED* */
if (input_len == 0)
return 0;
/* authentication has failed, try parse status.
we are only interested in extracting status if possible
so we don't really need to much error handling. */
if (jtype == JSON_TYPE_STRING ||
break;
} else if (jtype == JSON_TYPE_OBJECT_KEY &&
found_status = TRUE;
} else json_parse_skip_next(parser);
}
/* deinitialize json parser */
else {
ret = -1;
error = "Status value missing";
}
if (ret < 0)
error);
else
return -1;
}
return 0;
}
static int
const char **error_r)
{
(struct oauthbearer_dsasl_client *)_client;
*error_r = "authid not set";
return -1;
}
*error_r = "password not set";
return -1;
}
return 0;
}
static int
const char **error_r)
{
(struct oauthbearer_dsasl_client *)_client;
*error_r = "authid not set";
return -1;
}
*error_r = "password not set";
return -1;
}
return 0;
}
static int
{
(struct oauthbearer_dsasl_client *)_client;
else
return 1;
*error_r = "Invalid port value";
return -1;
}
return 1;
}
return 0;
}
static int
{
(struct oauthbearer_dsasl_client *)_client;
/* this is set to value after login attempt */
return 1;
}
return 0;
}
.name = "OAUTHBEARER",
.struct_size = sizeof(struct oauthbearer_dsasl_client),
};
.name = "XOAUTH2",
.struct_size = sizeof(struct oauthbearer_dsasl_client),
};