base64_encode(str_data(auth_data),
str_len(auth_data), init_resp);
- (void)client_auth_begin(client, "DOVECOT-TOKEN",
- str_c(init_resp));
+ (void)client_auth_begin_private(client, "DOVECOT-TOKEN",
+ str_c(init_resp));
} T_END;
}
client_unref(&client);
}
-int client_auth_begin(struct client *client, const char *mech_name,
- const char *init_resp)
+static int
+client_auth_begin_common(struct client *client, const char *mech_name,
+ bool private, const char *init_resp)
{
if (!client->secured && strcmp(client->ssl_set->ssl, "required") == 0) {
if (client->set->auth_verbose) {
client_ref(client);
client->auth_initializing = TRUE;
sasl_server_auth_begin(client, login_binary->protocol, mech_name,
- init_resp, sasl_callback);
+ private, init_resp, sasl_callback);
client->auth_initializing = FALSE;
if (!client->authenticating)
return 1;
return 0;
}
+int client_auth_begin(struct client *client, const char *mech_name,
+ const char *init_resp)
+{
+ return client_auth_begin_common(client, mech_name, FALSE, init_resp);
+}
+
+int client_auth_begin_private(struct client *client, const char *mech_name,
+ const char *init_resp)
+{
+ return client_auth_begin_common(client, mech_name, TRUE, init_resp);
+}
+
bool client_check_plaintext_auth(struct client *client, bool pass_sent)
{
bool ssl_required = (strcmp(client->ssl_set->ssl, "required") == 0);
void client_auth_parse_response(struct client *client);
int client_auth_begin(struct client *client, const char *mech_name,
const char *init_resp);
+int client_auth_begin_private(struct client *client, const char *mech_name,
+ const char *init_resp);
bool client_check_plaintext_auth(struct client *client, bool pass_sent);
int client_auth_read_line(struct client *client);
void sasl_server_auth_begin(struct client *client,
const char *service, const char *mech_name,
- const char *initial_resp_base64,
+ bool private, const char *initial_resp_base64,
sasl_server_callback_t *callback)
{
struct auth_request_info info;
client->sasl_callback = callback;
mech = sasl_server_find_available_mech(client, mech_name);
- if (mech == NULL) {
+ if (mech == NULL ||
+ ((mech->flags & MECH_SEC_PRIVATE) != 0 && !private)) {
sasl_server_auth_failed(client,
"Unsupported authentication mechanism.",
AUTH_CLIENT_FAIL_CODE_MECH_INVALID);
return;
}
+ i_assert(!private || (mech->flags & MECH_SEC_PRIVATE) != 0);
+
if (!client->secured && client->set->disable_plaintext_auth &&
(mech->flags & MECH_SEC_PLAINTEXT) != 0) {
sasl_server_auth_failed(client,
void sasl_server_auth_begin(struct client *client,
const char *service, const char *mech_name,
- const char *initial_resp_base64,
+ bool private, const char *initial_resp_base64,
sasl_server_callback_t *callback);
void sasl_server_auth_failed(struct client *client, const char *reason,
const char *code) ATTR_NULL(3);
return TRUE;
}
- (void)client_auth_begin(client, "APOP", str_c(base64));
+ (void)client_auth_begin_private(client, "APOP", str_c(base64));
return TRUE;
}