mod_smacks: Bounce unhandled stanzas from local origin (fix #1759)
Sending stanzas with a remote session as origin when the stanzas have a
local JID in the from attribute trips validation in core.stanza_router,
leading to warnings:
> Received a stanza claiming to be from remote.example, over a stream authed for localhost.example
Using module:send() uses the local host as origin, which is fine here.
local saslprep = require "util.encodings".stringprep.saslprep;
local _ENV = nil;
-- luacheck: std none
local function external(self, message)
message = saslprep(message);
local state
self.username, state = self.profile.external(message);
if state == false then
return "failure", "account-disabled";
elseif state == nil then
return "failure", "not-authorized";
elseif state == "expired" then
return "false", "credentials-expired";
end
return "success";
end
local function init(registerMechanism)
registerMechanism("EXTERNAL", {"external"}, external);
end
return {
init = init;
}