Giter VIP home page Giter VIP logo

passport-yahoo's Introduction

Passport-Yahoo

Passport strategy for authenticating with Yahoo! using OpenID 2.0.

This module lets you authenticate using Yahoo! in your Node.js applications. By plugging into Passport, Yahoo! authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.

Install

$ 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 application:

app.get('/auth/yahoo',
  passport.authenticate('yahoo'));

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.

Tests

$ npm install --dev
$ make test

Build Status

Credits

License

The MIT License

Copyright (c) 2011-2013 Jared Hanson <http://jaredhanson.net/>

Sponsor

passport-yahoo's People

Contributors

jaredhanson avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

passport-yahoo's Issues

Failed to discover OP endpoint URL (message: No providers found for the given identifier)

I have successfully managed to use passport-google, but with passport-yahoo I'm getting this error message:

Failed to discover OP endpoint URL (message: No providers found for the given identifier)
at Strategy.authenticate
at openid.authenticate
at openid.discover.i
at _resolveHostMeta
at _get.get.done
at IncomingMessage._get
at IncomingMessage.EventEmitter.emit
...

Thank you!

Dani

Fix for Yahoo: Failed to verify assertion (message: No OpenID provider was discovered for the asserted claimed identifier)

Starting about a week ago passport-yahoo started breaking. I finally tracked down the issue to a change that Yahoo made that is exposed by code in openid.js. Perhaps this is fixed with the latest version of the openid code but I'm running with a frozen set of npm modules. I am posting in the hopes this saves someone else the multiple hours it took me to track this down, even though the author appears to have abandoned this project.

The change Yahoo made is that this command:
curl -H 'Accept: application/xrds+xml,text/html,text/plain,*/*' https://me.yahoo.com/.well-known/host-meta

now returns different data. There is some content-type problem on Yahoo's side, because if you remove '/' from the list (or 'text/html') then the correct content is returned -- even though the returned content-type remains the same.

To fix the problem, run this command to remove the '/' from the Accept header that is sent:
sed -i 's%,\*/\*%%' node_modules/passport-yahoo/node_modules/passport-openid/node_modules/openid/openid.js

Invalid Signature

Yahoo OpenID stopped working for me recently (not sure exactly when, but ball park a few days?). Any idea if it is a problem with openid.js or a problem with Yahoo?

Any advice/direction is appreciated.

It is failing with an error "Invalid signature". This is the stack trace:

{
"message":"Failed to verify assertion",
"stack":"Failed to verify assertion (message: Invalid signature)
    at app/node_modules/passport-yahoo/node_modules/passport-openid/lib/passport-openid/strategy.js:184:36
    at app/node_modules/passport-yahoo/node_modules/passport-openid/node_modules/openid/openid.js:1063:12
    at app/node_modules/passport-yahoo/node_modules/passport-openid/node_modules/openid/openid.js:1188:14
    at app/node_modules/passport-yahoo/node_modules/passport-openid/node_modules/openid/openid.js:1269:7
    at Object.openid.loadAssociation (app/node_modules/passport-yahoo/node_modules/passport-openid/node_modules/openid/openid.js:107:5)
    at _checkSignatureUsingAssociation (app/node_modules/passport-yahoo/node_modules/passport-openid/node_modules/openid/openid.js:1231:10)
    at _checkSignature (app/node_modules/passport-yahoo/node_modules/passport-openid/node_modules/openid/openid.js:1221:5)
    at _verifyAssertionAgainstProvider (app/node_modules/passport-yahoo/node_modules/passport-openid/node_modules/openid/openid.js:1184:3)
    at app/node_modules/passport-yahoo/node_modules/passport-openid/node_modules/openid/openid.js:1155:16
    at app/node_modules/passport-yahoo/node_modules/passport-openid/node_modules/openid/openid.js:678:7
    at app/node_modules/passport-yahoo/node_modules/passport-openid/node_modules/openid/openid.js:533:11
    at done (app/node_modules/passport-yahoo/node_modules/passport-openid/node_modules/openid/openid.js:254:9)
    at IncomingMessage.<anonymous> (app/node_modules/passport-yahoo/node_modules/passport-openid/node_modules/openid/openid.js:258:32)
    at IncomingMessage.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:920:16
    at process._tickCallback (node.js:415:13)",
"name":"InternalOpenIDError",
"openidError":{"message":"Invalid signature"}
}

Error: Can't set headers after they are sent

I have been trying to debug an error in my app for quite a while now and decided to run the example in this repo to reset my head and understand how everything should be hooked up correctly. However, when I ran the demo in this app, it spat out the same error that I am seeing in my app:

Error: Can't set headers after they are sent.
    at ServerResponse.OutgoingMessage.setHeader (http.js:691:11)
    at ServerResponse.res.setHeader (passport-yahoo/examples/signon/node_modules/express/node_modules/connect/lib/patch.js:63:22)
    at next (passport-yahoo/examples/signon/node_modules/express/node_modules/connect/lib/proto.js:156:13)
    at pass (passport-yahoo/examples/signon/node_modules/express/lib/router/index.js:110:24)
    at nextRoute (passport-yahoo/examples/signon/node_modules/express/lib/router/index.js:100:7)
    at callbacks (passport-yahoo/examples/signon/node_modules/express/lib/router/index.js:167:11)
    at complete (passport-yahoo/examples/signon/node_modules/passport/lib/middleware/authenticate.js:243:13)
    at passport-yahoo/examples/signon/node_modules/passport/lib/middleware/authenticate.js:250:15
    at pass (passport-yahoo/examples/signon/node_modules/passport/lib/authenticator.js:427:14)
    at Authenticator.transformAuthInfo (passport-yahoo/examples/signon/node_modules/passport/lib/authenticator.js:449:5)

Yahoo OpenID has been experiencing issues for a while, but shouldn't the passport module gracefully propagate this error up through the stack so that my next error handler middleware can handle the error correctly (redirect to an error page, for example).

After some googling, I reviewed the following pages (among others) and think I have my error handling setup correctly for once the passport module propagates the error up:

Any thoughts?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.