Skip to content
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

modified reading tokens from headers #620

Merged
merged 2 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions brightIDfaucet/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from dotenv import load_dotenv
from sentry_sdk.integrations.django import DjangoIntegration

from corsheaders.defaults import default_headers

from faucet.faucet_manager.bright_id_interface import BrightIDInterface

load_dotenv()
Expand Down Expand Up @@ -244,6 +246,11 @@ def before_send(event, hint):
else:
CORS_ALLOW_ALL_ORIGINS = True

CORS_ALLOW_HEADERS = list(default_headers) + [
alimaktabi marked this conversation as resolved.
Show resolved Hide resolved
'cf-turnstile-response',
'hc-turnstile-response',
]

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/

Expand Down
4 changes: 2 additions & 2 deletions core/constraints/captcha.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def is_observed(self, *args, **kwargs) -> bool:
context["request"]
)

turnstile_token = request_context.data.get("cf-turnstile-response")
turnstile_token = request_context.headers.get("cf-turnstile-response")

return request_context.ip is not None and turnstile_token is not None and cloudflare.is_verified(
turnstile_token, request_context.ip
Expand Down Expand Up @@ -60,7 +60,7 @@ def is_observed(self, *args, **kwargs) -> bool:
context["request"]
)

turnstile_token = request_context.data.get("hc-turnstile-response") or request_context.data.get("cf-turnstile-response")
turnstile_token = request_context.headers.get("hc-turnstile-response")

return request_context.ip is not None and turnstile_token is not None and hcaptcha.is_verified(
turnstile_token, request_context.ip
Expand Down
Loading