From 1bef659b1042ab50ee2e3a550df7a82d7c760a32 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 26 Feb 2021 10:13:58 +0100 Subject: [PATCH] stages/captcha: remove dependency on captcha app --- authentik/stages/captcha/api.py | 1 + authentik/stages/captcha/settings.py | 9 --------- authentik/stages/captcha/tests.py | 8 +++++--- 3 files changed, 6 insertions(+), 12 deletions(-) delete mode 100644 authentik/stages/captcha/settings.py diff --git a/authentik/stages/captcha/api.py b/authentik/stages/captcha/api.py index 6cd61185f..fb425e42f 100644 --- a/authentik/stages/captcha/api.py +++ b/authentik/stages/captcha/api.py @@ -12,6 +12,7 @@ class CaptchaStageSerializer(StageSerializer): model = CaptchaStage fields = StageSerializer.Meta.fields + ["public_key", "private_key"] + extra_kwargs = {"private_key": {"write_only": True}} class CaptchaStageViewSet(ModelViewSet): diff --git a/authentik/stages/captcha/settings.py b/authentik/stages/captcha/settings.py deleted file mode 100644 index 6b63a51db..000000000 --- a/authentik/stages/captcha/settings.py +++ /dev/null @@ -1,9 +0,0 @@ -"""authentik captcha stage settings""" -# https://developers.google.com/recaptcha/docs/faq#id-like-to-run-automated-tests-with-recaptcha.-what-should-i-do -RECAPTCHA_PUBLIC_KEY = "6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI" -RECAPTCHA_PRIVATE_KEY = "6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe" - -NOCAPTCHA = True -INSTALLED_APPS = ["captcha"] - -SILENCED_SYSTEM_CHECKS = ["captcha.recaptcha_test_key_error"] diff --git a/authentik/stages/captcha/tests.py b/authentik/stages/captcha/tests.py index 66b84bea7..f08faeaea 100644 --- a/authentik/stages/captcha/tests.py +++ b/authentik/stages/captcha/tests.py @@ -1,5 +1,4 @@ """captcha tests""" -from django.conf import settings from django.test import Client, TestCase from django.urls import reverse from django.utils.encoding import force_str @@ -11,6 +10,9 @@ from authentik.flows.planner import FlowPlan from authentik.flows.views import SESSION_KEY_PLAN from authentik.stages.captcha.models import CaptchaStage +# https://developers.google.com/recaptcha/docs/faq#id-like-to-run-automated-tests-with-recaptcha.-what-should-i-do +RECAPTCHA_PUBLIC_KEY = "6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI" +RECAPTCHA_PRIVATE_KEY = "6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe" class TestCaptchaStage(TestCase): """Captcha tests""" @@ -29,8 +31,8 @@ class TestCaptchaStage(TestCase): ) self.stage = CaptchaStage.objects.create( name="captcha", - public_key=settings.RECAPTCHA_PUBLIC_KEY, - private_key=settings.RECAPTCHA_PRIVATE_KEY, + public_key=RECAPTCHA_PUBLIC_KEY, + private_key=RECAPTCHA_PRIVATE_KEY, ) FlowStageBinding.objects.create(target=self.flow, stage=self.stage, order=2)