docs: Document Turnstile fraud protection and new sign-up rule conditions#1278
docs: Document Turnstile fraud protection and new sign-up rule conditions#1278promptless[bot] wants to merge 1 commit intodevfrom
Conversation
| | `emailDomain` | string | The domain part of the email (after @) | | ||
| | `authMethod` | string | The authentication method: `password`, `otp`, `oauth`, or `passkey` | | ||
| | `oauthProvider` | string | The OAuth provider ID if using OAuth (e.g., `google`, `github`), empty string otherwise | | ||
| | `countryCode` | string | ISO 3166-1 alpha-2 country code detected at sign-up (e.g., `US`, `DE`, `JP`). Empty string if unavailable. | |
There was a problem hiding this comment.
Citation: Added countryCode and riskScores conditions based on the new SignUpRuleContext type in apps/backend/src/lib/cel-evaluator.ts which now includes countryCode, riskScores.bot, and riskScores.free_trial_abuse fields for fraud protection rule evaluation.
View source
|
|
||
| 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). | ||
|
|
||
| ## Bot protection (Turnstile) |
There was a problem hiding this comment.
Citation: Turnstile environment variables documented based on apps/backend/.env.development which shows the new Turnstile configuration options: NEXT_PUBLIC_STACK_BOT_CHALLENGE_SITE_KEY, NEXT_PUBLIC_STACK_BOT_CHALLENGE_INVISIBLE_SITE_KEY, STACK_TURNSTILE_SECRET_KEY, STACK_DISABLE_BOT_CHALLENGE, STACK_ALLOW_SIGN_UP_ON_VISIBLE_BOT_CHALLENGE_FAILURE, and STACK_TRUSTED_PROXY.
View source
| </MethodLayout> | ||
| </CollapsibleTypesSection> | ||
|
|
||
| <CollapsibleTypesSection type="serverUser" property="countryCode" defaultOpen={false}> |
There was a problem hiding this comment.
Citation: New countryCode and riskScores properties on ServerUser based on changes to apps/backend/src/app/api/latest/users/crud.tsx which adds country_code and risk_scores to the user CRUD response, derived from the new signUpCountryCode, signUpRiskScoreBot, and signUpRiskScoreFreeTrialAbuse database fields.
View source
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
|
Greptile SummaryThis documentation PR covers the Turnstile fraud protection integration shipped in #1239, touching three files: sign-up rules, the ServerUser SDK reference, and the self-host guide.
Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Sign-up attempt] --> B[Cloudflare Turnstile challenge]
B --> C{Challenge result}
C -->|ok| D[Compute risk scores\nbot, free_trial_abuse]
C -->|invalid / error| E{STACK_ALLOW_SIGN_UP_ON_\nVISIBLE_BOT_CHALLENGE_FAILURE?}
E -->|true| D
E -->|false| REJECT[Reject sign-up]
D --> F[Detect country code\nvia proxy headers\nSTACK_TRUSTED_PROXY]
F --> G[Build CEL context\nemail, emailDomain, authMethod,\noauthProvider, countryCode,\nriskScores.bot, riskScores.free_trial_abuse]
G --> H[Evaluate sign-up rules\nin priority order]
H --> I{First matching rule}
I -->|Allow| ALLOW[Allow sign-up\nStore countryCode + riskScores\non ServerUser]
I -->|Reject| REJECT
I -->|Restrict| RESTRICT[Allow sign-up\nbut mark as restricted]
I -->|Log| LOG[Log and continue\nto default action]
I -->|No match| DEFAULT[Apply default action]
|
Open this suggestion in Promptless to view citations and reasoning process
Documents the new Turnstile integration for fraud protection from PR #1239. Adds
countryCodeandriskScores(bot, free_trial_abuse) to sign-up rules conditions with example use cases. Documents newcountryCodeandriskScoresproperties in ServerUser SDK reference. Adds Turnstile configuration section for self-hosted deployments.Trigger Events
stack-auth/stack-auth commit (dev): e59a707 Turnstile integration for fraud protection (#1239)
Promptless Research (6 files, 1 GitHub PR)
.long_term_context/product_knowledge/product_overview.md.long_term_context/doc_workflow/client_instructions.md.long_term_context/style/client_style_guide.mddocs/content/docs/(guides)/concepts/sign-up-rules.mdxdocs/content/docs/sdk/types/user.mdxdocs/content/docs/(guides)/others/self-host.mdxAgent Response
Tip: Leave inline comments with
@Promptlesson suggestion diffs in the Promptless dashboard for targeted refinements 💬