Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't serve functions locally that do non-JWT bearer authorization #107

Closed
pimterry opened this issue Jan 30, 2019 · 4 comments
Closed

Can't serve functions locally that do non-JWT bearer authorization #107

pimterry opened this issue Jan 30, 2019 · 4 comments

Comments

@pimterry
Copy link
Contributor

I have a function that takes a bearer token in its authorization header which isn't a JWT.

When deployed to Netlify, that works fine, everything's great.

When run locally with netlify-lambda serve, any bearer tokens present are always parsed as JWTs, which fails, so the function returns 500 and never runs: https://github.com/netlify/netlify-lambda/blob/master/lib/serve.js#L83-L91.

I think the logic there should handle this case. If there's a bearer token that parses as a JWT, emulate assume it's a Netlify JWT and emulate Netlify identity. However if token parsing fails, continue the request as an unauthenticated request, and so potentially allow the function to use/validate the authorization token itself.

For now as far as I can tell there's no nice way to work around this, so my function works perfectly when deployed but is impossible to test locally, so this is a fairly major problem for this case.

@swyxio
Copy link
Contributor

swyxio commented Jan 30, 2019

yikes. that was a recent PR and we never thought about your usecase. wanna try your hand at a PR?

@pimterry
Copy link
Contributor Author

@sw-yx sure, done #108

@swyxio
Copy link
Contributor

swyxio commented Jan 31, 2019

released as 1.3.1

@pimterry
Copy link
Contributor Author

Great stuff, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants