diff --git a/README.md b/README.md index f7b9458..a20bfeb 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,57 @@ # Passport-Yahoo [Passport](https://github.com/jaredhanson/passport) strategy for authenticating -with [Yahoo](http://www.yahoo.com/) using OpenID 2.0. +with [Yahoo!](http://www.yahoo.com/) using OpenID 2.0. + +## Installation + + $ npm install passport-yahoo + +## Usage + +#### Configure Strategy + +The Yahoo authentication strategy authenticates users using a Yahoo account, +which is also an OpenID 2.0 identifier. The strategy requires a `validate` +callback, which accepts this identifier and calls `done` providing a user. +Additionally, options can be supplied to specify a return URL and realm. + + passport.use(new YahooStrategy({ + returnURL: 'http://localhost:3000/auth/yahoo/return', + realm: 'http://localhost:3000/' + }, + function(identifier, done) { + User.findByOpenID({ openId: identifier }, function (err, user) { + return done(err, user); + }); + } + )); + +#### Authenticate Requests + +Use `passport.authenticate()`, specifying the `'yahoo'` strategy, to +authenticate requests. + +For example, as route middleware in an [Express](http://expressjs.com/) +application: + + app.get('/auth/yahoo', + passport.authenticate('yahoo'), + function(req, res){ + // The request will be redirected to Yahoo for authentication, so + // this function will not be called. + }); + + app.get('/auth/yahoo/return', + passport.authenticate('yahoo', { failureRedirect: '/login' }), + function(req, res) { + // Successful authentication, redirect home. + res.redirect('/'); + }); + +#### Examples + +For a complete, working example, refer to the [signon example](https://github.com/jaredhanson/passport-yahoo/tree/master/examples/signon). ## Credits diff --git a/examples/signon/app.js b/examples/signon/app.js index 56d471f..306e186 100644 --- a/examples/signon/app.js +++ b/examples/signon/app.js @@ -29,9 +29,6 @@ passport.use(new YahooStrategy({ realm: 'http://localhost:3000/' }, function(identifier, profile, done) { - console.log('YAHOO ID: ' + identifier); - console.log('YAHOO PROFILE: ' + util.inspect(profile)); - // asynchronous verification, for effect... process.nextTick(function () { diff --git a/package.json b/package.json index 718331b..1c93907 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "passport-yahoo", "version": "0.1.0", - "description": "Yahoo authentication strategy for Passport.", + "description": "Yahoo! authentication strategy for Passport.", "author": "Jared Hanson (http://www.jaredhanson.net/)", "repository": { "type": "git",