Skip to content

Commit

Permalink
Merge pull request #200 from ignapas/captcha-fix
Browse files Browse the repository at this point in the history
Captcha validation for /tasks endpoint
  • Loading branch information
egauzens authored Mar 6, 2024
2 parents 258b8b4 + e90a3c2 commit 34c484a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,5 @@ class Config(object):
CTF_CMA_ACCESS_TOKEN = os.environ.get("CTF_CMA_ACCESS_TOKEN")
CTF_SPACE_ID = os.environ.get("CTF_SPACE_ID")
CTF_HOMEPAGE_ID = os.environ.get("CTF_HOMEPAGE_ID", '4qJ9WUWXg09FAUvCnbGxBY')
NUXT_TURNSTILE_SECRET_KEY = os.environ.get("NUXT_TURNSTILE_SECRET_KEY")
TURNSTILE_URL = os.environ.get("TURNSTILE_URL", "https://challenges.cloudflare.com/turnstile/v0/siteverify")
14 changes: 14 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,20 @@ def get_scaffold_state():
@app.route("/tasks", methods=["POST"])
def create_wrike_task():
form = request.form
if "captcha_token" in form:
captchaReq = requests.post(
url=Config.TURNSTILE_URL,
json={
"secret": Config.NUXT_TURNSTILE_SECRET_KEY,
"response": form["captcha_token"]
}
)
captchaResp = captchaReq.json()
if "success" not in captchaResp or not captchaResp["success"]:
abort(409, description="Failed Captcha Validation")
# else:
# abort(409, description="Missing Captcha Token")
# captcha all good
if form and 'title' in form and 'description' in form:
title = form["title"]
description = form["description"]
Expand Down

0 comments on commit 34c484a

Please sign in to comment.