Passport strategy for authenticating with NekoCAS
$ npm install passport-nekocas
Configure Strategy:
const NekocasStrategy = require('passport-nekocas').Strategy
passport.use(new NekocasStrategy({
serviceBaseURL: 'http://localhost',
secret: 'vNOZpKdqnUYcztBjUhvvPLpeYCIIBVev',
domain: 'https://cas.n3ko.co'
}, function (user, done) {
models.User.findOrCreate({
where: {
email: user.email
}
}).spread(function (user) {
if (!user) return done(null, false)
return done(null, user)
}).catch(function (err) {
return done(err)
})
}))
Authenticate Requests:
passport.authenticate('nekocas', {
successReturnToOrRedirect: '/',
failureRedirect: '/',
failureFlash: 'Failed to login.'
})(req, res, next)