@webiny/api-security-auth0
v5.41.1
Published
Security plugins for Auth0
Downloads
884
Readme
@webiny/api-security-auth0
In .env
file, add your Auth0 variables:
# Auth0 variables for the API.
AUTH0_DOMAIN=https://dev-12345678.us.auth0.com
AUTH0_CLIENT_ID=111111111111111
# Auth0 variables for React apps (webpack will pick this up).
REACT_APP_AUTH0_DOMAIN=https://dev-12345678.us.auth0.com
REACT_APP_AUTH0_CLIENT_ID=111111111111111
Auth0 Action to add custom claims:
/**
* Handler that will be called during the execution of a PostLogin flow.
*
* @param {Event} event - Details about the user and the context in which they are logging in.
* @param {PostLoginAPI} api - Interface whose methods can be used to change the behavior of the login.
*/
exports.onExecutePostLogin = async (event, api) => {
if (event.authorization) {
api.idToken.setCustomClaim(`webiny_group`, event.user.app_metadata.group);
}
};