*: fix lookup_fields

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-09-20 19:19:36 +02:00
parent 95a2fddfa8
commit d900a2b6a9
9 changed files with 1 additions and 9 deletions

View File

@ -40,7 +40,6 @@ def bearer_auth(raw_header: bytes) -> Optional[User]:
raise AuthenticationFailed("Malformed header") raise AuthenticationFailed("Malformed header")
tokens = Token.filter_not_expired(key=password, intent=TokenIntents.INTENT_API) tokens = Token.filter_not_expired(key=password, intent=TokenIntents.INTENT_API)
if not tokens.exists(): if not tokens.exists():
LOGGER.info("Authenticating via secret_key")
user = token_secret_key(password) user = token_secret_key(password)
if not user: if not user:
raise AuthenticationFailed("Token invalid/expired") raise AuthenticationFailed("Token invalid/expired")
@ -58,6 +57,7 @@ def token_secret_key(value: str) -> Optional[User]:
outposts = Outpost.objects.filter(managed=MANAGED_OUTPOST) outposts = Outpost.objects.filter(managed=MANAGED_OUTPOST)
if not outposts: if not outposts:
return None return None
LOGGER.info("Authenticating via secret_key")
outpost = outposts.first() outpost = outposts.first()
return outpost.user return outpost.user

View File

@ -77,7 +77,6 @@ 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,7 +62,6 @@ 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,7 +66,6 @@ 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,7 +108,6 @@ 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,7 +69,6 @@ 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,7 +84,6 @@ 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,7 +49,6 @@ 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,7 +40,6 @@ 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"]