passport icon indicating copy to clipboard operation
passport copied to clipboard

passport.authenticate fails in AWS Lambda

Open syntacticsolutions opened this issue 7 years ago • 7 comments

Hi, I have an implementation using the passport-saml strategy and it works on a dockerized instance. When I place the same code on a lambda function using aws-serverless-express I can hit the post endpoint, but passport.authenticate fails and I get a 502 response from the server. If I take that function out then it works as expected. Shouldn't the passport.authenticate execute a callback? How do I show errors? I think the lambda function is closing before it receives the response from passport.authenticate (assuming that it is an asynchronous function) but I have no way to force lambda to wait for the response I can't do async and await because the callback appears to be handled within the function. Is this some kind of middleware function? How is it receiving the req and response? This is what my code looks like

app.post('/saml/consume', 
passport.authenticate('saml', { failureRedirect: '/', failureFlash: true }), 
(req, res) => {
	res.redirect('/app');
})

I don't even know how to put a try catch block in there because it appears to be a middleware function

syntacticsolutions avatar Feb 13 '18 20:02 syntacticsolutions

Ok I solved the problem. Turns out API Gateway doesn't support multi-part/formdata. You can close this.

syntacticsolutions avatar Feb 13 '18 21:02 syntacticsolutions

Hi, I'm also trying to use passport (facebook) with AWS Lambda. Did you find any workaround?

andyli avatar Sep 27 '18 07:09 andyli

Hi, any solution?

kantharia avatar Dec 24 '18 09:12 kantharia

Apparently this is now supported. See https://stackoverflow.com/a/41770688/153629

However after adding multi-part/formdata support to my API Gateway I'm still not having any success.

@kantharia @andyli did you ever get this working?

philwilks avatar Aug 26 '19 17:08 philwilks

+1 not working..

whiteBeer avatar Aug 19 '20 17:08 whiteBeer

I got it working: The code executing in the lambda can't access the public internet. When I just wrote a lambda using nodejs fetch, the lambda hangs. You have to setup the lambda like this: https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Scenario2.html . Then it worked perfectly. Thanks to the aws support.

Superlokkus avatar Dec 14 '20 10:12 Superlokkus

Hey, anyone got passport strategy working in aws lambda? I'm having issues for docusign, it works locally but not on lambda! Checked VPC it has access to public internet. The callback seems not to be working.

Pio-Dev-Github avatar Feb 28 '23 11:02 Pio-Dev-Github