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)