Auth0 runs an Action before it creates a user who signs up with a password or a passwordless code (a Database or Passwordless connection), and that Action can call Bot Protection and refuse the sign-up. The sign-up page is Auth0's, on Auth0's domain, so the Action has no _kz cookie: the decision stands on the IP and the User-Agent.
The tag
Put the tag on your own pages, where people arrive before they sign up and where they sign in and pay, so those decisions have the token:
<script src="https://eu.korzen.dev/v1/tag.js" data-site-key="YOUR_SITE_KEY" async></script>
The call
The Action, with Korzen's npm package @korzen/bot-protection as its dependency: it has no dependencies of its own and runs on the Action's Node 22. An Action often starts cold, and its first call opens a new connection to Bot Protection, slower than the one a server keeps open, so its timeout is one second, of the 20 seconds Auth0 gives the Action in all. A slower answer, or any error, lets the sign-up through:
// Auth0 Dashboard: Actions, Triggers, pre-user-registration; a new Action. // Add the dependency @korzen/bot-protection and the secret KORZEN_API_KEY to the Action. const { createClient } = require("@korzen/bot-protection"); let korzen, key; // one client while the Action stays warm: it keeps the connection open exports.onExecutePreUserRegistration = async (event, api) => { if (key !== event.secrets.KORZEN_API_KEY) { key = event.secrets.KORZEN_API_KEY; // One second: a cold Action's first call opens its connection, which a short timeout cuts korzen = createClient({ apiKey: key, url: "https://eu.korzen.dev", timeoutMs: 1000 }); } const d = await korzen.decide({ ip: event.request.ip, ip_from: "custom", // Auth0's reading of it user_agent: event.request.user_agent, ja4: event.security_context?.ja4 || undefined, // behind Cloudflare only: left out without it headers: { "accept-language": event.request.language }, path: "/signup", method: "POST", }); // null on any error: fail open if (d?.action === "block") { api.access.deny("korzen_block", "We could not create your account."); return; } if (d?.request_id) api.user.setAppMetadata("korzen_request_id", d.request_id); };
Auth0 gives the Action the browser's language and User-Agent but none of the request's other headers, so the call forwards accept-language alone: the other headers Bot Protection reads in your own server's calls are missing here.
On a tenant whose traffic comes through Cloudflare (Auth0's Enterprise plans), the event also has security_context.ja4: the JA4 of the visitor's TLS handshake with Auth0's edge, the same form Bot Protection reads from Cloudflare in front of your own server. The call sends it as ja4 when it is there; without it, it is left out.
The visitor's IP
event.request.ip is the address that reached Auth0, already the visitor's: nothing to set up. On a custom domain behind your own proxy, see Auth0's custom domain settings for the visitor's IP.
Auth0's decisions come without the tag's token. A missing token never makes a visitor bot on its own. The call sends no protected_action for that reason: with it, block mode would block every sign-up.
Apply the action
Read only action. On block, answer with the same error the action shows when it fails for any other reason, so a bot learns nothing. The account starts in monitor mode, where action is always allow: nothing changes for visitors until you turn on block mode.
Keep the answer's request_id with what the action created, such as the account or the order: it names that decision when you ask us about it. The answer
Test it on your machine
Use your development tenant. In the Action editor, Test runs it with a sample event; then sign up on your login page, and the decision shows on the dashboard's Decisions page under /signup. Check fail open with a wrong KORZEN_API_KEY secret: the sign-up goes through.
Common mistakes
- Social sign-ups. Google, GitHub and the like do not run the pre-user-registration trigger; a post-login Action can ask Bot Protection about them on their first sign-in.
- Calling
/v1/decidefrom the browser. The API key would reach every visitor; the call belongs on your server. - No timeout, or an error that stops the sign-up. Any answer other than
200, and no answer in time, means: let the visitor through.