Comparison

util/sasl.lua @ 13759:1437d8884899

Merge 13.0->trunk
author Matthew Wild <mwild1@gmail.com>
date Thu, 06 Mar 2025 13:34:55 +0000
parent 13758:fc97319ef48e
comparison
equal deleted inserted replaced
13757:025f6e490774 13759:1437d8884899
65 t_insert(backend_mechanism[backend_name], name); 65 t_insert(backend_mechanism[backend_name], name);
66 end 66 end
67 end 67 end
68 68
69 -- create a new SASL object which can be used to authenticate clients 69 -- create a new SASL object which can be used to authenticate clients
70 local function new(realm, profile) 70 local function new(realm, profile, userdata)
71 local mechanisms = profile.mechanisms; 71 local mechanisms = profile.mechanisms;
72 if not mechanisms then 72 if not mechanisms then
73 mechanisms = {}; 73 mechanisms = {};
74 for backend in pairs(profile) do 74 for backend in pairs(profile) do
75 if backend_mechanism[backend] then 75 if backend_mechanism[backend] then
78 end 78 end
79 end 79 end
80 end 80 end
81 profile.mechanisms = mechanisms; 81 profile.mechanisms = mechanisms;
82 end 82 end
83 return setmetatable({ profile = profile, realm = realm, mechs = mechanisms }, method); 83 return setmetatable({
84 profile = profile,
85 realm = realm,
86 mechs = mechanisms,
87 userdata = userdata
88 }, method);
84 end 89 end
85 90
86 -- add a channel binding handler 91 -- add a channel binding handler
87 function method:add_cb_handler(name, f) 92 function method:add_cb_handler(name, f)
88 if type(self.profile.cb) ~= "table" then 93 if type(self.profile.cb) ~= "table" then
92 return self; 97 return self;
93 end 98 end
94 99
95 -- get a fresh clone with the same realm and profile 100 -- get a fresh clone with the same realm and profile
96 function method:clean_clone() 101 function method:clean_clone()
97 return new(self.realm, self.profile) 102 return new(self.realm, self.profile, self.userdata)
98 end 103 end
99 104
100 -- get a list of possible SASL mechanisms to use 105 -- get a list of possible SASL mechanisms to use
101 function method:mechanisms() 106 function method:mechanisms()
102 local current_mechs = {}; 107 local current_mechs = {};