mirror of
https://github.com/bjc/prosody.git
synced 2025-04-05 06:07:37 +03:00
mod_saslauth, mod_tls: minor code cleanup
This commit is contained in:
parent
c157d04ba3
commit
5e41870700
2 changed files with 18 additions and 25 deletions
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
local st = require "util.stanza";
|
local st = require "util.stanza";
|
||||||
local sm_bind_resource = require "core.sessionmanager".bind_resource;
|
local sm_bind_resource = require "core.sessionmanager".bind_resource;
|
||||||
local jid
|
|
||||||
local base64 = require "util.encodings".base64;
|
local base64 = require "util.encodings".base64;
|
||||||
|
|
||||||
local usermanager_validate_credentials = require "core.usermanager".validate_credentials;
|
local usermanager_validate_credentials = require "core.usermanager".validate_credentials;
|
||||||
|
@ -80,7 +79,7 @@ local function password_callback(node, host, mechanism, decoder)
|
||||||
return func, nil;
|
return func, nil;
|
||||||
end
|
end
|
||||||
|
|
||||||
function sasl_handler(session, stanza)
|
local function sasl_handler(session, stanza)
|
||||||
if stanza.name == "auth" then
|
if stanza.name == "auth" then
|
||||||
-- FIXME ignoring duplicates because ejabberd does
|
-- FIXME ignoring duplicates because ejabberd does
|
||||||
session.sasl_handler = new_sasl(stanza.attr.mechanism, session.host, password_callback);
|
session.sasl_handler = new_sasl(stanza.attr.mechanism, session.host, password_callback);
|
||||||
|
@ -112,18 +111,18 @@ local mechanisms_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-sasl' };
|
||||||
local bind_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-bind' };
|
local bind_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-bind' };
|
||||||
local xmpp_session_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-session' };
|
local xmpp_session_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-session' };
|
||||||
module:add_event_hook("stream-features",
|
module:add_event_hook("stream-features",
|
||||||
function (session, features)
|
function (session, features)
|
||||||
if not session.username then
|
if not session.username then
|
||||||
features:tag("mechanisms", mechanisms_attr);
|
features:tag("mechanisms", mechanisms_attr);
|
||||||
-- TODO: Provide PLAIN only if TLS is active, this is a SHOULD from the introduction of RFC 4616. This behavior could be overridden via configuration but will issuing a warning or so.
|
-- TODO: Provide PLAIN only if TLS is active, this is a SHOULD from the introduction of RFC 4616. This behavior could be overridden via configuration but will issuing a warning or so.
|
||||||
features:tag("mechanism"):text("PLAIN"):up();
|
features:tag("mechanism"):text("PLAIN"):up();
|
||||||
features:tag("mechanism"):text("DIGEST-MD5"):up();
|
features:tag("mechanism"):text("DIGEST-MD5"):up();
|
||||||
features:up();
|
features:up();
|
||||||
else
|
else
|
||||||
features:tag("bind", bind_attr):tag("required"):up():up();
|
features:tag("bind", bind_attr):tag("required"):up():up();
|
||||||
features:tag("session", xmpp_session_attr):up();
|
features:tag("session", xmpp_session_attr):up();
|
||||||
end
|
end
|
||||||
end);
|
end);
|
||||||
|
|
||||||
module:add_iq_handler("c2s", "urn:ietf:params:xml:ns:xmpp-bind",
|
module:add_iq_handler("c2s", "urn:ietf:params:xml:ns:xmpp-bind",
|
||||||
function (session, stanza)
|
function (session, stanza)
|
||||||
|
|
|
@ -21,12 +21,6 @@
|
||||||
|
|
||||||
local st = require "util.stanza";
|
local st = require "util.stanza";
|
||||||
|
|
||||||
--local sessions = sessions;
|
|
||||||
|
|
||||||
local t_insert = table.insert;
|
|
||||||
|
|
||||||
local log = require "util.logger".init("mod_starttls");
|
|
||||||
|
|
||||||
local xmlns_starttls ='urn:ietf:params:xml:ns:xmpp-tls';
|
local xmlns_starttls ='urn:ietf:params:xml:ns:xmpp-tls';
|
||||||
|
|
||||||
module:add_handler("c2s_unauthed", "starttls", xmlns_starttls,
|
module:add_handler("c2s_unauthed", "starttls", xmlns_starttls,
|
||||||
|
@ -44,8 +38,8 @@ module:add_handler("c2s_unauthed", "starttls", xmlns_starttls,
|
||||||
|
|
||||||
local starttls_attr = { xmlns = xmlns_starttls };
|
local starttls_attr = { xmlns = xmlns_starttls };
|
||||||
module:add_event_hook("stream-features",
|
module:add_event_hook("stream-features",
|
||||||
function (session, features)
|
function (session, features)
|
||||||
if session.conn.starttls then
|
if session.conn.starttls then
|
||||||
features:tag("starttls", starttls_attr):up();
|
features:tag("starttls", starttls_attr):up();
|
||||||
end
|
end
|
||||||
end);
|
end);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue