comparison 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
parents 8e9e5c7d97ff
children b3a5439a16bf
comparison
equal deleted inserted replaced
409:df57fa689415 410:abac17cb5032
14 local base64 = require "util.encodings".base64; 14 local base64 = require "util.encodings".base64;
15 local sha1 = require "util.hashes".sha1; 15 local sha1 = require "util.hashes".sha1;
16 16
17 local prosody = prosody; 17 local prosody = prosody;
18 local socket_path = module:get_option_string("dovecot_auth_socket", "/var/run/dovecot/auth-login"); 18 local socket_path = module:get_option_string("dovecot_auth_socket", "/var/run/dovecot/auth-login");
19 local append_host = module:get_option_boolean("auth_append_host", false);
19 20
20 function new_provider(host) 21 function new_provider(host)
21 local provider = { name = "dovecot", request_id = 0 }; 22 local provider = { name = "dovecot", request_id = 0 };
22 log("debug", "initializing dovecot authentication provider for host '%s'", host); 23 log("debug", "initializing dovecot authentication provider for host '%s'", host);
23 24
123 return nil, "Auth failed. Dovecot communications error"; 124 return nil, "Auth failed. Dovecot communications error";
124 end 125 end
125 end 126 end
126 127
127 -- Send auth data 128 -- Send auth data
128 username = username .. "@" .. module.host; -- FIXME: this is actually a hack for my server 129 if append_host then
130 username = username .. "@" .. module.host;
131 end
129 local b64 = base64.encode(username .. "\0" .. username .. "\0" .. password); 132 local b64 = base64.encode(username .. "\0" .. username .. "\0" .. password);
130 provider.request_id = provider.request_id + 1 % 4294967296 133 provider.request_id = provider.request_id + 1 % 4294967296
131 134
132 local msg = "AUTH\t" .. provider.request_id .. "\tPLAIN\tservice=XMPP\tresp=" .. b64; 135 local msg = "AUTH\t" .. provider.request_id .. "\tPLAIN\tservice=XMPP\tresp=" .. b64;
133 log("debug", "sending auth request for '%s' with password '%s': '%s'", username, password, msg); 136 log("debug", "sending auth request for '%s' with password '%s': '%s'", username, password, msg);