Software /
code /
prosody-modules
Annotate
mod_auth_dovecot/mod_auth_dovecot.lua @ 410:abac17cb5032
mod_auth_dovecot: Make appending the domain name configurable. Warning: If you depend on this behaviour, add auth_append_host = true to your config
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 02 Sep 2011 00:47:31 +0200 |
parent | 342:8e9e5c7d97ff |
child | 411:b3a5439a16bf |
rev | line source |
---|---|
261
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 -- Dovecot authentication backend for Prosody |
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 -- |
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 -- Copyright (C) 2010 Javier Torres |
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 -- Copyright (C) 2008-2010 Matthew Wild |
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 -- Copyright (C) 2008-2010 Waqas Hussain |
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 -- |
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 |
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 local socket_unix = require "socket.unix"; |
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 local datamanager = require "util.datamanager"; |
312
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
10 local usermanager = require "core.usermanager"; |
270
853ae6ae87bf
mod_auth_dovecot: Use correct module name for logger
Javier Torres <javitonino@gmail.com>
parents:
269
diff
changeset
|
11 local log = require "util.logger".init("auth_dovecot"); |
261
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 local new_sasl = require "util.sasl".new; |
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 local nodeprep = require "util.encodings".stringprep.nodeprep; |
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 local base64 = require "util.encodings".base64; |
340
5d306466f3f6
mod_auth_dovecot: Use hash of vhost as PID to pass to dovecot - the ID must be unique per process, whereas we make a connection per vhost.
Matthew Wild <mwild1@gmail.com>
parents:
339
diff
changeset
|
15 local sha1 = require "util.hashes".sha1; |
261
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 |
312
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
17 local prosody = prosody; |
271
05ea4abb664d
mod_auth_dovecot: Load dovecot socket path form config
Javier Torres <javitonino@gmail.com>
parents:
270
diff
changeset
|
18 local socket_path = module:get_option_string("dovecot_auth_socket", "/var/run/dovecot/auth-login"); |
410
abac17cb5032
mod_auth_dovecot: Make appending the domain name configurable. Warning: If you depend on this behaviour, add auth_append_host = true to your config
Kim Alvefur <zash@zash.se>
parents:
342
diff
changeset
|
19 local append_host = module:get_option_boolean("auth_append_host", false); |
261
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 |
312
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
21 function new_provider(host) |
310
b3bcd1913c85
mod_auth_dovecot: Switch to using upvalue 'conn' instead of provider.c throughout (thanks Adrien Clerc)
Matthew Wild <mwild1@gmail.com>
parents:
305
diff
changeset
|
22 local provider = { name = "dovecot", request_id = 0 }; |
261
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 log("debug", "initializing dovecot authentication provider for host '%s'", host); |
268
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
24 |
310
b3bcd1913c85
mod_auth_dovecot: Switch to using upvalue 'conn' instead of provider.c throughout (thanks Adrien Clerc)
Matthew Wild <mwild1@gmail.com>
parents:
305
diff
changeset
|
25 local conn; |
340
5d306466f3f6
mod_auth_dovecot: Use hash of vhost as PID to pass to dovecot - the ID must be unique per process, whereas we make a connection per vhost.
Matthew Wild <mwild1@gmail.com>
parents:
339
diff
changeset
|
26 -- Generate an id for this connection (must be a 31-bit number, unique per process) |
5d306466f3f6
mod_auth_dovecot: Use hash of vhost as PID to pass to dovecot - the ID must be unique per process, whereas we make a connection per vhost.
Matthew Wild <mwild1@gmail.com>
parents:
339
diff
changeset
|
27 local pid = tonumber(sha1(host, true):sub(1, 6), 16); |
310
b3bcd1913c85
mod_auth_dovecot: Switch to using upvalue 'conn' instead of provider.c throughout (thanks Adrien Clerc)
Matthew Wild <mwild1@gmail.com>
parents:
305
diff
changeset
|
28 |
269
74846ec9c29f
mod_auth_dovecot: Close socket on error
Javier Torres <javitonino@gmail.com>
parents:
268
diff
changeset
|
29 -- Closes the socket |
74846ec9c29f
mod_auth_dovecot: Close socket on error
Javier Torres <javitonino@gmail.com>
parents:
268
diff
changeset
|
30 function provider.close(self) |
310
b3bcd1913c85
mod_auth_dovecot: Switch to using upvalue 'conn' instead of provider.c throughout (thanks Adrien Clerc)
Matthew Wild <mwild1@gmail.com>
parents:
305
diff
changeset
|
31 if conn then |
b3bcd1913c85
mod_auth_dovecot: Switch to using upvalue 'conn' instead of provider.c throughout (thanks Adrien Clerc)
Matthew Wild <mwild1@gmail.com>
parents:
305
diff
changeset
|
32 conn:close(); |
b3bcd1913c85
mod_auth_dovecot: Switch to using upvalue 'conn' instead of provider.c throughout (thanks Adrien Clerc)
Matthew Wild <mwild1@gmail.com>
parents:
305
diff
changeset
|
33 conn = nil; |
269
74846ec9c29f
mod_auth_dovecot: Close socket on error
Javier Torres <javitonino@gmail.com>
parents:
268
diff
changeset
|
34 end |
74846ec9c29f
mod_auth_dovecot: Close socket on error
Javier Torres <javitonino@gmail.com>
parents:
268
diff
changeset
|
35 end |
74846ec9c29f
mod_auth_dovecot: Close socket on error
Javier Torres <javitonino@gmail.com>
parents:
268
diff
changeset
|
36 |
268
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
37 -- The following connects to a new socket and send the handshake |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
38 function provider.connect(self) |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
39 -- Destroy old socket |
269
74846ec9c29f
mod_auth_dovecot: Close socket on error
Javier Torres <javitonino@gmail.com>
parents:
268
diff
changeset
|
40 provider:close(); |
261
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
41 |
310
b3bcd1913c85
mod_auth_dovecot: Switch to using upvalue 'conn' instead of provider.c throughout (thanks Adrien Clerc)
Matthew Wild <mwild1@gmail.com>
parents:
305
diff
changeset
|
42 conn = socket.unix(); |
261
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
43 |
268
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
44 -- Create a connection to dovecot socket |
273
8d283ae7f29d
mod_auth_dovecot: More debug messages
Javier Torres <javitonino@gmail.com>
parents:
272
diff
changeset
|
45 log("debug", "connecting to dovecot socket at '%s'", socket_path); |
312
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
46 local ok, err = conn:connect(socket_path); |
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
47 if not ok then |
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
48 log("error", "error connecting to dovecot socket at '%s'. error was '%s'. check permissions", socket_path, err); |
269
74846ec9c29f
mod_auth_dovecot: Close socket on error
Javier Torres <javitonino@gmail.com>
parents:
268
diff
changeset
|
49 provider:close(); |
268
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
50 return false; |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
51 end |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
52 |
261
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
53 -- Send our handshake |
273
8d283ae7f29d
mod_auth_dovecot: More debug messages
Javier Torres <javitonino@gmail.com>
parents:
272
diff
changeset
|
54 log("debug", "sending handshake to dovecot. version 1.1, cpid '%d'", pid); |
268
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
55 if not provider:send("VERSION\t1\t1\n") then |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
56 return false |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
57 end |
312
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
58 if not provider:send("CPID\t" .. pid .. "\n") then |
268
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
59 return false |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
60 end |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
61 |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
62 -- Parse Dovecot's handshake |
261
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
63 local done = false; |
339
5aa8229e8815
mod_auth_dovecot: Add line missing from previous commit.
Kim Alvefur <zash@zash.se>
parents:
338
diff
changeset
|
64 local supported_mechs = {}; |
261
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
65 while (not done) do |
312
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
66 local line = provider:receive(); |
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
67 if not line then |
268
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
68 return false; |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
69 end |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
70 |
312
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
71 log("debug", "dovecot handshake: '%s'", line); |
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
72 local parts = line:gmatch("[^\t]+"); |
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
73 local first = parts(); |
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
74 if first == "VERSION" then |
268
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
75 -- Version should be 1.1 |
311
f663ea45436f
mod_auth_dovecot: Only check Dovecot major version. Bump log level from 'warn' to 'error'. (thanks Adrien Clerc)
Matthew Wild <mwild1@gmail.com>
parents:
310
diff
changeset
|
76 local major_version = parts(); |
268
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
77 |
311
f663ea45436f
mod_auth_dovecot: Only check Dovecot major version. Bump log level from 'warn' to 'error'. (thanks Adrien Clerc)
Matthew Wild <mwild1@gmail.com>
parents:
310
diff
changeset
|
78 if major_version ~= "1" then |
f663ea45436f
mod_auth_dovecot: Only check Dovecot major version. Bump log level from 'warn' to 'error'. (thanks Adrien Clerc)
Matthew Wild <mwild1@gmail.com>
parents:
310
diff
changeset
|
79 log("error", "dovecot server version is not 1.x. it is %s.x", major_version); |
269
74846ec9c29f
mod_auth_dovecot: Close socket on error
Javier Torres <javitonino@gmail.com>
parents:
268
diff
changeset
|
80 provider:close(); |
268
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
81 return false; |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
82 end |
312
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
83 elseif first == "MECH" then |
338
6560fd0b77f5
mod_auth_dovecot: One mechanism per MECH command.
Kim Alvefur <zash@zash.se>
parents:
312
diff
changeset
|
84 local mech = parts(); |
6560fd0b77f5
mod_auth_dovecot: One mechanism per MECH command.
Kim Alvefur <zash@zash.se>
parents:
312
diff
changeset
|
85 supported_mechs[mech] = true; |
6560fd0b77f5
mod_auth_dovecot: One mechanism per MECH command.
Kim Alvefur <zash@zash.se>
parents:
312
diff
changeset
|
86 elseif first == "DONE" then |
6560fd0b77f5
mod_auth_dovecot: One mechanism per MECH command.
Kim Alvefur <zash@zash.se>
parents:
312
diff
changeset
|
87 -- We need PLAIN |
6560fd0b77f5
mod_auth_dovecot: One mechanism per MECH command.
Kim Alvefur <zash@zash.se>
parents:
312
diff
changeset
|
88 if not supported_mechs.PLAIN then |
6560fd0b77f5
mod_auth_dovecot: One mechanism per MECH command.
Kim Alvefur <zash@zash.se>
parents:
312
diff
changeset
|
89 log("warn", "server doesn't support PLAIN mechanism."); |
269
74846ec9c29f
mod_auth_dovecot: Close socket on error
Javier Torres <javitonino@gmail.com>
parents:
268
diff
changeset
|
90 provider:close(); |
268
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
91 return false; |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
92 end |
261
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
93 done = true; |
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
94 end |
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
95 end |
268
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
96 return true; |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
97 end |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
98 |
269
74846ec9c29f
mod_auth_dovecot: Close socket on error
Javier Torres <javitonino@gmail.com>
parents:
268
diff
changeset
|
99 -- Wrapper for send(). Handles errors |
268
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
100 function provider.send(self, data) |
312
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
101 local ok, err = conn:send(data); |
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
102 if not ok then |
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
103 log("error", "error sending '%s' to dovecot. error was '%s'", data, err); |
269
74846ec9c29f
mod_auth_dovecot: Close socket on error
Javier Torres <javitonino@gmail.com>
parents:
268
diff
changeset
|
104 provider:close(); |
268
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
105 return false; |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
106 end |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
107 return true; |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
108 end |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
109 |
269
74846ec9c29f
mod_auth_dovecot: Close socket on error
Javier Torres <javitonino@gmail.com>
parents:
268
diff
changeset
|
110 -- Wrapper for receive(). Handles errors |
268
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
111 function provider.receive(self) |
312
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
112 local line, err = conn:receive(); |
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
113 if not line then |
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
114 log("error", "error receiving data from dovecot. error was '%s'", err); |
269
74846ec9c29f
mod_auth_dovecot: Close socket on error
Javier Torres <javitonino@gmail.com>
parents:
268
diff
changeset
|
115 provider:close(); |
268
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
116 return false; |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
117 end |
312
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
118 return line; |
268
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
119 end |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
120 |
274
cda4855863af
mod_auth_dovecot: Implement user_exists
Javier Torres <javitonino@gmail.com>
parents:
273
diff
changeset
|
121 function provider.send_auth_request(self, username, password) |
310
b3bcd1913c85
mod_auth_dovecot: Switch to using upvalue 'conn' instead of provider.c throughout (thanks Adrien Clerc)
Matthew Wild <mwild1@gmail.com>
parents:
305
diff
changeset
|
122 if not conn then |
b3bcd1913c85
mod_auth_dovecot: Switch to using upvalue 'conn' instead of provider.c throughout (thanks Adrien Clerc)
Matthew Wild <mwild1@gmail.com>
parents:
305
diff
changeset
|
123 if not provider:connect() then |
269
74846ec9c29f
mod_auth_dovecot: Close socket on error
Javier Torres <javitonino@gmail.com>
parents:
268
diff
changeset
|
124 return nil, "Auth failed. Dovecot communications error"; |
74846ec9c29f
mod_auth_dovecot: Close socket on error
Javier Torres <javitonino@gmail.com>
parents:
268
diff
changeset
|
125 end |
268
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
126 end |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
127 |
261
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
128 -- Send auth data |
410
abac17cb5032
mod_auth_dovecot: Make appending the domain name configurable. Warning: If you depend on this behaviour, add auth_append_host = true to your config
Kim Alvefur <zash@zash.se>
parents:
342
diff
changeset
|
129 if append_host then |
abac17cb5032
mod_auth_dovecot: Make appending the domain name configurable. Warning: If you depend on this behaviour, add auth_append_host = true to your config
Kim Alvefur <zash@zash.se>
parents:
342
diff
changeset
|
130 username = username .. "@" .. module.host; |
abac17cb5032
mod_auth_dovecot: Make appending the domain name configurable. Warning: If you depend on this behaviour, add auth_append_host = true to your config
Kim Alvefur <zash@zash.se>
parents:
342
diff
changeset
|
131 end |
261
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
132 local b64 = base64.encode(username .. "\0" .. username .. "\0" .. password); |
273
8d283ae7f29d
mod_auth_dovecot: More debug messages
Javier Torres <javitonino@gmail.com>
parents:
272
diff
changeset
|
133 provider.request_id = provider.request_id + 1 % 4294967296 |
8d283ae7f29d
mod_auth_dovecot: More debug messages
Javier Torres <javitonino@gmail.com>
parents:
272
diff
changeset
|
134 |
8d283ae7f29d
mod_auth_dovecot: More debug messages
Javier Torres <javitonino@gmail.com>
parents:
272
diff
changeset
|
135 local msg = "AUTH\t" .. provider.request_id .. "\tPLAIN\tservice=XMPP\tresp=" .. b64; |
8d283ae7f29d
mod_auth_dovecot: More debug messages
Javier Torres <javitonino@gmail.com>
parents:
272
diff
changeset
|
136 log("debug", "sending auth request for '%s' with password '%s': '%s'", username, password, msg); |
312
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
137 if not provider:send(msg .. "\n") then |
268
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
138 return nil, "Auth failed. Dovecot communications error"; |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
139 end |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
140 |
272
6b35c23664db
mod_auth_dovecot: Use sequential (instead of fixed) id for messages
Javier Torres <javitonino@gmail.com>
parents:
271
diff
changeset
|
141 |
268
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
142 -- Get response |
312
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
143 local line = provider:receive(); |
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
144 log("debug", "got auth response: '%s'", line); |
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
145 if not line then |
268
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
146 return nil, "Auth failed. Dovecot communications error"; |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
147 end |
312
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
148 local parts = line:gmatch("[^\t]+"); |
268
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
149 |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
150 -- Check response |
273
8d283ae7f29d
mod_auth_dovecot: More debug messages
Javier Torres <javitonino@gmail.com>
parents:
272
diff
changeset
|
151 local status = parts(); |
8d283ae7f29d
mod_auth_dovecot: More debug messages
Javier Torres <javitonino@gmail.com>
parents:
272
diff
changeset
|
152 local resp_id = tonumber(parts()); |
274
cda4855863af
mod_auth_dovecot: Implement user_exists
Javier Torres <javitonino@gmail.com>
parents:
273
diff
changeset
|
153 |
312
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
154 if resp_id ~= provider.request_id then |
273
8d283ae7f29d
mod_auth_dovecot: More debug messages
Javier Torres <javitonino@gmail.com>
parents:
272
diff
changeset
|
155 log("warn", "dovecot response_id(%s) doesn't match request_id(%s)", resp_id, provider.request_id); |
8d283ae7f29d
mod_auth_dovecot: More debug messages
Javier Torres <javitonino@gmail.com>
parents:
272
diff
changeset
|
156 provider:close(); |
8d283ae7f29d
mod_auth_dovecot: More debug messages
Javier Torres <javitonino@gmail.com>
parents:
272
diff
changeset
|
157 return nil, "Auth failed. Dovecot communications error"; |
8d283ae7f29d
mod_auth_dovecot: More debug messages
Javier Torres <javitonino@gmail.com>
parents:
272
diff
changeset
|
158 end |
8d283ae7f29d
mod_auth_dovecot: More debug messages
Javier Torres <javitonino@gmail.com>
parents:
272
diff
changeset
|
159 |
274
cda4855863af
mod_auth_dovecot: Implement user_exists
Javier Torres <javitonino@gmail.com>
parents:
273
diff
changeset
|
160 return status, parts; |
cda4855863af
mod_auth_dovecot: Implement user_exists
Javier Torres <javitonino@gmail.com>
parents:
273
diff
changeset
|
161 end |
cda4855863af
mod_auth_dovecot: Implement user_exists
Javier Torres <javitonino@gmail.com>
parents:
273
diff
changeset
|
162 |
cda4855863af
mod_auth_dovecot: Implement user_exists
Javier Torres <javitonino@gmail.com>
parents:
273
diff
changeset
|
163 function provider.test_password(username, password) |
cda4855863af
mod_auth_dovecot: Implement user_exists
Javier Torres <javitonino@gmail.com>
parents:
273
diff
changeset
|
164 log("debug", "test password '%s' for user %s at host %s", password, username, module.host); |
cda4855863af
mod_auth_dovecot: Implement user_exists
Javier Torres <javitonino@gmail.com>
parents:
273
diff
changeset
|
165 |
cda4855863af
mod_auth_dovecot: Implement user_exists
Javier Torres <javitonino@gmail.com>
parents:
273
diff
changeset
|
166 local status, extra = provider:send_auth_request(username, password); |
cda4855863af
mod_auth_dovecot: Implement user_exists
Javier Torres <javitonino@gmail.com>
parents:
273
diff
changeset
|
167 |
312
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
168 if status == "OK" then |
273
8d283ae7f29d
mod_auth_dovecot: More debug messages
Javier Torres <javitonino@gmail.com>
parents:
272
diff
changeset
|
169 log("info", "login ok for '%s'", username); |
261
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
170 return true; |
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
171 else |
273
8d283ae7f29d
mod_auth_dovecot: More debug messages
Javier Torres <javitonino@gmail.com>
parents:
272
diff
changeset
|
172 log("info", "login failed for '%s'", username); |
261
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
173 return nil, "Auth failed. Invalid username or password."; |
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
174 end |
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
175 end |
269
74846ec9c29f
mod_auth_dovecot: Close socket on error
Javier Torres <javitonino@gmail.com>
parents:
268
diff
changeset
|
176 |
261
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
177 function provider.get_password(username) |
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
178 return nil, "Cannot get_password in dovecot backend."; |
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
179 end |
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
180 |
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
181 function provider.set_password(username, password) |
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
182 return nil, "Cannot set_password in dovecot backend."; |
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
183 end |
269
74846ec9c29f
mod_auth_dovecot: Close socket on error
Javier Torres <javitonino@gmail.com>
parents:
268
diff
changeset
|
184 |
261
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
185 function provider.user_exists(username) |
274
cda4855863af
mod_auth_dovecot: Implement user_exists
Javier Torres <javitonino@gmail.com>
parents:
273
diff
changeset
|
186 log("debug", "user_exists for user %s at host %s", username, module.host); |
cda4855863af
mod_auth_dovecot: Implement user_exists
Javier Torres <javitonino@gmail.com>
parents:
273
diff
changeset
|
187 |
cda4855863af
mod_auth_dovecot: Implement user_exists
Javier Torres <javitonino@gmail.com>
parents:
273
diff
changeset
|
188 -- Send a request. If the response (FAIL) contains an extra |
cda4855863af
mod_auth_dovecot: Implement user_exists
Javier Torres <javitonino@gmail.com>
parents:
273
diff
changeset
|
189 -- parameter like user=<username> then it exists. |
cda4855863af
mod_auth_dovecot: Implement user_exists
Javier Torres <javitonino@gmail.com>
parents:
273
diff
changeset
|
190 local status, extra = provider:send_auth_request(username, ""); |
cda4855863af
mod_auth_dovecot: Implement user_exists
Javier Torres <javitonino@gmail.com>
parents:
273
diff
changeset
|
191 |
cda4855863af
mod_auth_dovecot: Implement user_exists
Javier Torres <javitonino@gmail.com>
parents:
273
diff
changeset
|
192 local param = extra(); |
312
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
193 while param do |
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
194 local parts = param:gmatch("[^=]+"); |
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
195 local name = parts(); |
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
196 local value = parts(); |
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
197 if name == "user" then |
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
198 log("debug", "user '%s' exists", username); |
274
cda4855863af
mod_auth_dovecot: Implement user_exists
Javier Torres <javitonino@gmail.com>
parents:
273
diff
changeset
|
199 return true; |
cda4855863af
mod_auth_dovecot: Implement user_exists
Javier Torres <javitonino@gmail.com>
parents:
273
diff
changeset
|
200 end |
cda4855863af
mod_auth_dovecot: Implement user_exists
Javier Torres <javitonino@gmail.com>
parents:
273
diff
changeset
|
201 |
cda4855863af
mod_auth_dovecot: Implement user_exists
Javier Torres <javitonino@gmail.com>
parents:
273
diff
changeset
|
202 param = extra(); |
cda4855863af
mod_auth_dovecot: Implement user_exists
Javier Torres <javitonino@gmail.com>
parents:
273
diff
changeset
|
203 end |
cda4855863af
mod_auth_dovecot: Implement user_exists
Javier Torres <javitonino@gmail.com>
parents:
273
diff
changeset
|
204 |
312
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
205 log("debug", "user '%s' does not exists (or dovecot didn't send user=<username> parameter)", username); |
274
cda4855863af
mod_auth_dovecot: Implement user_exists
Javier Torres <javitonino@gmail.com>
parents:
273
diff
changeset
|
206 return false; |
261
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
207 end |
269
74846ec9c29f
mod_auth_dovecot: Close socket on error
Javier Torres <javitonino@gmail.com>
parents:
268
diff
changeset
|
208 |
261
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
209 function provider.create_user(username, password) |
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
210 return nil, "Cannot create_user in dovecot backend."; |
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
211 end |
269
74846ec9c29f
mod_auth_dovecot: Close socket on error
Javier Torres <javitonino@gmail.com>
parents:
268
diff
changeset
|
212 |
261
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
213 function provider.get_sasl_handler() |
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
214 local getpass_authentication_profile = { |
305
4c3abf1a9b5a
mod_auth_*, mod_saslauth_muc: Update SASL callbacks to take SASL handler as first argument.
Waqas Hussain <waqas20@gmail.com>
parents:
274
diff
changeset
|
215 plain_test = function(sasl, username, password, realm) |
268
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
216 local prepped_username = nodeprep(username); |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
217 if not prepped_username then |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
218 log("debug", "NODEprep failed on username: %s", username); |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
219 return "", nil; |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
220 end |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
221 return usermanager.test_password(prepped_username, realm, password), true; |
cfcd4efb0fa4
mod_auth_dovecot: Remove asserts (use logger) and refactor socket code
Javier Torres <javitonino@gmail.com>
parents:
267
diff
changeset
|
222 end |
269
74846ec9c29f
mod_auth_dovecot: Close socket on error
Javier Torres <javitonino@gmail.com>
parents:
268
diff
changeset
|
223 }; |
342
8e9e5c7d97ff
mod_auth_*: Get rid of undocumented and broken 'sasl_realm' config option.
Waqas Hussain <waqas20@gmail.com>
parents:
340
diff
changeset
|
224 return new_sasl(module.host, getpass_authentication_profile); |
269
74846ec9c29f
mod_auth_dovecot: Close socket on error
Javier Torres <javitonino@gmail.com>
parents:
268
diff
changeset
|
225 end |
74846ec9c29f
mod_auth_dovecot: Close socket on error
Javier Torres <javitonino@gmail.com>
parents:
268
diff
changeset
|
226 |
74846ec9c29f
mod_auth_dovecot: Close socket on error
Javier Torres <javitonino@gmail.com>
parents:
268
diff
changeset
|
227 return provider; |
261
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
228 end |
0f46fb2dbc79
mod_auth_dovecot: Initial commit of Dovecot authentication backend by Javier Torres
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
229 |
312
31deafcbf623
mod_auth_dovecot: Fix various global variable sets/gets, log levels, unclear variable names and change coding style to match more closely the rest of the Prosody code.
Matthew Wild <mwild1@gmail.com>
parents:
311
diff
changeset
|
230 module:add_item("auth-provider", new_provider(module.host)); |