switch to text field, add debug mode

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens Langhammer 2023-12-15 20:12:17 +01:00
parent edccf3331a
commit 41387e413f
No known key found for this signature in database
5 changed files with 8 additions and 13 deletions

View File

@ -45,7 +45,7 @@ class Migration(migrations.Migration):
default="number_matching_3",
),
),
("cgw_endpoint", models.URLField()),
("cgw_endpoint", models.TextField()),
(
"configure_flow",
models.ForeignKey(

View File

@ -50,7 +50,7 @@ class AuthenticatorMobileStage(ConfigurableStage, FriendlyNamedStage, Stage):
item_matching_mode = models.TextField(
choices=ItemMatchingMode.choices, default=ItemMatchingMode.NUMBER_MATCHING_3
)
cgw_endpoint = models.URLField()
cgw_endpoint = models.TextField()
def create_transaction(self, device: "MobileDevice") -> "MobileTransaction":
"""Create a transaction for `device` with the config of this stage."""

View File

@ -1,7 +1,7 @@
"""Mobile stage"""
from django.http import HttpResponse
from rest_framework.fields import CharField
from django.conf import settings
from authentik.core.api.utils import PassiveSerializer
from authentik.flows.challenge import (
Challenge,
@ -65,10 +65,13 @@ class AuthenticatorMobileStageView(ChallengeStageView):
def get_challenge(self, *args, **kwargs) -> Challenge:
self.prepare()
endpoint = f"https://{self.executor.current_stage.cgw_endpoint}/"
if settings.DEBUG:
endpoint = endpoint.replace(":3415", ":3416")
endpoint = endpoint.replace("https", "http")
payload = AuthenticatorMobilePayloadChallenge(
data={
# TODO: use cloud gateway?
"u": self.request.build_absolute_uri("/"),
"u": endpoint,
"s": str(self.executor.plan.context[FLOW_PLAN_MOBILE_ENROLL_DEVICE].pk),
"t": self.executor.plan.context[FLOW_PLAN_MOBILE_ENROLL_TOKEN].token,
}

View File

@ -6155,8 +6155,6 @@
},
"cgw_endpoint": {
"type": "string",
"format": "uri",
"maxLength": 200,
"minLength": 1,
"title": "Cgw endpoint"
}

View File

@ -30429,8 +30429,6 @@ components:
$ref: '#/components/schemas/ItemMatchingModeEnum'
cgw_endpoint:
type: string
format: uri
maxLength: 200
required:
- cgw_endpoint
- component
@ -30464,9 +30462,7 @@ components:
$ref: '#/components/schemas/ItemMatchingModeEnum'
cgw_endpoint:
type: string
format: uri
minLength: 1
maxLength: 200
required:
- cgw_endpoint
- name
@ -38236,9 +38232,7 @@ components:
$ref: '#/components/schemas/ItemMatchingModeEnum'
cgw_endpoint:
type: string
format: uri
minLength: 1
maxLength: 200
PatchedAuthenticatorSMSStageRequest:
type: object
description: AuthenticatorSMSStage Serializer