Prevent Logins from a Particular Client without Blocking the IP Address within Auth0
There is a need to prevent logins coming from a particular client who is no longer using the service. Deleting the client would not stop the automated requests from hitting Auth0. Blocking an IP address is not possible because it is shared among other active clients.
- Client requests
- Actions
To prevent login requests coming from a particular client that shares the same IP as other active clients, use an Action with api.access.deny in place. Create an if check, and if the event.client.name == blocked client name, then call the api.access.deny(“reason”) to deny the request.
In order to implement this, please follow the steps below:
- Navigate to Auth0 Dashboard > Actions > Triggers.
- Click on Post-Login Trigger.
- Add Action > Use the template below as a reference and click Deploy.
- Navigate back to the Post-login Trigger.
- Then drag the action into the trigger and hit Apply.
exports.onExecutePostLogin = async (event, api) => {
if (event.client.name === "Unallowed Application") {
return api.access.deny("Access denied for this application.");
}
};
Related References