]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: sasl-server-mech-oauth2 - Move mech_oauth2_initialize to auth-sasl-mech-oauth2.c
authorStephan Bosch <stephan.bosch@open-xchange.com>
Thu, 3 Oct 2024 00:26:33 +0000 (02:26 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Thu, 9 Oct 2025 08:41:22 +0000 (08:41 +0000)
src/auth/Makefile.am
src/auth/auth-sasl-mech-oauth2.c
src/auth/auth-sasl-oauth2.h [new file with mode: 0644]
src/auth/main.c
src/auth/mech.c
src/auth/sasl-server-mech-oauth2.c
src/auth/sasl-server-protected.h

index 23e111a6e3755987ce970932d4332f2e91b67c85..9ee3061ba86f8133685c002681235f256912f10e 100644 (file)
@@ -155,6 +155,7 @@ headers = \
        auth-request-handler-private.h \
        auth-request-var-expand.h \
        auth-sasl.h \
+       auth-sasl-oauth2.h \
        auth-settings.h \
        auth-fields.h \
        auth-token.h \
index 9e540dfdf574d9e8969ea379ec6c245b340d6f4e..5b57c5490e8a89663936378d7c1447bacf890c18 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "auth-common.h"
 #include "auth-sasl.h"
+#include "auth-sasl-oauth2.h"
 #include "auth-request.h"
 
 static void
@@ -161,3 +162,16 @@ auth_sasl_oauth2_verify_token(struct oauth2_auth_request *oauth2_req,
                        mech_oauth2_verify_token_input_args, oauth2_req);
        }
 }
+
+void mech_oauth2_initialize(void)
+{
+       const char *mech, *error;
+       array_foreach_elem(&global_auth_settings->mechanisms, mech) {
+               if (strcasecmp(mech, mech_xoauth2.mech_name) == 0 ||
+                   strcasecmp(mech, mech_oauthbearer.mech_name) == 0) {
+                       if (db_oauth2_init(auth_event, FALSE,
+                                          &db_oauth2, &error) < 0)
+                               i_fatal("Cannot initialize oauth2: %s", error);
+               }
+       }
+}
diff --git a/src/auth/auth-sasl-oauth2.h b/src/auth/auth-sasl-oauth2.h
new file mode 100644 (file)
index 0000000..73dff0f
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef AUTH_SASL_OAUTH2_H
+#define AUTH_SASL_OAUTH2_H
+
+void mech_oauth2_initialize(void);
+
+#endif
index a85b8dca3927ad24193743e148be6c6d7184f147..903a4f17ac67e724664a32ff7f9b890ce624dffa 100644 (file)
@@ -31,6 +31,7 @@
 #include "auth-master-connection.h"
 #include "auth-client-connection.h"
 #include "auth-policy.h"
+#include "auth-sasl-oauth2.h"
 #include "db-oauth2.h"
 
 #include <unistd.h>
@@ -180,6 +181,7 @@ static void main_preinit(void)
 
        dict_drivers_register_builtin();
        mech_init(global_auth_settings);
+       mech_oauth2_initialize();
        mech_reg = mech_register_init(global_auth_settings);
        auths_preinit(NULL, global_auth_settings, mech_reg, protocols);
 
index 5bc37cf81cd9f319dda1afbbed193d1b070a9ca5..8668c818de96cdd6b749171c38d44eec1fbc3c47 100644 (file)
@@ -213,7 +213,6 @@ void mech_init(const struct auth_settings *set)
 #endif
        mech_register_module(&mech_oauthbearer);
        mech_register_module(&mech_xoauth2);
-       mech_oauth2_initialize();
 }
 
 void mech_deinit(const struct auth_settings *set)
index 17d34b06ee4602e228b791c387daf6850522bd58..69a0f1406d1868c91d195075d62d6cddf81ac18c 100644 (file)
@@ -334,16 +334,3 @@ const struct sasl_server_mech_def mech_xoauth2 = {
        .auth_initial = sasl_server_mech_generic_auth_initial,
        .auth_continue = mech_xoauth2_auth_continue,
 };
-
-void mech_oauth2_initialize(void)
-{
-       const char *mech, *error;
-       array_foreach_elem(&global_auth_settings->mechanisms, mech) {
-               if (strcasecmp(mech, mech_xoauth2.mech_name) == 0 ||
-                   strcasecmp(mech, mech_oauthbearer.mech_name) == 0) {
-                       if (db_oauth2_init(auth_event, FALSE,
-                                          &db_oauth2, &error) < 0)
-                               i_fatal("Cannot initialize oauth2: %s", error);
-               }
-       }
-}
index bf5d94d6b78905e625589f3c22917c9d1e37aab3..24a541a85cfdb20d109108e3ab0b30a275dbc3de 100644 (file)
@@ -75,8 +75,6 @@ mech_register_find(const struct mechanisms_register *reg, const char *name);
 void mech_init(const struct auth_settings *set);
 void mech_deinit(const struct auth_settings *set);
 
-void mech_oauth2_initialize(void);
-
 /*
  * Request
  */