1.1.0 • Published 3 years ago

azure-functions-auth0-fork v1.1.0

Weekly downloads
6
License
MIT
Repository
github
Last release
3 years ago

azure-functions-auth0

Authenticating Azure Functions with Auth0. See this blog post for more details.

Configuration

const auth0 = require('azure-functions-auth0')({
  clientId: '...',
  clientSecret: '...',
  domain: 'example.auth0.com'
});

module.exports = auth0(function(context, req) {
  // YOUR USUAL CODE GOES HERE.
  if (req.user)) {
    context.res = {
      body: req.user
    };
  }
  else {
    context.res = {
      status: 400,
      body: "The user seems to be missing"
    };
  }
  context.done();
});

Usage

Now then when you make a call to the Http endpoint you'll need to add an Auth0 user token in the header. Eg:

GET https://functionsad5bb49d.azurewebsites.net/api/my-http-function?code=1pvuf...
Authorization: Bearer my-auth0-token

A boilerplate repository is also available to show how this works.