You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/docs/(guides)/concepts/sign-up-rules.mdx
+28-1Lines changed: 28 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: Sign-up Rules
3
3
description: Control who can sign up for your application with customizable rules.
4
4
icon: ShieldCheck
5
-
lastModified: "2026-02-24"
5
+
lastModified: "2026-03-20"
6
6
---
7
7
8
8
Sign-up rules let you control who can sign up for your application. You can create rules that evaluate sign-up attempts based on conditions like email domain or authentication method, then allow, reject, or restrict users accordingly.
@@ -31,6 +31,9 @@ When building rule conditions, you have access to these context variables:
31
31
|`emailDomain`| string | The domain part of the email (after @) |
32
32
|`authMethod`| string | The authentication method: `password`, `otp`, `oauth`, or `passkey`|
33
33
|`oauthProvider`| string | The OAuth provider ID if using OAuth (e.g., `google`, `github`), empty string otherwise |
34
+
|`countryCode`| string | ISO 3166-1 alpha-2 country code detected at sign-up (e.g., `US`, `DE`, `JP`). Empty string if unavailable. |
35
+
|`riskScores.bot`| number | Bot risk score from 0-100. Higher values indicate higher likelihood of automated sign-up attempts. |
36
+
|`riskScores.free_trial_abuse`| number | Free trial abuse risk score from 0-100. Higher values indicate abuse patterns like disposable emails or repeated sign-ups. |
34
37
35
38
The condition builder supports these operations on string values:
36
39
@@ -39,6 +42,9 @@ The condition builder supports these operations on string values:
39
42
-`endsWith("suffix")` - Check if value ends with a suffix
40
43
-`matches("regex")` - Check if value matches a regular expression
41
44
-`==` and `!=` - Exact equality comparisons
45
+
-`in` - Check if value is in a list (e.g., `countryCode in ["US", "CA"]`)
46
+
47
+
For numeric fields like risk scores, you can use comparison operators: `>`, `>=`, `<`, `<=`.
42
48
43
49
You can combine multiple conditions using AND/OR logic.
44
50
@@ -100,6 +106,27 @@ Allow password sign-ups from any domain, but restrict OAuth sign-ups:
100
106
2. Rule 2: `authMethod == "oauth"` → Restrict
101
107
3. Default: Allow
102
108
109
+
### Block high-risk bot sign-ups
110
+
111
+
Block sign-ups with a high bot risk score:
112
+
113
+
- Condition: `riskScores.bot > 70`
114
+
- Action: Reject
115
+
116
+
### Restrict sign-ups from specific countries
117
+
118
+
Require manual review for sign-ups from certain countries:
119
+
120
+
- Condition: `countryCode in ["XX", "YY"]` (replace with actual country codes)
The dashboard shows analytics for each rule, including how many times it's been triggered over the past 48 hours. Use this to understand your sign-up patterns and tune your rules.
Copy file name to clipboardExpand all lines: docs/content/docs/(guides)/others/self-host.mdx
+21-1Lines changed: 21 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
title: Self-host
3
-
lastModified: "2026-01-10"
3
+
lastModified: "2026-03-20"
4
4
---
5
5
6
6
<Infotype="danger">
@@ -121,3 +121,23 @@ To manage your dashboard configs with this account, manually go into the databas
121
121
Go back to the dashboard, refresh the page, and you should see the "Stack Dashboard" project. We recommend disabling new user sign-ups to your internal project to avoid unauthorized account and project creations.
122
122
123
123
Now, create a new project for your app and follow the [normal setup process](../getting-started/setup.mdx). Add `NEXT_PUBLIC_STACK_API_URL=https://your-backend-url.com` to your app's environment variables so that it connects to your API backend instead of the default Stack Auth API backend (https://api.stack-auth.com).
124
+
125
+
## Bot protection (Turnstile)
126
+
127
+
Stack Auth uses Cloudflare Turnstile to protect sign-up flows from bots. By default, self-hosted instances use Cloudflare's development test keys, which always pass without showing a challenge.
128
+
129
+
For production, configure your own Turnstile keys from the [Cloudflare Dashboard](https://dash.cloudflare.com/?to=/:account/turnstile):
130
+
131
+
| Environment Variable | Description |
132
+
|---------------------|-------------|
133
+
|`NEXT_PUBLIC_STACK_BOT_CHALLENGE_SITE_KEY`| Turnstile site key for visible challenges. |
134
+
|`NEXT_PUBLIC_STACK_BOT_CHALLENGE_INVISIBLE_SITE_KEY`| Turnstile site key for invisible challenges. |
135
+
|`STACK_TURNSTILE_SECRET_KEY`| Turnstile secret key for server-side verification. |
136
+
137
+
Optional settings:
138
+
139
+
| Environment Variable | Description |
140
+
|---------------------|-------------|
141
+
|`STACK_DISABLE_BOT_CHALLENGE`| Set to `true` to disable Turnstile entirely. |
142
+
|`STACK_ALLOW_SIGN_UP_ON_VISIBLE_BOT_CHALLENGE_FAILURE`| Set to `true` to allow sign-ups even when the visible challenge fails (not recommended for production). |
143
+
|`STACK_TRUSTED_PROXY`| Set to `vercel` or `cloudflare` to trust the respective reverse proxy for reading client IP addresses. Required for accurate IP-based fraud detection when running behind a proxy. |
0 commit comments