diff --git a/authentik/core/tests/test_applications_api.py b/authentik/core/tests/test_applications_api.py index 5c485ea68..587e3a3d2 100644 --- a/authentik/core/tests/test_applications_api.py +++ b/authentik/core/tests/test_applications_api.py @@ -43,14 +43,14 @@ class TestApplicationsAPI(APITestCase): self.assertEqual( self.client.patch( reverse("authentik_api:application-detail", kwargs={"slug": self.allowed.slug}), - {"meta_launch_url": "https://%(username)s.test.goauthentik.io/%(username)s"}, + {"meta_launch_url": "https://%(username)s-test.test.goauthentik.io/%(username)s"}, ).status_code, 200, ) self.allowed.refresh_from_db() self.assertEqual( self.allowed.get_launch_url(self.user), - f"https://{self.user.username}.test.goauthentik.io/{self.user.username}", + f"https://{self.user.username}-test.test.goauthentik.io/{self.user.username}", ) def test_set_icon(self): diff --git a/authentik/lib/models.py b/authentik/lib/models.py index 24054d9e2..19029c57f 100644 --- a/authentik/lib/models.py +++ b/authentik/lib/models.py @@ -81,7 +81,8 @@ class DomainlessFormattedURLValidator(DomainlessURLValidator): def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) - self.host_re = r"([%\(\)a-zA-Z])+" + self.domain_re + self.domain_re + self.formatter_re = r"([%\(\)a-zA-Z])*" + self.host_re = "(" + self.formatter_re + self.hostname_re + self.domain_re + "|localhost)" self.regex = _lazy_re_compile( r"^(?:[a-z0-9.+-]*)://" # scheme is validated separately r"(?:[^\s:@/]+(?::[^\s:@/]*)?@)?" # user:pass authentication