jaredhanson / passport-openid

OpenID authentication strategy for Passport and Node.js.
https://www.passportjs.org/packages/passport-openid/?utm_source=github&utm_medium=referral&utm_campaign=passport-openid&utm_content=about
MIT License
98 stars 90 forks source link

Any plan of supporting POST request issued from openid-provider after authtentication passed #29

Open catinthesky opened 10 years ago

catinthesky commented 10 years ago

Hello, Recently I fount the module (passport-openid) seems now not supporting POST request issued from OpenID-provider after passing the authentication (here meaning after inputting the username and password), and the relying node.js app side would hang there in fact trapped in the deal loop, further checking shows that it's the openid-passport module not support this POST request type, the relevant code I found are:

1) In passport-openid's strategy.js: Strategy.prototype.authenticate = function(req) { if (req.query['openid.mode'] === 'cancel') { return this.fail({ message: 'OpenID authentication canceled' }); } //here the code assume, the request to be GET method

2) and openid module's openid.verifyAssertion function which seems not have a good support for POST request.

So is there any plan to support the POST request ?

Thanks a lot.

SatyaBulusu commented 9 years ago

@jaredhanson Hi Jared, Thanks for building such a useful library. In my case, the OP is issuing a POST reuest. As @yaozaiyong mentioned, any plans to handle the POST request and parse the form data from request body.

zackerydev commented 5 years ago

Here's a workaround I've user to handle the POST call, not to revive a dead issue but this might help someone in the future:

app.post(
  '/auth/openid/return',
  (req, res, next) => {
    if (req.body['openid.mode']) {
      req.url = req.url + '?' + qs.stringify(req.body);
    }
    req.query = req.body;
    next();
  },
  passport.authenticate('openid', {
    failureRedirect: '/login'
  }),
  (req, res) => {
    res.redirect('/');
  }
);