api: add explicit lookup_value_regex, disable include_format_suffixes

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-09-20 13:42:56 +02:00
parent f8dee09107
commit b5c857aff4
9 changed files with 9 additions and 0 deletions

View File

@ -99,6 +99,7 @@ from authentik.stages.user_write.api import UserWriteStageViewSet
from authentik.tenants.api import TenantViewSet from authentik.tenants.api import TenantViewSet
router = routers.DefaultRouter() router = routers.DefaultRouter()
router.include_format_suffixes = False
router.register("admin/system_tasks", TaskViewSet, basename="admin_system_tasks") router.register("admin/system_tasks", TaskViewSet, basename="admin_system_tasks")
router.register("admin/apps", AppsViewSet, basename="apps") router.register("admin/apps", AppsViewSet, basename="apps")

View File

@ -77,6 +77,7 @@ class ApplicationViewSet(UsedByMixin, ModelViewSet):
"meta_publisher", "meta_publisher",
] ]
lookup_field = "slug" lookup_field = "slug"
lookup_value_regex = r"^[-a-zA-Z0-9_]+\Z"
ordering = ["name"] ordering = ["name"]
def _filter_queryset_for_list(self, queryset: QuerySet) -> QuerySet: def _filter_queryset_for_list(self, queryset: QuerySet) -> QuerySet:

View File

@ -62,6 +62,7 @@ class SourceViewSet(
queryset = Source.objects.none() queryset = Source.objects.none()
serializer_class = SourceSerializer serializer_class = SourceSerializer
lookup_field = "slug" lookup_field = "slug"
lookup_value_regex = r"^[-a-zA-Z0-9_]+\Z"
def get_queryset(self): # pragma: no cover def get_queryset(self): # pragma: no cover
return Source.objects.select_subclasses() return Source.objects.select_subclasses()

View File

@ -66,6 +66,7 @@ class TokenViewSerializer(PassiveSerializer):
class TokenViewSet(UsedByMixin, ModelViewSet): class TokenViewSet(UsedByMixin, ModelViewSet):
"""Token Viewset""" """Token Viewset"""
lookup_value_regex = r"^[-a-zA-Z0-9_]+\Z"
lookup_field = "identifier" lookup_field = "identifier"
queryset = Token.objects.all() queryset = Token.objects.all()
serializer_class = TokenSerializer serializer_class = TokenSerializer

View File

@ -108,6 +108,7 @@ class FlowViewSet(UsedByMixin, ModelViewSet):
queryset = Flow.objects.all() queryset = Flow.objects.all()
serializer_class = FlowSerializer serializer_class = FlowSerializer
lookup_field = "slug" lookup_field = "slug"
lookup_value_regex = r"^[-a-zA-Z0-9_]+\Z"
search_fields = ["name", "slug", "designation", "title"] search_fields = ["name", "slug", "designation", "title"]
filterset_fields = ["flow_uuid", "name", "slug", "designation"] filterset_fields = ["flow_uuid", "name", "slug", "designation"]

View File

@ -69,6 +69,7 @@ class LDAPSourceViewSet(UsedByMixin, ModelViewSet):
queryset = LDAPSource.objects.all() queryset = LDAPSource.objects.all()
serializer_class = LDAPSourceSerializer serializer_class = LDAPSourceSerializer
lookup_field = "slug" lookup_field = "slug"
lookup_value_regex = r"^[-a-zA-Z0-9_]+\Z"
filterset_fields = [ filterset_fields = [
"name", "name",
"slug", "slug",

View File

@ -84,6 +84,7 @@ class OAuthSourceViewSet(UsedByMixin, ModelViewSet):
queryset = OAuthSource.objects.all() queryset = OAuthSource.objects.all()
serializer_class = OAuthSourceSerializer serializer_class = OAuthSourceSerializer
lookup_field = "slug" lookup_field = "slug"
lookup_value_regex = r"^[-a-zA-Z0-9_]+\Z"
filterset_fields = [ filterset_fields = [
"name", "name",
"slug", "slug",

View File

@ -49,6 +49,7 @@ class PlexSourceViewSet(UsedByMixin, ModelViewSet):
queryset = PlexSource.objects.all() queryset = PlexSource.objects.all()
serializer_class = PlexSourceSerializer serializer_class = PlexSourceSerializer
lookup_field = "slug" lookup_field = "slug"
lookup_value_regex = r"^[-a-zA-Z0-9_]+\Z"
filterset_fields = [ filterset_fields = [
"name", "name",
"slug", "slug",

View File

@ -40,6 +40,7 @@ class SAMLSourceViewSet(UsedByMixin, ModelViewSet):
queryset = SAMLSource.objects.all() queryset = SAMLSource.objects.all()
serializer_class = SAMLSourceSerializer serializer_class = SAMLSourceSerializer
lookup_field = "slug" lookup_field = "slug"
lookup_value_regex = r"^[-a-zA-Z0-9_]+\Z"
filterset_fields = "__all__" filterset_fields = "__all__"
ordering = ["name"] ordering = ["name"]