]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: db-lua: Introduce auth_lua_settings
authorMarkus Valentin <markus.valentin@open-xchange.com>
Thu, 29 Feb 2024 16:12:19 +0000 (17:12 +0100)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:12 +0000 (12:34 +0200)
src/auth/db-lua.c
src/auth/db-lua.h

index d6962391e9b3f731244df348293d0761eeb7485b..cba551e1e2c7e002d5e8450f3ebbf538eae9b684 100644 (file)
@@ -17,6 +17,7 @@
 #include "passdb-template.h"
 #include "password-scheme.h"
 #include "auth-request-var-expand.h"
+#include "settings.h"
 
 #define AUTH_LUA_PASSDB_INIT "auth_passdb_init"
 #define AUTH_LUA_PASSDB_LOOKUP "auth_passdb_lookup"
@@ -37,6 +38,41 @@ struct auth_lua_userdb_iterate_context {
        ARRAY_TYPE(const_string) users;
 };
 
+#undef DEF
+#define DEF(type, name) \
+       SETTING_DEFINE_STRUCT_##type(#name, name, struct auth_lua_settings)
+
+static const struct setting_define auth_lua_setting_defines[] = {
+       { .type = SET_FILTER_NAME, .key = "passdb_lua", },
+       { .type = SET_FILTER_NAME, .key = "userdb_lua", },
+       DEF(STRLIST, auth_lua_config),
+       DEF(STR, auth_lua_file),
+
+       SETTING_DEFINE_LIST_END
+};
+
+static const struct auth_lua_settings auth_lua_default_settings = {
+       .auth_lua_file = "",
+       .auth_lua_config = ARRAY_INIT,
+};
+
+static const struct setting_keyvalue auth_lua_default_settings_keyvalue[] = {
+       { "passdb_lua/passdb_use_worker", "yes"},
+       { "userdb_lua/userdb_use_worker", "yes"},
+       { NULL, NULL }
+};
+
+const struct setting_parser_info auth_lua_setting_parser_info = {
+       .name = "auth_lua",
+
+       .defines = auth_lua_setting_defines,
+       .defaults = &auth_lua_default_settings,
+       .default_settings = auth_lua_default_settings_keyvalue,
+
+       .struct_size = sizeof(struct auth_lua_settings),
+       .pool_offset1 = 1 + offsetof(struct auth_lua_settings, pool),
+};
+
 static struct auth_request *
 auth_lua_check_auth_request(lua_State *L, int arg);
 
index 30993aacdbf0be1cd29fe9da178a79fbf460aafc..277f7e5c6d058267f5b9e2932199e569e426f02d 100644 (file)
@@ -9,6 +9,14 @@
 
 struct dlua_script;
 
+struct auth_lua_settings {
+       pool_t pool;
+       const char *auth_lua_file;
+       ARRAY_TYPE(const_string) auth_lua_config;
+};
+
+extern const struct setting_parser_info auth_lua_setting_parser_info;
+
 enum auth_lua_script_type {
        AUTH_LUA_SCRIPT_TYPE_PASSDB,
        AUTH_LUA_SCRIPT_TYPE_USERDB,