Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/api/common.py
Show All 11 Lines | |||||
import attr | import attr | ||||
from django.core.files.uploadedfile import UploadedFile | from django.core.files.uploadedfile import UploadedFile | ||||
from django.http import FileResponse, HttpResponse | from django.http import FileResponse, HttpResponse | ||||
from django.shortcuts import render | from django.shortcuts import render | ||||
from django.urls import reverse | from django.urls import reverse | ||||
from django.utils import timezone | from django.utils import timezone | ||||
from rest_framework import status | from rest_framework import status | ||||
from rest_framework.authentication import BaseAuthentication, BasicAuthentication | from rest_framework.authentication import BaseAuthentication | ||||
from rest_framework.permissions import BasePermission, IsAuthenticated | from rest_framework.permissions import BasePermission, IsAuthenticated | ||||
from rest_framework.request import Request | from rest_framework.request import Request | ||||
from rest_framework.views import APIView | from rest_framework.views import APIView | ||||
from swh.deposit.api.checks import check_metadata | from swh.deposit.api.checks import check_metadata | ||||
from swh.deposit.api.converters import convert_status_detail | from swh.deposit.api.converters import convert_status_detail | ||||
from swh.deposit.auth import KeycloakBasicAuthentication | |||||
from swh.deposit.models import Deposit | from swh.deposit.models import Deposit | ||||
from swh.deposit.utils import compute_metadata_context | from swh.deposit.utils import compute_metadata_context | ||||
from swh.model import hashutil | from swh.model import hashutil | ||||
from swh.model.identifiers import ExtendedSWHID, QualifiedSWHID, ValidationError | from swh.model.identifiers import ExtendedSWHID, QualifiedSWHID, ValidationError | ||||
from swh.model.model import ( | from swh.model.model import ( | ||||
MetadataAuthority, | MetadataAuthority, | ||||
MetadataAuthorityType, | MetadataAuthorityType, | ||||
MetadataFetcher, | MetadataFetcher, | ||||
▲ Show 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | |||||
class AuthenticatedAPIView(APIView): | class AuthenticatedAPIView(APIView): | ||||
"""Mixin intended as a based API view to enforce the basic | """Mixin intended as a based API view to enforce the basic | ||||
authentication check | authentication check | ||||
""" | """ | ||||
authentication_classes: Sequence[Type[BaseAuthentication]] = (BasicAuthentication,) | authentication_classes: Sequence[Type[BaseAuthentication]] = ( | ||||
KeycloakBasicAuthentication, | |||||
) | |||||
permission_classes: Sequence[Type[BasePermission]] = (IsAuthenticated,) | permission_classes: Sequence[Type[BasePermission]] = (IsAuthenticated,) | ||||
class APIBase(APIConfig, AuthenticatedAPIView, metaclass=ABCMeta): | class APIBase(APIConfig, AuthenticatedAPIView, metaclass=ABCMeta): | ||||
"""Base deposit request class sharing multiple common behaviors. | """Base deposit request class sharing multiple common behaviors. | ||||
""" | """ | ||||
▲ Show 20 Lines • Show All 1,023 Lines • Show Last 20 Lines |