Skip to content

Commit 184915a

Browse files
committed
Update CSP header for cloudflare turnstile
1 parent d87a6bf commit 184915a

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

apps/api/src/main.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ if (ENV.NODE_ENV === 'production' && !ENV.CI && cluster.isPrimary) {
130130
'*.rollbar.com',
131131
'api.amplitude.com',
132132
'api.cloudinary.com',
133-
'challenges.cloudflare.com',
134-
'ip-api.com',
133+
'https://challenges.cloudflare.com',
135134
],
136135
baseUri: ["'self'"],
137136
blockAllMixedContent: [],
@@ -163,7 +162,7 @@ if (ENV.NODE_ENV === 'production' && !ENV.CI && cluster.isPrimary) {
163162
'*.gstatic.com',
164163
'*.google-analytics.com',
165164
'*.googletagmanager.com',
166-
'challenges.cloudflare.com',
165+
'https://challenges.cloudflare.com',
167166
],
168167
scriptSrcAttr: ["'none'"],
169168
styleSrc: ["'self'", 'https:', "'unsafe-inline'"],

apps/landing/components/auth/Captcha.tsx

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
import { Turnstile } from '@marsidev/react-turnstile';
12
import { useId } from 'react';
2-
import Turnstile from 'react-turnstile';
33
import { ENVIRONMENT } from '../../utils/environment';
44

55
interface CaptchaProps {
66
action: string;
77
formError?: string;
8+
onLoad?: () => void;
89
onChange: (token: string) => void;
910
}
1011

11-
export function Captcha({ action, formError, onChange }: CaptchaProps) {
12+
export function Captcha({ action, formError, onLoad, onChange }: CaptchaProps) {
1213
const id = useId();
1314

1415
// Skip rendering the captcha if we're running in Playwright or if the key is not set
@@ -21,16 +22,16 @@ export function Captcha({ action, formError, onChange }: CaptchaProps) {
2122
<>
2223
<Turnstile
2324
id={id}
24-
sitekey={ENVIRONMENT.CAPTCHA_KEY}
25-
theme="light"
26-
appearance="always"
27-
size="flexible"
28-
refreshExpired="auto"
29-
fixedSize
30-
action={action}
31-
onVerify={(token) => onChange(token)}
32-
// onError={}
33-
onSuccess={(token, preClearanceObtained) => onChange(token)}
25+
siteKey={ENVIRONMENT.CAPTCHA_KEY}
26+
options={{
27+
action,
28+
theme: 'light',
29+
appearance: 'always',
30+
size: 'flexible',
31+
refreshExpired: 'auto',
32+
}}
33+
onWidgetLoad={onLoad}
34+
onSuccess={(token) => onChange(token)}
3435
/>
3536
{formError && (
3637
<p id={`${id}-error`} role="alert" className="mt-2 text-sm text-red-600">

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@
244244
"@heroicons/react": "^1.0.4",
245245
"@hookform/resolvers": "^3.9.0",
246246
"@jetstreamapp/soql-parser-js": "^6.1.0",
247+
"@marsidev/react-turnstile": "^1.0.2",
247248
"@mdx-js/react": "^1.6.21",
248249
"@monaco-editor/react": "^4.6.0",
249250
"@opentelemetry/api": "^1.8.0",
@@ -339,7 +340,6 @@
339340
"react-resize-detector": "^10.0.1",
340341
"react-router-dom": "6.11.2",
341342
"react-split": "^2.0.14",
342-
"react-turnstile": "^1.1.4",
343343
"react-use-clipboard": "^1.0.9",
344344
"recoil": "^0.7.7",
345345
"regenerator-runtime": "0.13.7",

yarn.lock

+5-5
Original file line numberDiff line numberDiff line change
@@ -5556,6 +5556,11 @@
55565556
semver "^7.3.5"
55575557
tar "^6.1.11"
55585558

5559+
"@marsidev/react-turnstile@^1.0.2":
5560+
version "1.0.2"
5561+
resolved "https://registry.yarnpkg.com/@marsidev/react-turnstile/-/react-turnstile-1.0.2.tgz#d4ca03b6c31793bc73b3b99f5b991539a56f7f36"
5562+
integrity sha512-YkCtJVaCzZ1kcmhPsiFTmTXVughoNzEMRsNHcmTG0K5OdbCQfAG67Q6d5Ze+A72vrHbvVZkvcLgUbldeGcbRjQ==
5563+
55595564
"@maxim_mazurok/gapi.client.discovery-v1@latest":
55605565
version "0.1.20200806"
55615566
resolved "https://registry.yarnpkg.com/@maxim_mazurok/gapi.client.discovery-v1/-/gapi.client.discovery-v1-0.1.20200806.tgz#1bdb82fadd659a159765178993dff6dbcb5968bc"
@@ -21729,11 +21734,6 @@ react-transition-group@^4.3.0:
2172921734
loose-envify "^1.4.0"
2173021735
prop-types "^15.6.2"
2173121736

21732-
react-turnstile@^1.1.4:
21733-
version "1.1.4"
21734-
resolved "https://registry.yarnpkg.com/react-turnstile/-/react-turnstile-1.1.4.tgz#0c23b2f4b55f83b929407ae9bfbd211fbe5df362"
21735-
integrity sha512-oluyRWADdsufCt5eMqacW4gfw8/csr6Tk+fmuaMx0PWMKP1SX1iCviLvD2D5w92eAzIYDHi/krUWGHhlfzxTpQ==
21736-
2173721737
react-use-clipboard@^1.0.9:
2173821738
version "1.0.9"
2173921739
resolved "https://registry.yarnpkg.com/react-use-clipboard/-/react-use-clipboard-1.0.9.tgz#d34d4d04500f77c606795d3756fc587ec93db8d2"

0 commit comments

Comments
 (0)