]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: Forgot to add mech-external.c in earlier commit.
authorTimo Sirainen <tss@iki.fi>
Tue, 26 May 2009 06:53:42 +0000 (02:53 -0400)
committerTimo Sirainen <tss@iki.fi>
Tue, 26 May 2009 06:53:42 +0000 (02:53 -0400)
--HG--
branch : HEAD

src/auth/mech-external.c [new file with mode: 0644]

diff --git a/src/auth/mech-external.c b/src/auth/mech-external.c
new file mode 100644 (file)
index 0000000..92a4834
--- /dev/null
@@ -0,0 +1,52 @@
+/* Copyright (c) 2009 Dovecot authors, see the included COPYING file */
+
+#include "auth-common.h"
+#include "passdb.h"
+#include "mech.h"
+#include "mech-plain-common.h"
+
+static void
+mech_external_auth_continue(struct auth_request *request,
+                           const unsigned char *data, size_t data_size)
+{
+       const char *authzid, *error;
+
+       authzid = t_strndup(data, data_size);
+       if (request->user == NULL) {
+               auth_request_log_info(request, "external",
+                                     "username not known");
+               auth_request_fail(request);
+        } else if (*authzid != '\0' &&
+                  !auth_request_set_login_username(request, authzid, &error)) {
+               /* invalid login username */
+               auth_request_log_info(request, "plain",
+                                     "login user: %s", error);
+               auth_request_fail(request);
+       } else {
+                auth_request_verify_plain(request, "",
+                                          plain_verify_callback);
+       }
+}
+
+static struct auth_request *mech_external_auth_new(void)
+{
+        struct auth_request *request;
+       pool_t pool;
+
+       pool = pool_alloconly_create("external_auth_request", 2048);
+       request = p_new(pool, struct auth_request, 1);
+       request->pool = pool;
+       return request;
+}
+
+const struct mech_module mech_external = {
+       "EXTERNAL",
+
+       MEMBER(flags) 0,
+       MEMBER(passdb_need) MECH_PASSDB_NEED_VERIFY_PLAIN,
+
+       mech_external_auth_new,
+       mech_generic_auth_initial,
+       mech_external_auth_continue,
+       mech_generic_auth_free
+};