Last active
May 11, 2022 06:25
-
-
Save andris9/938a73247b1e76ec515293f580dfa802 to your computer and use it in GitHub Desktop.
zonemta authentication
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# store to config/plugins/authplugin.toml | |
[authplugin] | |
enabled="receiver" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// store to plugins/authplugin.js | |
'use strict'; | |
const username = 'user'; | |
const password = 'secret'; | |
module.exports.title = 'Simple Authentication'; | |
module.exports.init = function(app, done) { | |
// Listen for AUTH command | |
app.addHook('smtp:auth', (auth, session, next) => { | |
if (auth.username !== username || auth.password !== password) { | |
// authentication failed | |
let err = new Error('Authentication failed'); | |
err.responseCode = 535; | |
return next(err); | |
} | |
// consider the authentication as succeeded as we did not get an error | |
next(); | |
}); | |
done(); | |
}; |
how would you wire this into the default.js?
"modules/authplugin": {
enabled: true
}
?
Still don't working...???
Does not seem to work in 2020.
For a real production example see the authentication in zonemta-wildduck plugin.
In addition of enabling an authentication plugin you also need to make sure that authentication is even enabled for the smtp interface in ZoneMTA, otherwise the authentication plugin is never called.
autphlugin.js
is a typo - it should be authplugin.js
- Unfortunately, I can't seem to get the authentication working. @andris9
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
It's seems to be missing a comparison of password.
I'm using this same plugin, but with some modifications on line #10:
if (auth.username !== username || auth.password !== password ) {