-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add cloudflare turnstile #181
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you rebase for the changes to main that now uses server side rendering for the main page.
async function verifyTurnstile(token: string, ip: string) { | ||
const formData = new FormData(); | ||
formData.append('secret', process.env.TURNSTILE_SECRET_KEY as string); | ||
formData.append('response', token); | ||
formData.append('remoteip', ip); | ||
|
||
const url = 'https://challenges.cloudflare.com/turnstile/v0/siteverify'; | ||
const result = await fetch(url, { | ||
body: formData, | ||
method: 'POST', | ||
}); | ||
|
||
const json = await result.json(); | ||
|
||
return json.success; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So from briefly reading about cloudflare turnstiles it does look like a good option if we don't need a manual challenge. I was initially thinking to use the Supabase captcha, but this works.
The main thing we want to do is protect the authentication page to avoid bots and from reading about this we want to have a client side check that is verified on the server.
That makes me think a dedicated server action for cloudflare would make sense that we call on the authentication page as well. We might want to add it to the layout.tsx
so it's called on all pages?
see #184 |
make sure to add env vars before merging