core: fix url validator (#4957)

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens L 2023-03-15 12:00:57 +01:00 committed by GitHub
parent 5375637eda
commit 86f9056d3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -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):

View File

@ -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