nrbnlulu / strawberry-django-auth

Authentication system for django using strawberry
https://nrbnlulu.github.io/strawberry-django-auth/
MIT License
63 stars 28 forks source link

reCAPTCHA and friends support #581

Open nrbnlulu opened 1 hour ago

nrbnlulu commented 1 hour ago

Discussed in https://github.com/nrbnlulu/strawberry-django-auth/discussions/580

Originally posted by **pkrakesh** October 1, 2024 How can I implement CloudFlare Turnstile or Google reCaptcha wth the package? These widget returns a token and in the backend we can verify the the token against its api endpoint. This is the way I have implemented the verification: ``` @strawberry_django.input_mutation(handle_django_errors=True) def verify_human(self, info, token: str) -> CloudFlareTurnstileNode: request = info.context['request'] url = "https://challenges.cloudflare.com/turnstile/v0/siteverify" ip = request.headers.get('CF_Connecting-IP') data = { "secret": settings.CLOUDFLARE_SECRET_KEY, "response": token, "ip": ip } response = requests.post(url, data=data) print(response.json()) is_success = response.json()['success'] return CloudFlareTurnstileNode(success=is_success) ``` ``` # types.py @strawberry.type class CloudFlareTurnstileNode: success: bool ``` How do I add the verification to the `register` field provided by the package?
nrbnlulu commented 1 hour ago

Not sure it is currently possible in a proper way. we do have our own captcha implementation here though.

pkrakesh commented 39 minutes ago

I don't know how to implement the built in captcha as the documentation is not provided with much information. Can I get some help?