int auth_request_handler_auth_begin(struct auth_request_handler *handler,
const char *const *args)
{
- const struct mech_module *mech;
+ const struct sasl_server_mech_def *mech;
struct auth_request *request;
const char *name, *arg, *initial_resp;
void *initial_resp_data;
}
struct auth_request *
-auth_request_new(const struct mech_module *mech, struct event *parent_event)
+auth_request_new(const struct sasl_server_mech_def *mech,
+ struct event *parent_event)
{
struct auth_request *request;
static bool
auth_request_mechanism_accepted(const char *const *mechs,
- const struct mech_module *mech)
+ const struct sasl_server_mech_def *mech)
{
/* no filter specified, anything goes */
if (mechs == NULL) return TRUE;
proxy DNS lookups) */
enum passdb_result passdb_result;
- const struct mech_module *mech;
+ const struct sasl_server_mech_def *mech;
/* Protocol-specific settings */
const struct auth_settings *protocol_set;
/* Currently active settings. May be the same as protocol_set, but
extern unsigned int auth_request_state_count[AUTH_REQUEST_STATE_MAX];
struct auth_request *
-auth_request_new(const struct mech_module *mech, struct event *parent_event);
+auth_request_new(const struct sasl_server_mech_def *mech,
+ struct event *parent_event);
struct auth_request *auth_request_new_dummy(struct event *parent_event);
void auth_request_init(struct auth_request *request);
struct auth *auth_request_get_auth(struct auth_request *request);
return &request->auth_request;
}
-const struct mech_module mech_apop = {
+const struct sasl_server_mech_def mech_apop = {
.mech_name = "APOP",
.flags = SASL_MECH_SEC_PRIVATE | SASL_MECH_SEC_DICTIONARY |
return request;
}
-const struct mech_module mech_dovecot_token = {
+const struct sasl_server_mech_def mech_dovecot_token = {
.mech_name = "DOVECOT-TOKEN",
.flags = SASL_MECH_SEC_PRIVATE | SASL_MECH_SEC_ALLOW_NULS,
}
static bool
-auth_mech_verify_passdb(const struct auth *auth, const struct mech_module *mech)
+auth_mech_verify_passdb(const struct auth *auth,
+ const struct sasl_server_mech_def *mech)
{
switch (mech->passdb_need) {
case SASL_MECH_PASSDB_NEED_NOTHING:
static struct mech_module_list *mech_modules;
-void mech_register_module(const struct mech_module *module)
+void mech_register_module(const struct sasl_server_mech_def *module)
{
struct mech_module_list *list;
i_assert(strcmp(module->mech_name, t_str_ucase(module->mech_name)) == 0);
mech_modules = list;
}
-void mech_unregister_module(const struct mech_module *module)
+void mech_unregister_module(const struct sasl_server_mech_def *module)
{
struct mech_module_list **pos, *list;
}
}
-const struct mech_module *mech_module_find(const char *name)
+const struct sasl_server_mech_def *mech_module_find(const char *name)
{
struct mech_module_list *list;
name = t_str_ucase(name);
return NULL;
}
-extern const struct mech_module mech_plain;
-extern const struct mech_module mech_login;
-extern const struct mech_module mech_apop;
-extern const struct mech_module mech_cram_md5;
-extern const struct mech_module mech_digest_md5;
-extern const struct mech_module mech_external;
-extern const struct mech_module mech_otp;
-extern const struct mech_module mech_scram_sha1;
-extern const struct mech_module mech_scram_sha1_plus;
-extern const struct mech_module mech_scram_sha256;
-extern const struct mech_module mech_scram_sha256_plus;
-extern const struct mech_module mech_anonymous;
+extern const struct sasl_server_mech_def mech_plain;
+extern const struct sasl_server_mech_def mech_login;
+extern const struct sasl_server_mech_def mech_apop;
+extern const struct sasl_server_mech_def mech_cram_md5;
+extern const struct sasl_server_mech_def mech_digest_md5;
+extern const struct sasl_server_mech_def mech_external;
+extern const struct sasl_server_mech_def mech_otp;
+extern const struct sasl_server_mech_def mech_scram_sha1;
+extern const struct sasl_server_mech_def mech_scram_sha1_plus;
+extern const struct sasl_server_mech_def mech_scram_sha256;
+extern const struct sasl_server_mech_def mech_scram_sha256_plus;
+extern const struct sasl_server_mech_def mech_anonymous;
#ifdef HAVE_GSSAPI
-extern const struct mech_module mech_gssapi;
+extern const struct sasl_server_mech_def mech_gssapi;
#endif
#ifdef HAVE_GSSAPI_SPNEGO
-extern const struct mech_module mech_gssapi_spnego;
+extern const struct sasl_server_mech_def mech_gssapi_spnego;
#endif
-extern const struct mech_module mech_winbind_ntlm;
-extern const struct mech_module mech_winbind_spnego;
-extern const struct mech_module mech_oauthbearer;
-extern const struct mech_module mech_xoauth2;
+extern const struct sasl_server_mech_def mech_winbind_ntlm;
+extern const struct sasl_server_mech_def mech_winbind_spnego;
+extern const struct sasl_server_mech_def mech_oauthbearer;
+extern const struct sasl_server_mech_def mech_xoauth2;
static void mech_register_add(struct mechanisms_register *reg,
- const struct mech_module *mech)
+ const struct sasl_server_mech_def *mech)
{
struct mech_module_list *list;
string_t *handshake;
mech_register_init(const struct auth_settings *set)
{
struct mechanisms_register *reg;
- const struct mech_module *mech;
+ const struct sasl_server_mech_def *mech;
const char *name;
pool_t pool;
pool_unref(®->pool);
}
-const struct mech_module *
+const struct sasl_server_mech_def *
mech_register_find(const struct mechanisms_register *reg, const char *name)
{
const struct mech_module_list *list;
return request;
}
-const struct mech_module mech_anonymous = {
+const struct sasl_server_mech_def mech_anonymous = {
.mech_name = "ANONYMOUS",
.flags = SASL_MECH_SEC_ANONYMOUS | SASL_MECH_SEC_ALLOW_NULS,
return &request->auth_request;
}
-const struct mech_module mech_cram_md5 = {
+const struct sasl_server_mech_def mech_cram_md5 = {
.mech_name = "CRAM-MD5",
.flags = SASL_MECH_SEC_DICTIONARY | SASL_MECH_SEC_ACTIVE,
return &request->auth_request;
}
-const struct mech_module mech_digest_md5 = {
+const struct sasl_server_mech_def mech_digest_md5 = {
.mech_name = "DIGEST-MD5",
.flags = SASL_MECH_SEC_DICTIONARY | SASL_MECH_SEC_ACTIVE |
return request;
}
-const struct mech_module mech_external = {
+const struct sasl_server_mech_def mech_external = {
.mech_name = "EXTERNAL",
.flags = 0,
pool_unref(&auth_request->pool);
}
-const struct mech_module mech_gssapi = {
+const struct sasl_server_mech_def mech_gssapi = {
.mech_name = "GSSAPI",
.flags = SASL_MECH_SEC_ALLOW_NULS,
/* MIT Kerberos v1.5+ and Heimdal v0.7+ support SPNEGO for Kerberos tickets
internally. Nothing else needs to be done here. Note, however, that this does
not support SPNEGO when the only available credential is NTLM. */
-const struct mech_module mech_gssapi_spnego = {
+const struct sasl_server_mech_def mech_gssapi_spnego = {
.mech_name = "GSS-SPNEGO",
.flags = SASL_MECH_SEC_ALLOW_NULS,
void mech_gssapi_deinit(void)
{
#ifdef HAVE_GSSAPI_SPNEGO
- const struct mech_module *mech;
+ const struct sasl_server_mech_def *mech;
mech = mech_module_find(mech_gssapi_spnego.mech_name);
if (mech != NULL && mech->auth_new == mech_gssapi_auth_new)
return request;
}
-const struct mech_module mech_login = {
+const struct sasl_server_mech_def mech_login = {
.mech_name = "LOGIN",
.flags = SASL_MECH_SEC_PLAINTEXT,
bool verifying_token:1;
};
-const struct mech_module mech_oauthbearer;
-const struct mech_module mech_xoauth2;
+const struct sasl_server_mech_def mech_oauthbearer;
+const struct sasl_server_mech_def mech_xoauth2;
static struct db_oauth2 *db_oauth2 = NULL;
return &request->request;
}
-const struct mech_module mech_oauthbearer = {
+const struct sasl_server_mech_def mech_oauthbearer = {
.mech_name = "OAUTHBEARER",
/* while this does not transfer plaintext password,
.auth_free = sasl_server_mech_generic_auth_free,
};
-const struct mech_module mech_xoauth2 = {
+const struct sasl_server_mech_def mech_xoauth2 = {
.mech_name = "XOAUTH2",
.flags = SASL_MECH_SEC_PLAINTEXT,
* Mechanism
*/
-const struct mech_module mech_otp = {
+const struct sasl_server_mech_def mech_otp = {
.mech_name = "OTP",
.flags = SASL_MECH_SEC_DICTIONARY | SASL_MECH_SEC_ACTIVE |
return request;
}
-const struct mech_module mech_plain = {
+const struct sasl_server_mech_def mech_plain = {
.mech_name = "PLAIN",
.flags = SASL_MECH_SEC_PLAINTEXT | SASL_MECH_SEC_ALLOW_NULS,
pool_unref(&auth_request->pool);
}
-const struct mech_module mech_scram_sha1 = {
+const struct sasl_server_mech_def mech_scram_sha1 = {
.mech_name = "SCRAM-SHA-1",
.flags = SASL_MECH_SEC_MUTUAL_AUTH,
.auth_free = mech_scram_auth_free,
};
-const struct mech_module mech_scram_sha1_plus = {
+const struct sasl_server_mech_def mech_scram_sha1_plus = {
.mech_name = "SCRAM-SHA-1-PLUS",
.flags = SASL_MECH_SEC_MUTUAL_AUTH | SASL_MECH_SEC_CHANNEL_BINDING,
.auth_free = mech_scram_auth_free,
};
-const struct mech_module mech_scram_sha256 = {
+const struct sasl_server_mech_def mech_scram_sha256 = {
.mech_name = "SCRAM-SHA-256",
.flags = SASL_MECH_SEC_MUTUAL_AUTH,
.auth_free = mech_scram_auth_free,
};
-const struct mech_module mech_scram_sha256_plus = {
+const struct sasl_server_mech_def mech_scram_sha256_plus = {
.mech_name = "SCRAM-SHA-256-PLUS",
.flags = SASL_MECH_SEC_MUTUAL_AUTH | SASL_MECH_SEC_CHANNEL_BINDING,
return do_auth_new(&winbind_spnego_context);
}
-const struct mech_module mech_winbind_ntlm = {
+const struct sasl_server_mech_def mech_winbind_ntlm = {
.mech_name = "NTLM",
.flags = SASL_MECH_SEC_DICTIONARY | SASL_MECH_SEC_ACTIVE |
.auth_free = sasl_server_mech_generic_auth_free,
};
-const struct mech_module mech_winbind_spnego = {
+const struct sasl_server_mech_def mech_winbind_spnego = {
.mech_name = "GSS-SPNEGO",
.flags = SASL_MECH_SEC_ALLOW_NULS,
struct auth_request;
-struct mech_module {
+struct sasl_server_mech_def {
const char *mech_name;
enum sasl_mech_security_flags flags;
struct mech_module_list {
struct mech_module_list *next;
- const struct mech_module *module;
+ const struct sasl_server_mech_def *module;
};
struct mechanisms_register {
* Mechanism
*/
-extern const struct mech_module mech_dovecot_token;
+extern const struct sasl_server_mech_def mech_dovecot_token;
-void mech_register_module(const struct mech_module *module);
-void mech_unregister_module(const struct mech_module *module);
-const struct mech_module *mech_module_find(const char *name);
+void mech_register_module(const struct sasl_server_mech_def *module);
+void mech_unregister_module(const struct sasl_server_mech_def *module);
+const struct sasl_server_mech_def *mech_module_find(const char *name);
void sasl_server_mech_generic_auth_initial(struct auth_request *request,
const unsigned char *data,
struct mechanisms_register *
mech_register_init(const struct auth_settings *set);
void mech_register_deinit(struct mechanisms_register **reg);
-const struct mech_module *
+const struct sasl_server_mech_def *
mech_register_find(const struct mechanisms_register *reg, const char *name);
void mech_init(const struct auth_settings *set);
};
static struct auth_request *
-test_auth_request_init(const struct mech_module *mech)
+test_auth_request_init(const struct sasl_server_mech_def *mech)
{
struct auth_request *request;
pool_t pool = pool_alloconly_create("test auth request", 1024);
#define UCHAR_LEN(str) (const unsigned char *)(str), sizeof(str)-1
-extern const struct mech_module mech_anonymous;
-extern const struct mech_module mech_apop;
-extern const struct mech_module mech_cram_md5;
-extern const struct mech_module mech_digest_md5;
-extern const struct mech_module mech_external;
-extern const struct mech_module mech_login;
-extern const struct mech_module mech_oauthbearer;
-extern const struct mech_module mech_otp;
-extern const struct mech_module mech_plain;
-extern const struct mech_module mech_scram_sha1;
-extern const struct mech_module mech_scram_sha256;
-extern const struct mech_module mech_xoauth2;
+extern const struct sasl_server_mech_def mech_anonymous;
+extern const struct sasl_server_mech_def mech_apop;
+extern const struct sasl_server_mech_def mech_cram_md5;
+extern const struct sasl_server_mech_def mech_digest_md5;
+extern const struct sasl_server_mech_def mech_external;
+extern const struct sasl_server_mech_def mech_login;
+extern const struct sasl_server_mech_def mech_oauthbearer;
+extern const struct sasl_server_mech_def mech_otp;
+extern const struct sasl_server_mech_def mech_plain;
+extern const struct sasl_server_mech_def mech_scram_sha1;
+extern const struct sasl_server_mech_def mech_scram_sha256;
+extern const struct sasl_server_mech_def mech_xoauth2;
struct test_case {
- const struct mech_module *mech;
+ const struct sasl_server_mech_def *mech;
const unsigned char *in;
size_t len;
const char *username;
}
static void test_mech_prepare_request(struct auth_request **request_r,
- const struct mech_module *mech,
+ const struct sasl_server_mech_def *mech,
struct auth_request_handler *handler,
unsigned int running_test,
const struct test_case *test_case)
for (unsigned int running_test = 0; running_test < N_ELEMENTS(tests);
running_test++) T_BEGIN {
struct test_case *test_case = &tests[running_test];
- const struct mech_module *mech = test_case->mech;
+ const struct sasl_server_mech_def *mech = test_case->mech;
struct auth_request *request;
const char *testname = t_strdup_printf("auth mech %s %d/%zu",
mech->mech_name,