passport.authenticate fails in AWS Lambda
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
Ok I solved the problem. Turns out API Gateway doesn't support multi-part/formdata. You can close this.
Hi, I'm also trying to use passport (facebook) with AWS Lambda. Did you find any workaround?
Hi, any solution?
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?
+1 not working..
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.
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.