Auth0 Extension Tools for Express
A set of tools and utilities to simplify the development of Auth0 Extensions with Epxress.
Usage
const expressTools = ;
Start an Express Server.
Here's what you need to use it as an entrypoint for your Webtask:
const expressApp = ; moduleexports = expressTools;
Then you can create your Express server like this:
module { // 'config' is a method that exposes process.env, Webtask params and secrets console; // 'storage' is a Webtask storage object: https://webtask.io/docs/storage storage; const app = ; app; app; ... // Finally you just have to return the app here. return app;};
Middlewares
Authentication Required Middleware
Force a user to be set on the request. If no user is present, an UnauthorizedError
will be returned.
const middlewares = middlewares; const app = ;... app;
User Authentication Middleware
Validate an end user token using RS256.
const authenticateUsers = authenticateUsers; const app = ;app
You can also optionally set the middleware to only execute when a token is provided where the issuer matches the configured issuer. If not token is provided, or a token is provided with a different issuer, this middleware will not run.
const authenticateUsers = authenticateUsers; const app = ;app
Auth0 Administrator Authentication Middleware
Validate an administrator session token.
const authenticateAdmins = authenticateAdmins; const app = ;app
You can also optionally set the middleware to only execute when a token is provided where the issuer matches the configured issuer. If not token is provided, or a token is provided with a different issuer, this middleware will not run.
const authenticateUsers = authenticateUsers; const app = ;app
API v2 Middleware
A middleware to inject the Management API Client for Node.js on the current request:
const middlewares = middlewares; const app = ;app;app; const managementClient = middlewares; app;
Hook Token Middleware
A middleware to validate tokens from the Management Dashboard when installing/updating/uninstalling Extensions:
const middlewares = middlewares; const app = ;app;app; const hookValidator = middlewares;app;app;
Url Helpers
const urlHelpers = urlHelpers; // Eg: /api/run/mytenant/abc/const basePath = urlHelpers; // Eg: http://sandbox.it.auth0.com/api/run/mytenant/abcconst baseUrl = urlHelpers;