Skip to content
This repository has been archived by the owner on Sep 12, 2019. It is now read-only.

Inject client context into functions #138

Merged
merged 1 commit into from
Apr 18, 2019
Merged

Conversation

irreal
Copy link
Contributor

@irreal irreal commented Apr 18, 2019

- Summary

When the Netlify function is invoked with an Authorization header containing a bearer token, this decodes the information inside the token and populates the client context, just like the production environment does.

This is a straight up port of the same functionality from this netlify-lambda PR and is crucial for local development of functions that use authentication.

Just like in netlify-lambda, this doesn't actually validate the token, it only decodes the public part and injects it into the invocation.

- Test plan

Proper testing support doesn't seem to be in place yet, so I tested this change by compiling the Netlify cli locally with this fork of the netlify-dev-plugin in place, and everything ran well.

The info is populated if you have a valid bearer token present, otherwise it's left empty as expected.

- Description for the changelog

Populate client context if authorization header with a bearer token is present in function invocation

@swyxio
Copy link
Contributor

swyxio commented Apr 18, 2019

yes i wanted this too but we punted on it for the launch. thanks for taking the initiative!

@swyxio swyxio merged commit bdd8489 into netlify:master Apr 18, 2019
swyxio added a commit that referenced this pull request Apr 18, 2019
Inject client context into functions
@swyxio
Copy link
Contributor

swyxio commented Apr 18, 2019

released in cli v2.11.11

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

Successfully merging this pull request may close these issues.

2 participants