Auth0 conveniently provides security solutions.
One of Auth0's main features is being able to provide JWT tokens for authentication.
Aside from mainly using JWT token for verification, you can also customize the JWT token to include other details that can be used for additional security verification.
For example, an application might include user email in the request headers. You can compare the email provided in the headers to the email provided by the decoded Auth0 JWT token.
First we need to set this up in the Auth0 dashboard.
Auth Pipeline > Rules > Create Rule > Empty Rule
// provide a url namespace string const namespace = 'https://www.test-namespace.com/'; context.accessToken[namespace + "user_email"] = user.email; callback(null, user, context); }
Reminder: You have to provide a URL namespace string or Auth0 wouldn't return the metadata (I myself got stuck here). This has something to do with OIDC Namespace specifications.
Once the rule is applied. You will find the email(or other data you included in the token) when you decode it.
To confirm paste the provided Auth0 token in https://jwt.io/. The decoded token payload will show user email as one of its payload:
I provided a simple example but there are many use cases for inserting data in the JWT token.
Until next time.
Stay stoked and code. :)