Skip to content

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

Closed
@pimterry

Description

@pimterry

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions