Skip to content

sandrinodimattia/azure-functions-auth0

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Authenticate your Azure Functions (Http) with Auth0

Resources

License

Stars

Watchers

Forks

Packages

No packages published