A simple Node.js module you can use to build you own external ejabberd auth with
npm install ejabberd-auth
To create your own external authentication script for ejabberd, simply require ejabberd-auth and call the run() method exported by this module while passing your authentification function to it.
require('ejabberd-auth').run({
actions: {
auth: function(done, userName, domain, password) {
// Some auth to be done here
done(true); // or done(false) if the authentification has failed
}
}
});
run() takes a configuration object. It takes the following options:
- log: Configuration for the Winston File transport used for logging (refer the winston documentation for more details). If no log configuration or filename is given, logging will be disabled.
- actions: An object containing callback functions for the module to call, when ejabberd requests an action. Possible keys are:
- auth: Called, when a user tries to log in. Call the callback with true to allow the user to enter.
auth: function(callback, userName, domainName, password)
- isuser: Called, when ejabberd needs to check, if a JID exists.
isuser: function(callback, userName)
- setpass: Called, when a user tries to change their password. Change the password and call the callback with true, to signalize, that the password was successfully changed.
setpass: function(callback)
- auth: Called, when a user tries to log in. Call the callback with true to allow the user to enter.
If any of the action key is not given, false will be returned to ejabberd.