Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/api/common.py
# Copyright (C) 2017-2019 The Software Heritage developers | # Copyright (C) 2017-2019 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import hashlib | import hashlib | ||||
from typing import Any, Tuple | |||||
from abc import ABCMeta, abstractmethod | from abc import ABCMeta, abstractmethod | ||||
from django.urls import reverse | from django.urls import reverse | ||||
from django.http import HttpResponse | from django.http import HttpResponse | ||||
from django.shortcuts import render | from django.shortcuts import render | ||||
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 BasicAuthentication | from rest_framework.authentication import BasicAuthentication | ||||
from rest_framework.permissions import IsAuthenticated, AllowAny | from rest_framework.permissions import IsAuthenticated, AllowAny | ||||
Show All 25 Lines | |||||
ACCEPT_ARCHIVE_CONTENT_TYPES = ['application/zip', 'application/x-tar'] | ACCEPT_ARCHIVE_CONTENT_TYPES = ['application/zip', 'application/x-tar'] | ||||
class SWHAPIView(APIView): | class SWHAPIView(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 = (BasicAuthentication, ) | authentication_classes = (BasicAuthentication, ) # type: Tuple[Any, ...] | ||||
permission_classes = (IsAuthenticated, ) | permission_classes = (IsAuthenticated, ) | ||||
class SWHPrivateAPIView(SWHAPIView): | class SWHPrivateAPIView(SWHAPIView): | ||||
"""Mixin intended as private api (so no authentication) based API view | """Mixin intended as private api (so no authentication) based API view | ||||
(for the private ones). | (for the private ones). | ||||
""" | """ | ||||
▲ Show 20 Lines • Show All 836 Lines • Show Last 20 Lines |