@@ -111,6 +111,10 @@ Logs warning message.
111111
112112##### ` auth_request#response_from_template(template) `
113113
114+ [[ removed,auth_lua_string_response_removed]] This was a bit unsafe
115+ function. Return the table instead with the necessary
116+ ` auth_request#var_expand() ` calls.
117+
114118Takes in ` key=value ` template and expands it using ` var_expand() ` and produces
115119table suitable for passdb result.
116120
@@ -216,25 +220,29 @@ Lua passdb supports two modes of function:
216220
217221Function signature is ` auth_passdb_lookup(request) ` .
218222
219- Function must return a tuple, which contains a return code, and also
220- additionally a string or table.
223+ Function must return a tuple, which contains:
224+ * ` dovecot.auth.PASSDB_RESULT_OK ` and extra fields table
225+ * ` dovecot.auth.PASSDB_RESULT_* ` error and error string
221226
222- Table must be in key-value format, as it will be imported into auth request.
227+ The extra fields table must be in key-value format, as it will be imported into
228+ auth request.
223229
224- The string must be in ` key=value ` format, except if return code indicates
225- internal error, the second parameter can be used as error string .
230+ [[ removed,auth_lua_string_response_removed ]] String can no longer be returned
231+ for ` PASSDB_RESULT_OK ` .
226232
227233#### Password Verification Database
228234
229235Function signature is ` auth_password_verify(request, password) ` .
230236
231- Function must return a tuple, which contains a return code, and also
232- additionally a string or table.
237+ Function must return a tuple, which contains:
238+ * ` dovecot.auth.PASSDB_RESULT_OK ` and extra fields table
239+ * ` dovecot.auth.PASSDB_RESULT_* ` error and error string
233240
234- Table must be in key-value format, as it will be imported into auth request.
241+ The extra fields table must be in key-value format, as it will be imported into
242+ auth request.
235243
236- The string must be in ` key=value ` format, except if return code indicates
237- internal error, the second parameter can be used as error string .
244+ [[ removed,auth_lua_string_response_removed ]] String can no longer be returned
245+ for ` PASSDB_RESULT_OK ` .
238246
239247## userdb
240248
@@ -254,13 +262,15 @@ Lua userdb supports both single user lookup and iteration.
254262
255263Function signature is ` auth_userdb_lookup(request) ` .
256264
257- The function must return a tuple, which contains a return code, and also
258- additionally a string or table.
265+ Function must return a tuple, which contains:
266+ * ` dovecot.auth.USERDB_RESULT_OK ` and extra fields table
267+ * ` dovecot.auth.USERDB_RESULT_* ` error and error string
259268
260- Table must be in key-value format, as it will be imported into auth request.
269+ The extra fields table must be in key-value format, as it will be imported into
270+ auth request.
261271
262- The string must be in key=value format, except if return code indicates
263- internal error, the second parameter can be used as error string .
272+ [[ removed,auth_lua_string_response_removed ]] String can no longer be returned
273+ for ` USERDB_RESULT_OK ` .
264274
265275#### User Iteration
266276
@@ -277,14 +287,14 @@ The iteration will hold the whole user database in memory during iteration.
277287``` lua:line-numbers
278288function auth_passdb_lookup(req)
279289 if req.user == "testuser1" then
280- return dovecot.auth.PASSDB_RESULT_OK, " password= pass"
290+ return dovecot.auth.PASSDB_RESULT_OK, { password = " pass" }
281291 end
282292 return dovecot.auth.PASSDB_RESULT_USER_UNKNOWN, "no such user"
283293end
284294
285295function auth_userdb_lookup(req)
286296 if req.user == "testuser1" then
287- return dovecot.auth.USERDB_RESULT_OK, " uid= vmail gid= vmail"
297+ return dovecot.auth.USERDB_RESULT_OK, { uid = " vmail", gid = " vmail" }
288298 end
289299 return dovecot.auth.USERDB_RESULT_USER_UNKNOWN, "no such user"
290300end
@@ -319,12 +329,12 @@ function auth_passdb_lookup(req)
319329 for user, pass in string.gmatch(line, "(%w+)%s(.+)") do
320330 if (user == req.username) then
321331 -- you can add additional information here, like userdb_uid
322- return dovecot.auth.PASSDB_RESULT_OK, " password=" .. pass
332+ return dovecot.auth.PASSDB_RESULT_OK, { password = pass }
323333 end
324334 end
325335 end
326336
327- return dovecot.auth.PASSDB_RESULT_USER_UNKNOWN, ""
337+ return dovecot.auth.PASSDB_RESULT_USER_UNKNOWN
328338end
329339```
330340
@@ -349,18 +359,18 @@ function auth_passdb_lookup(req)
349359 res = db_lookup(req.username)
350360 if res.result == 0 then
351361 -- you can add additional information here for passdb
352- return dovecot.auth.PASSDB_RESULT_OK, " password=" .. res.password
362+ return dovecot.auth.PASSDB_RESULT_OK, { password = res.password }
353363 end
354- return dovecot.auth.PASSDB_RESULT_USER_UNKNOWN, ""
364+ return dovecot.auth.PASSDB_RESULT_USER_UNKNOWN
355365end
356366
357367function auth_userdb_lookup(req)
358368 res = db_lookup(req.username)
359369 if res.result == 0 then
360370 -- you can add additional information here for userdb, like uid or home
361- return dovecot.auth.USERDB_RESULT_OK, " uid= vmail gid= vmail"
371+ return dovecot.auth.USERDB_RESULT_OK, { uid = " vmail, gid = " vmail" }
362372 end
363- return dovecot.auth.USERDB_RESULT_USER_UNKNOWN, ""
373+ return dovecot.auth.USERDB_RESULT_USER_UNKNOWN
364374end
365375
366376function auth_userdb_iterate()
0 commit comments