X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=util%2Fsasl.lua;h=5845f34a45e31cedfb20c07ec1592ef5ff833bdb;hb=79a152bb61900a86c486b62d59be60fa845f8afc;hp=0d90880dcda40a6f15b70e768e5132a8c4bbd706;hpb=db5688d8546c1387ece50f3ae76c3434367d6c12;p=prosody.git diff --git a/util/sasl.lua b/util/sasl.lua index 0d90880d..5845f34a 100644 --- a/util/sasl.lua +++ b/util/sasl.lua @@ -18,9 +18,8 @@ local type = type local setmetatable = setmetatable; local assert = assert; local require = require; -local print = print -module "sasl" +local _ENV = nil; --[[ Authentication Backend Prototypes: @@ -67,7 +66,7 @@ local function registerMechanism(name, backends, f, cb_backends) end -- create a new SASL object which can be used to authenticate clients -function new(realm, profile) +local function new(realm, profile) local mechanisms = profile.mechanisms; if not mechanisms then mechanisms = {}; @@ -101,14 +100,16 @@ end function method:mechanisms() local current_mechs = {}; for mech, _ in pairs(self.mechs) do - if mechanism_channelbindings[mech] and self.profile.cb then - local ok = false; - for cb_name, _ in pairs(self.profile.cb) do - if mechanism_channelbindings[mech][cb_name] then - ok = true; + if mechanism_channelbindings[mech] then + if self.profile.cb then + local ok = false; + for cb_name, _ in pairs(self.profile.cb) do + if mechanism_channelbindings[mech][cb_name] then + ok = true; + end end + if ok == true then current_mechs[mech] = true; end end - if ok == true then current_mechs[mech] = true; end else current_mechs[mech] = true; end @@ -137,4 +138,7 @@ require "util.sasl.anonymous" .init(registerMechanism); require "util.sasl.scram" .init(registerMechanism); require "util.sasl.external" .init(registerMechanism); -return _M; +return { + registerMechanism = registerMechanism; + new = new; +};