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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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