]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: mech-dovecot-token - Create and use definition for mechanism name
authorStephan Bosch <stephan.bosch@open-xchange.com>
Thu, 5 Oct 2023 16:56:09 +0000 (18:56 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Thu, 9 Oct 2025 08:41:22 +0000 (08:41 +0000)
src/auth/auth-client-connection.c
src/auth/auth-sasl-mech-dovecot-token.c
src/auth/test-mech.c
src/imap-urlauth-login/imap-urlauth-login.c
src/lib-auth-client/auth-sasl-common.h

index cbc4339274fb3154abd484b03c36e709ca85ae33..e4c03a46624c033b3ee88f8f6de4f074de8e1332 100644 (file)
@@ -10,7 +10,6 @@
 #include "str-sanitize.h"
 #include "randgen.h"
 #include "master-service.h"
-#include "sasl-server-protected.h" // FIXME: remove
 #include "auth-sasl.h"
 #include "auth-request-handler.h"
 #include "auth-client-interface.h"
@@ -193,8 +192,8 @@ static void auth_client_finish_handshake(struct auth_client_connection *conn)
                return;
 
        if (conn->token_auth) {
-               mechanisms = t_strconcat("MECH\t",
-                       mech_dovecot_token.name, "\tprivate\n", NULL);
+               mechanisms = "MECH\t"
+                       AUTH_SASL_MECH_NAME_DOVECOT_TOKEN "\tprivate\n";
        } else {
                mechanisms = auth_sasl_mechs_get_handshake();
                if (conn->conn.minor_version >= AUTH_CLIENT_MINOR_VERSION_CHANNEL_BINDING)
index 365f7be30834812b38d4a450b4238a7744bade19..d9baf47718e7a4d36e8292f2b872bd297f041ed4 100644 (file)
@@ -6,6 +6,7 @@
 #include "auth-common.h"
 #include "safe-memset.h"
 #include "sasl-server-protected.h"
+#include "auth-sasl.h"
 #include "auth-token.h"
 
 static void
@@ -74,7 +75,7 @@ static const struct sasl_server_mech_funcs mech_dovecot_token_funcs = {
 };
 
 const struct sasl_server_mech_def mech_dovecot_token = {
-       .name = "DOVECOT-TOKEN",
+       .name = AUTH_SASL_MECH_NAME_DOVECOT_TOKEN,
 
        .flags = SASL_MECH_SEC_PRIVATE | SASL_MECH_SEC_ALLOW_NULS,
        .passdb_need = SASL_MECH_PASSDB_NEED_NOTHING,
index 39648deea5bc54bc0c8021a0e46aae69fb6ca09e..ca3f563a7239db58d4ad5aaa1eee2ee33ef2fce5 100644 (file)
@@ -108,7 +108,7 @@ static void test_mech_prepare_request(struct auth_request **request_r,
 
        struct auth *auth = auth_default_protocol();
        const struct sasl_server_mech *mech;
-       if (strcmp(mech_name, "DOVECOT-TOKEN") == 0)
+       if (strcmp(mech_name, AUTH_SASL_MECH_NAME_DOVECOT_TOKEN) == 0)
                mech = auth->sasl_mech_dovecot_token;
        else
                mech = sasl_server_mech_find(auth->sasl_inst, mech_name);
index 23a76f6c81d0afdc7d3259ee6754b674ab1bcac0..31648034cba00683143d233c1cde6a266afa7de6 100644 (file)
@@ -108,8 +108,8 @@ static void imap_urlauth_client_handle_input(struct client *client)
                base64_encode(str_data(auth_data),
                              str_len(auth_data), init_resp);
 
-               (void)client_auth_begin_private(client, "DOVECOT-TOKEN",
-                                               str_c(init_resp));
+               (void)client_auth_begin_private(client,
+                       AUTH_SASL_MECH_NAME_DOVECOT_TOKEN, str_c(init_resp));
        } T_END;
 }
 
index 3786a10a575631b0744b49335241d7adf3b9418b..565d2bfc3324f083b24a96fb42f6eb0024e99c51 100644 (file)
@@ -4,5 +4,6 @@
 #include "sasl-common.h"
 
 #define AUTH_SASL_MECH_NAME_APOP               "APOP"
+#define AUTH_SASL_MECH_NAME_DOVECOT_TOKEN      "DOVECOT-TOKEN"
 
 #endif