Skip to content

Instantly share code, notes, and snippets.

@MACSkeptic
Last active December 10, 2015 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MACSkeptic/4498671 to your computer and use it in GitHub Desktop.
Save MACSkeptic/4498671 to your computer and use it in GitHub Desktop.
function authWithCas(req, res) {
var CAS = require('cas');
var cas = new CAS({base_url: 'https://cas.thoughtworks.com/cas', service: 'www.recruiting-dashboard.herokuapp.com'});
var ticket = req.param('ticket');
if (ticket) {
cas.validate(ticket, function(err, status, username) {
if (err) {
// Handle the error
res.send({error: err});
}
else {
// Log the user in
res.send({status: status, username: username});
}
});
} else {
res.redirect('https://cas.thoughtworks.com/cas');
}
};
//var auth = express.basicAuth('talent', 'dashboard');
//app.get('/', auth, routes.index);
//instead of these two lines above
app.get('/', authWithCas, routes.index);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment