passport-pop3
POP3 authentication strategy for Passport
This module lets you authenticate using POP3 authentication in your Node.js applications. By plugging into Passport, POP3 authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.
Install
$ npm install --save passport-pop3
Usage
Configure Strategy
The POP3 authentication strategy authenticates users using a username and password, and you must provide host
and port
for POP3 authentication.
passport.use(new POP3Strategy({
host: 'localhost',
port: 995
}
));
Available Options
The available options are:
enabletls
- Optional, defaults to true. Ifenabletls
is true, the library will use a TLS connection. Note that you will have to set the correct port (generally 995).tlserrs
- Optional, defaults to false. Iftlserrs
is true, then TLS errors will be ignored.debug
- Optional, defaults to false. Ifdebug
is true, prints out requests and responses.usernameField
- Optional, defaults to 'username'.passwordField
- Optional, defaults to 'password'.
The fields usernameField
and passwordField
define the name of the properties in the POST body that are sent to the server.
Parameters
By default, POP3Strategy
expects to find credentials in parameters
named username and password. If your site prefers to name these fields
differently, options are available to change the defaults.
passport.use(new POP3Strategy({
host: 'localhost',
port: 110,
enabletls: false,
usernameField: 'email',
passwordField: 'passwd',
}
));
Authenticate Requests
Use passport.authenticate()
, specifying the 'pop3'
strategy, to
authenticate requests.
For example, as route middleware in an Express application:
app.post('/login',
passport.authenticate('pop3', { failureRedirect: '/login' }),
function(req, res) {
res.redirect('/');
});
License
MIT © Chun-Kai Wang