Allow access only on weekdays for a specific application
Let’s say you have an application that you want to make sure is only accessible during weekdays. Create a new Action, and select theLogin / Post Login
trigger because you’ll be adding the Action to the Login flow. Copy the following code to the Actions Code Editor:
Allow access only to users who are inside the corporate network
Let’s say you want to allow access to an application, but only for users who are accessing the application from inside your corporate network. Create a new Action, and select theLogin / Post Login
trigger because you’ll be adding the Action to the Login flow. Copy the following code to the Actions Code Editor:
To use an
npm
library like ipaddr.js
, you must add the library as a dependency to the Action. To learn more, read the “Add a dependency” section in Write Your First Action.Deny access to anyone calling an API
Let’s say you want to deny access to all users who are calling an API. This means that you need to deny access depending on theidentifier
value for your API, which you can find in the API field of your API at Auth0 Dashboard > Applications > APIs. Create a new Action, and select the Login / Post Login
trigger because you’ll be adding the Action to the Login flow. Copy the following code to the Actions Code Editor:
identifier
value for the API is https://api.example.com
, so this is the audience we will refuse.
Add user roles to tokens
To add user roles to Auth0-issued tokens, use theevent.authorization
object along with the api.idToken.setCustomClaim
and api.accessToken.setCustomClaim
methods. Create a new Action, and select the Login / Post Login
trigger because you’ll be adding the Action to the Login flow. Copy the following code to the Actions Code Editor:
- The returned to the requesting application is built and signed at the end of the trigger processing. The final, signed JWT is not accessible in an Action.
Deny access to specific JA3/JA4 fingerprints
Theevent.security_context
object contains the JA3/JA4 fingerprint values for the current transaction.
Create a new Action, and select the Login / Post Login
trigger because you’ll be adding the Action to the Login flow. Copy the following code to the Actions Code Editor: