Skip to content
This repository
Browse code

Update README.

  • Loading branch information...
commit d2cfe491e3fa4413e9a5e07cbd5d1b63289dad2f 1 parent 5623e0a
Jared Hanson authored

Showing 3 changed files with 52 additions and 5 deletions. Show diff stats Hide diff stats

  1. +51 1 README.md
  2. +0 3  examples/signon/app.js
  3. +1 1  package.json
52 README.md
Source Rendered
... ... @@ -1,7 +1,57 @@
1 1 # Passport-Yahoo
2 2
3 3 [Passport](https://github.com/jaredhanson/passport) strategy for authenticating
4   -with [Yahoo](http://www.yahoo.com/) using OpenID 2.0.
  4 +with [Yahoo!](http://www.yahoo.com/) using OpenID 2.0.
  5 +
  6 +## Installation
  7 +
  8 + $ npm install passport-yahoo
  9 +
  10 +## Usage
  11 +
  12 +#### Configure Strategy
  13 +
  14 +The Yahoo authentication strategy authenticates users using a Yahoo account,
  15 +which is also an OpenID 2.0 identifier. The strategy requires a `validate`
  16 +callback, which accepts this identifier and calls `done` providing a user.
  17 +Additionally, options can be supplied to specify a return URL and realm.
  18 +
  19 + passport.use(new YahooStrategy({
  20 + returnURL: 'http://localhost:3000/auth/yahoo/return',
  21 + realm: 'http://localhost:3000/'
  22 + },
  23 + function(identifier, done) {
  24 + User.findByOpenID({ openId: identifier }, function (err, user) {
  25 + return done(err, user);
  26 + });
  27 + }
  28 + ));
  29 +
  30 +#### Authenticate Requests
  31 +
  32 +Use `passport.authenticate()`, specifying the `'yahoo'` strategy, to
  33 +authenticate requests.
  34 +
  35 +For example, as route middleware in an [Express](http://expressjs.com/)
  36 +application:
  37 +
  38 + app.get('/auth/yahoo',
  39 + passport.authenticate('yahoo'),
  40 + function(req, res){
  41 + // The request will be redirected to Yahoo for authentication, so
  42 + // this function will not be called.
  43 + });
  44 +
  45 + app.get('/auth/yahoo/return',
  46 + passport.authenticate('yahoo', { failureRedirect: '/login' }),
  47 + function(req, res) {
  48 + // Successful authentication, redirect home.
  49 + res.redirect('/');
  50 + });
  51 +
  52 +#### Examples
  53 +
  54 +For a complete, working example, refer to the [signon example](https://github.com/jaredhanson/passport-yahoo/tree/master/examples/signon).
5 55
6 56 ## Credits
7 57
3  examples/signon/app.js
@@ -29,9 +29,6 @@ passport.use(new YahooStrategy({
29 29 realm: 'http://localhost:3000/'
30 30 },
31 31 function(identifier, profile, done) {
32   - console.log('YAHOO ID: ' + identifier);
33   - console.log('YAHOO PROFILE: ' + util.inspect(profile));
34   -
35 32 // asynchronous verification, for effect...
36 33 process.nextTick(function () {
37 34
2  package.json
... ... @@ -1,7 +1,7 @@
1 1 {
2 2 "name": "passport-yahoo",
3 3 "version": "0.1.0",
4   - "description": "Yahoo authentication strategy for Passport.",
  4 + "description": "Yahoo! authentication strategy for Passport.",
5 5 "author": "Jared Hanson <jaredhanson@gmail.com> (http://www.jaredhanson.net/)",
6 6 "repository": {
7 7 "type": "git",

0 comments on commit d2cfe49

Please sign in to comment.
Something went wrong with that request. Please try again.