https://github.com/mtso/passport-ses
Password-less AWS SES email authentication strategy for Passport
https://github.com/mtso/passport-ses
authentication aws email passport passwordless ses
Last synced: 4 months ago
JSON representation
Password-less AWS SES email authentication strategy for Passport
- Host: GitHub
- URL: https://github.com/mtso/passport-ses
- Owner: mtso
- License: mit
- Created: 2017-08-21T23:00:27.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2021-11-06T19:41:51.000Z (over 4 years ago)
- Last Synced: 2025-12-01T01:19:27.056Z (6 months ago)
- Topics: authentication, aws, email, passport, passwordless, ses
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/passport-ses
- Size: 7.81 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# passport-ses
[summary]::
Password-less authentication strategy using AWS SES.
## Install
```shell
$ npm install passport-ses
```
## Usage
#### Configure Strategy
The SES strategy authenticates users by sending them an email containing
a temporary token.
```js
var SESStrategy = require('passport-ses').Strategy;
passport.use('ses', new SESStrategy({
accessKeyId: process.env.AWS_ACCESS_KEY,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
region: process.env.AWS_REGION,
source: process.env.FROM_EMAIL,
hostname: process.env.HOSTNAME || 'localhost:3750'
}, function(email, done) {
User.findOne({ email }, function(err, user) {
done(err, user)
})
}
))
```
#### Authenticate Requests
```js
app.get('/auth/ses', passport.authenticate('ses', {
failureRedirect: '/login',
successRedirect: '/',
emailSentRedirect: '/check-email',
}))
```
## Token Store API
The strategy expects a token store that has the following API model:
```js
Token {
value: String
email: String
timestamp: Date
isValid: function() Boolean {}
destroy: function() {}
}
TokenStore {
set: function(value: String, email: String, callback: function(err, Token) {}) {}
get: function(value: String, callback: function(err, Token) {}) {}
}
```
The default token storage method is an in-memory object,
so restarting the server will delete any saved tokens.