Skip to content

Commit

Permalink
Add README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Ysheep666 committed Jan 9, 2014
1 parent 164b15c commit b48acd1
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 4 deletions.
29 changes: 25 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
###Node###

########################
# node.js / npm
########################
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
Expand All @@ -13,5 +13,26 @@ pids
logs
results

node_modules

npm-debug.log
node_modules


########################
# misc / editors
########################
*~
*#
.DS_STORE
.netbeans
nbproject
.idea


########################
# Test
########################
coverage.html



76 changes: 76 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# passport-cas

Cas authentication strategies for Passport.


## Install

$ npm install passport-cas

#### Configure Strategy

passport.use(new (require('passport-cas').Strategy)({
ssoBaseURL: 'http://www.example.com/',
serverBaseURL: 'http://localhost:3000'
}, function(login, done) {
User.findOne({login: login}, function (err, user) {
if (err) {
return done(err);
}
if (!user) {
return done(null, false, {message: 'Unknown user'});
}
return done(null, user);
});
}));

#### Authenticate Requests

passport.authenticate('cas', function (err, user, info) {
if (err) {
return next(err);
}

if (!user) {
req.session.messages = info.message;
return res.redirect('/');
}

req.logIn(user, function (err) {
if (err) {
return next(err);
}

req.session.messages = '';
return res.redirect('/');
});
})

For example:

// GET: '/cas_login'
exports.casLogin = function(req, res, next) {
passport.authenticate('cas', function (err, user, info) {
if (err) {
return next(err);
}

if (!user) {
req.session.messages = info.message;
return res.redirect('/');
}

req.logIn(user, function (err) {
if (err) {
return next(err);
}

req.session.messages = '';
return res.redirect('/');
});
})(req, res, next);
};

## License

[The MIT License](http://opensource.org/licenses/MIT)

0 comments on commit b48acd1

Please sign in to comment.