We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Launch URL in Application UI Settings can't be entered for some domains
**Describe the bug**
When I try to add a fixed link to an application, it will return an error with null text.
I think this is happening only for any subdomain that has a dash character on the subdomain portion of the name:
ej: https://tbb-assets.domain.com

**Screenshots**
This one gets saved without any problems:
https://application.com
![image](https://user-images.githubusercontent.com/75147745/225165939-0cc8c789-65e8-4fad-bec5-c0434ceecb6d.png)

But if i edit this domain to something else like:
https://tbb-assets.easyfoodsin.com
![image](https://user-images.githubusercontent.com/75147745/225165898-f2946215-3846-4f23-be88-8b4d84c067e2.png)

**Logs**
Output of docker-compose logs or kubectl logs respectively.
I can't find anything on the logs it seems that nothing is submitted is a validation error within the application edit screen.

**Version and Deployment (please complete the following information):**
 - authentik version: 2023.3.0
 - Deployment: docker-compose

**Additional context**
This error is not happening on version (2023.2.2) because I created a few applications recently that have many urls that have a dash on the subdomain.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `authentik/lib/models.py`
Content:
```
1 """Generic models"""
2 import re
3 
4 from django.core.validators import URLValidator
5 from django.db import models
6 from django.utils.regex_helper import _lazy_re_compile
7 from model_utils.managers import InheritanceManager
8 from rest_framework.serializers import BaseSerializer
9 
10 
11 class SerializerModel(models.Model):
12     """Base Abstract Model which has a serializer"""
13 
14     @property
15     def serializer(self) -> type[BaseSerializer]:
16         """Get serializer for this model"""
17         raise NotImplementedError
18 
19     class Meta:
20         abstract = True
21 
22 
23 class CreatedUpdatedModel(models.Model):
24     """Base Abstract Model to save created and update"""
25 
26     created = models.DateTimeField(auto_now_add=True)
27     last_updated = models.DateTimeField(auto_now=True)
28 
29     class Meta:
30         abstract = True
31 
32 
33 class InheritanceAutoManager(InheritanceManager):
34     """Object manager which automatically selects the subclass"""
35 
36     def get_queryset(self):
37         return super().get_queryset().select_subclasses()
38 
39 
40 class InheritanceForwardManyToOneDescriptor(models.fields.related.ForwardManyToOneDescriptor):
41     """Forward ManyToOne Descriptor that selects subclass. Requires InheritanceAutoManager."""
42 
43     def get_queryset(self, **hints):
44         return self.field.remote_field.model.objects.db_manager(hints=hints).select_subclasses()
45 
46 
47 class InheritanceForeignKey(models.ForeignKey):
48     """Custom ForeignKey that uses InheritanceForwardManyToOneDescriptor"""
49 
50     forward_related_accessor_class = InheritanceForwardManyToOneDescriptor
51 
52 
53 class DomainlessURLValidator(URLValidator):
54     """Subclass of URLValidator which doesn't check the domain
55     (to allow hostnames without domain)"""
56 
57     def __init__(self, *args, **kwargs) -> None:
58         super().__init__(*args, **kwargs)
59         self.host_re = "(" + self.hostname_re + self.domain_re + "|localhost)"
60         self.regex = _lazy_re_compile(
61             r"^(?:[a-z0-9.+-]*)://"  # scheme is validated separately
62             r"(?:[^\s:@/]+(?::[^\s:@/]*)?@)?"  # user:pass authentication
63             r"(?:" + self.ipv4_re + "|" + self.ipv6_re + "|" + self.host_re + ")"
64             r"(?::\d{2,5})?"  # port
65             r"(?:[/?#][^\s]*)?"  # resource path
66             r"\Z",
67             re.IGNORECASE,
68         )
69         self.schemes = ["http", "https", "blank"] + list(self.schemes)
70 
71     def __call__(self, value: str):
72         # Check if the scheme is valid.
73         scheme = value.split("://")[0].lower()
74         if scheme not in self.schemes:
75             value = "default" + value
76         super().__call__(value)
77 
78 
79 class DomainlessFormattedURLValidator(DomainlessURLValidator):
80     """URL validator which allows for python format strings"""
81 
82     def __init__(self, *args, **kwargs) -> None:
83         super().__init__(*args, **kwargs)
84         self.host_re = r"([%\(\)a-zA-Z])+" + self.domain_re + self.domain_re
85         self.regex = _lazy_re_compile(
86             r"^(?:[a-z0-9.+-]*)://"  # scheme is validated separately
87             r"(?:[^\s:@/]+(?::[^\s:@/]*)?@)?"  # user:pass authentication
88             r"(?:" + self.ipv4_re + "|" + self.ipv6_re + "|" + self.host_re + ")"
89             r"(?::\d{2,5})?"  # port
90             r"(?:[/?#][^\s]*)?"  # resource path
91             r"\Z",
92             re.IGNORECASE,
93         )
94         self.schemes = ["http", "https", "blank"] + list(self.schemes)
95
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/authentik/lib/models.py b/authentik/lib/models.py
--- a/authentik/lib/models.py
+++ b/authentik/lib/models.py
@@ -81,7 +81,8 @@
 
     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

{"golden_diff": "diff --git a/authentik/lib/models.py b/authentik/lib/models.py\n--- a/authentik/lib/models.py\n+++ b/authentik/lib/models.py\n@@ -81,7 +81,8 @@\n \n     def __init__(self, *args, **kwargs) -> None:\n         super().__init__(*args, **kwargs)\n-        self.host_re = r\"([%\\(\\)a-zA-Z])+\" + self.domain_re + self.domain_re\n+        self.formatter_re = r\"([%\\(\\)a-zA-Z])*\"\n+        self.host_re = \"(\" + self.formatter_re + self.hostname_re + self.domain_re + \"|localhost)\"\n         self.regex = _lazy_re_compile(\n             r\"^(?:[a-z0-9.+-]*)://\"  # scheme is validated separately\n             r\"(?:[^\\s:@/]+(?::[^\\s:@/]*)?@)?\"  # user:pass authentication\n", "issue": "Launch URL in Application UI Settings can't be entered for some domains\n**Describe the bug**\r\nWhen I try to add a fixed link to an application, it will return an error with null text.\r\nI think this is happening only for any subdomain that has a dash character on the subdomain portion of the name:\r\nej: https://tbb-assets.domain.com\r\n\r\n**Screenshots**\r\nThis one gets saved without any problems:\r\nhttps://application.com\r\n![image](https://user-images.githubusercontent.com/75147745/225165939-0cc8c789-65e8-4fad-bec5-c0434ceecb6d.png)\r\n\r\nBut if i edit this domain to something else like:\r\nhttps://tbb-assets.easyfoodsin.com\r\n![image](https://user-images.githubusercontent.com/75147745/225165898-f2946215-3846-4f23-be88-8b4d84c067e2.png)\r\n\r\n**Logs**\r\nOutput of docker-compose logs or kubectl logs respectively.\r\nI can't find anything on the logs it seems that nothing is submitted is a validation error within the application edit screen.\r\n\r\n**Version and Deployment (please complete the following information):**\r\n - authentik version: 2023.3.0\r\n - Deployment: docker-compose\r\n\r\n**Additional context**\r\nThis error is not happening on version (2023.2.2) because I created a few applications recently that have many urls that have a dash on the subdomain.\n", "before_files": [{"content": "\"\"\"Generic models\"\"\"\nimport re\n\nfrom django.core.validators import URLValidator\nfrom django.db import models\nfrom django.utils.regex_helper import _lazy_re_compile\nfrom model_utils.managers import InheritanceManager\nfrom rest_framework.serializers import BaseSerializer\n\n\nclass SerializerModel(models.Model):\n    \"\"\"Base Abstract Model which has a serializer\"\"\"\n\n    @property\n    def serializer(self) -> type[BaseSerializer]:\n        \"\"\"Get serializer for this model\"\"\"\n        raise NotImplementedError\n\n    class Meta:\n        abstract = True\n\n\nclass CreatedUpdatedModel(models.Model):\n    \"\"\"Base Abstract Model to save created and update\"\"\"\n\n    created = models.DateTimeField(auto_now_add=True)\n    last_updated = models.DateTimeField(auto_now=True)\n\n    class Meta:\n        abstract = True\n\n\nclass InheritanceAutoManager(InheritanceManager):\n    \"\"\"Object manager which automatically selects the subclass\"\"\"\n\n    def get_queryset(self):\n        return super().get_queryset().select_subclasses()\n\n\nclass InheritanceForwardManyToOneDescriptor(models.fields.related.ForwardManyToOneDescriptor):\n    \"\"\"Forward ManyToOne Descriptor that selects subclass. Requires InheritanceAutoManager.\"\"\"\n\n    def get_queryset(self, **hints):\n        return self.field.remote_field.model.objects.db_manager(hints=hints).select_subclasses()\n\n\nclass InheritanceForeignKey(models.ForeignKey):\n    \"\"\"Custom ForeignKey that uses InheritanceForwardManyToOneDescriptor\"\"\"\n\n    forward_related_accessor_class = InheritanceForwardManyToOneDescriptor\n\n\nclass DomainlessURLValidator(URLValidator):\n    \"\"\"Subclass of URLValidator which doesn't check the domain\n    (to allow hostnames without domain)\"\"\"\n\n    def __init__(self, *args, **kwargs) -> None:\n        super().__init__(*args, **kwargs)\n        self.host_re = \"(\" + self.hostname_re + self.domain_re + \"|localhost)\"\n        self.regex = _lazy_re_compile(\n            r\"^(?:[a-z0-9.+-]*)://\"  # scheme is validated separately\n            r\"(?:[^\\s:@/]+(?::[^\\s:@/]*)?@)?\"  # user:pass authentication\n            r\"(?:\" + self.ipv4_re + \"|\" + self.ipv6_re + \"|\" + self.host_re + \")\"\n            r\"(?::\\d{2,5})?\"  # port\n            r\"(?:[/?#][^\\s]*)?\"  # resource path\n            r\"\\Z\",\n            re.IGNORECASE,\n        )\n        self.schemes = [\"http\", \"https\", \"blank\"] + list(self.schemes)\n\n    def __call__(self, value: str):\n        # Check if the scheme is valid.\n        scheme = value.split(\"://\")[0].lower()\n        if scheme not in self.schemes:\n            value = \"default\" + value\n        super().__call__(value)\n\n\nclass DomainlessFormattedURLValidator(DomainlessURLValidator):\n    \"\"\"URL validator which allows for python format strings\"\"\"\n\n    def __init__(self, *args, **kwargs) -> None:\n        super().__init__(*args, **kwargs)\n        self.host_re = r\"([%\\(\\)a-zA-Z])+\" + self.domain_re + self.domain_re\n        self.regex = _lazy_re_compile(\n            r\"^(?:[a-z0-9.+-]*)://\"  # scheme is validated separately\n            r\"(?:[^\\s:@/]+(?::[^\\s:@/]*)?@)?\"  # user:pass authentication\n            r\"(?:\" + self.ipv4_re + \"|\" + self.ipv6_re + \"|\" + self.host_re + \")\"\n            r\"(?::\\d{2,5})?\"  # port\n            r\"(?:[/?#][^\\s]*)?\"  # resource path\n            r\"\\Z\",\n            re.IGNORECASE,\n        )\n        self.schemes = [\"http\", \"https\", \"blank\"] + list(self.schemes)\n", "path": "authentik/lib/models.py"}], "after_files": [{"content": "\"\"\"Generic models\"\"\"\nimport re\n\nfrom django.core.validators import URLValidator\nfrom django.db import models\nfrom django.utils.regex_helper import _lazy_re_compile\nfrom model_utils.managers import InheritanceManager\nfrom rest_framework.serializers import BaseSerializer\n\n\nclass SerializerModel(models.Model):\n    \"\"\"Base Abstract Model which has a serializer\"\"\"\n\n    @property\n    def serializer(self) -> type[BaseSerializer]:\n        \"\"\"Get serializer for this model\"\"\"\n        raise NotImplementedError\n\n    class Meta:\n        abstract = True\n\n\nclass CreatedUpdatedModel(models.Model):\n    \"\"\"Base Abstract Model to save created and update\"\"\"\n\n    created = models.DateTimeField(auto_now_add=True)\n    last_updated = models.DateTimeField(auto_now=True)\n\n    class Meta:\n        abstract = True\n\n\nclass InheritanceAutoManager(InheritanceManager):\n    \"\"\"Object manager which automatically selects the subclass\"\"\"\n\n    def get_queryset(self):\n        return super().get_queryset().select_subclasses()\n\n\nclass InheritanceForwardManyToOneDescriptor(models.fields.related.ForwardManyToOneDescriptor):\n    \"\"\"Forward ManyToOne Descriptor that selects subclass. Requires InheritanceAutoManager.\"\"\"\n\n    def get_queryset(self, **hints):\n        return self.field.remote_field.model.objects.db_manager(hints=hints).select_subclasses()\n\n\nclass InheritanceForeignKey(models.ForeignKey):\n    \"\"\"Custom ForeignKey that uses InheritanceForwardManyToOneDescriptor\"\"\"\n\n    forward_related_accessor_class = InheritanceForwardManyToOneDescriptor\n\n\nclass DomainlessURLValidator(URLValidator):\n    \"\"\"Subclass of URLValidator which doesn't check the domain\n    (to allow hostnames without domain)\"\"\"\n\n    def __init__(self, *args, **kwargs) -> None:\n        super().__init__(*args, **kwargs)\n        self.host_re = \"(\" + self.hostname_re + self.domain_re + \"|localhost)\"\n        self.regex = _lazy_re_compile(\n            r\"^(?:[a-z0-9.+-]*)://\"  # scheme is validated separately\n            r\"(?:[^\\s:@/]+(?::[^\\s:@/]*)?@)?\"  # user:pass authentication\n            r\"(?:\" + self.ipv4_re + \"|\" + self.ipv6_re + \"|\" + self.host_re + \")\"\n            r\"(?::\\d{2,5})?\"  # port\n            r\"(?:[/?#][^\\s]*)?\"  # resource path\n            r\"\\Z\",\n            re.IGNORECASE,\n        )\n        self.schemes = [\"http\", \"https\", \"blank\"] + list(self.schemes)\n\n    def __call__(self, value: str):\n        # Check if the scheme is valid.\n        scheme = value.split(\"://\")[0].lower()\n        if scheme not in self.schemes:\n            value = \"default\" + value\n        super().__call__(value)\n\n\nclass DomainlessFormattedURLValidator(DomainlessURLValidator):\n    \"\"\"URL validator which allows for python format strings\"\"\"\n\n    def __init__(self, *args, **kwargs) -> None:\n        super().__init__(*args, **kwargs)\n        self.formatter_re = r\"([%\\(\\)a-zA-Z])*\"\n        self.host_re = \"(\" + self.formatter_re + self.hostname_re + self.domain_re + \"|localhost)\"\n        self.regex = _lazy_re_compile(\n            r\"^(?:[a-z0-9.+-]*)://\"  # scheme is validated separately\n            r\"(?:[^\\s:@/]+(?::[^\\s:@/]*)?@)?\"  # user:pass authentication\n            r\"(?:\" + self.ipv4_re + \"|\" + self.ipv6_re + \"|\" + self.host_re + \")\"\n            r\"(?::\\d{2,5})?\"  # port\n            r\"(?:[/?#][^\\s]*)?\"  # resource path\n            r\"\\Z\",\n            re.IGNORECASE,\n        )\n        self.schemes = [\"http\", \"https\", \"blank\"] + list(self.schemes)\n", "path": "authentik/lib/models.py"}]}