Skip to content

Commit 3b90bf8

Browse files
committed
Add AllowAny to endpoints that should be available without Auth
1 parent f64ef8f commit 3b90bf8

File tree

17 files changed

+44
-11
lines changed

17 files changed

+44
-11
lines changed

django/thunderstore/frontend/api/experimental/views/community_package_list.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from rest_framework import status
88
from rest_framework.exceptions import ParseError
99
from rest_framework.generics import get_object_or_404
10+
from rest_framework.permissions import AllowAny
1011
from rest_framework.response import Response
1112
from rest_framework.views import APIView
1213

@@ -27,7 +28,7 @@ class CommunityPackageListApiView(APIView):
2728
Return paginated list of community's packages.
2829
"""
2930

30-
permission_classes = []
31+
permission_classes = [AllowAny]
3132

3233
@swagger_auto_schema(
3334
responses={200: CommunityPackageListSerializer()},

django/thunderstore/frontend/api/experimental/views/frontpage.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from django.db.models import QuerySet
22
from django.http import HttpRequest, HttpResponse
33
from drf_yasg.utils import swagger_auto_schema
4+
from rest_framework.permissions import AllowAny
45
from rest_framework.response import Response
56
from rest_framework.views import APIView
67

@@ -15,7 +16,7 @@ class FrontPageApiView(APIView):
1516
Return information required to render the site's front page.
1617
"""
1718

18-
permission_classes = []
19+
permission_classes = [AllowAny]
1920

2021
@swagger_auto_schema(
2122
responses={200: FrontPageContentSerializer()},

django/thunderstore/frontend/api/experimental/views/markdown.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from drf_yasg.utils import swagger_auto_schema
22
from rest_framework import status
3+
from rest_framework.permissions import AllowAny
34
from rest_framework.response import Response
45
from rest_framework.views import APIView
56

@@ -12,7 +13,7 @@
1213

1314
class RenderMarkdownApiView(APIView):
1415
serializer_class = RenderMarkdownResponseSerializer
15-
permission_classes = []
16+
permission_classes = [AllowAny]
1617

1718
@swagger_auto_schema(
1819
request_body=RenderMarkdownParamsSerializer,

django/thunderstore/frontend/api/experimental/views/package_details.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from drf_yasg.utils import swagger_auto_schema
44
from rest_framework import status
55
from rest_framework.generics import get_object_or_404
6+
from rest_framework.permissions import AllowAny
67
from rest_framework.response import Response
78
from rest_framework.views import APIView
89

@@ -21,7 +22,7 @@ class PackageDetailApiView(APIView):
2122
Return details about a single Package.
2223
"""
2324

24-
permission_classes = []
25+
permission_classes = [AllowAny]
2526

2627
@swagger_auto_schema(
2728
responses={200: PackageDetailViewContentSerializer()},

django/thunderstore/modpacks/api/experimental/views/legacyprofile.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from rest_framework import serializers, status
66
from rest_framework.exceptions import NotFound, ValidationError
77
from rest_framework.parsers import FileUploadParser
8+
from rest_framework.permissions import AllowAny
89
from rest_framework.response import Response
910
from rest_framework.throttling import UserRateThrottle
1011
from rest_framework.views import APIView
@@ -30,7 +31,7 @@ def get_rate(self) -> str:
3031

3132

3233
class LegacyProfileCreateApiView(APIView):
33-
permission_classes = []
34+
permission_classes = [AllowAny]
3435
parser_classes = [LegacyProfileFileUploadParser]
3536
throttle_classes = [LegacyProfileCreateThrottle]
3637

@@ -54,7 +55,7 @@ def post(self, request, *args, **kwargs):
5455

5556

5657
class LegacyProfileRetrieveApiView(APIView):
57-
permission_classes = []
58+
permission_classes = [AllowAny]
5859

5960
@swagger_auto_schema(
6061
responses={200: Schema(title="content", type=TYPE_FILE)},

django/thunderstore/repository/api/experimental/views/package.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from rest_framework.exceptions import ValidationError
44
from rest_framework.generics import ListAPIView, RetrieveAPIView, get_object_or_404
55
from rest_framework.pagination import CursorPagination
6+
from rest_framework.permissions import AllowAny
67

78
from thunderstore.cache.cache import ManualCacheCommunityMixin
89
from thunderstore.cache.enums import CacheBustCondition
@@ -49,6 +50,7 @@ class PackageListApiView(ManualCacheCommunityMixin, ListAPIView):
4950
Lists all available packages
5051
"""
5152

53+
permission_classes = [AllowAny]
5254
cache_until = CacheBustCondition.any_package_updated
5355
serializer_class = PackageSerializerExperimental
5456
pagination_class = CustomCursorPagination
@@ -69,6 +71,7 @@ class PackageDetailApiView(ManualCacheCommunityMixin, RetrieveAPIView):
6971
Get a single package
7072
"""
7173

74+
permission_classes = [AllowAny]
7275
cache_until = CacheBustCondition.any_package_updated
7376
serializer_class = PackageSerializerExperimental
7477

django/thunderstore/repository/api/experimental/views/package_index.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from drf_yasg.utils import swagger_auto_schema
88
from rest_framework import serializers
99
from rest_framework.exceptions import APIException
10+
from rest_framework.permissions import AllowAny
1011
from rest_framework.renderers import JSONRenderer
1112
from rest_framework.views import APIView
1213
from sentry_sdk import capture_exception
@@ -81,6 +82,8 @@ class PackageIndexApiView(APIView):
8182
newline delimited JSON.
8283
"""
8384

85+
permission_classes = [AllowAny]
86+
8487
@swagger_auto_schema(
8588
tags=["experimental"],
8689
responses={200: PackageIndexEntry(many=True)},

django/thunderstore/repository/api/experimental/views/package_version.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from drf_yasg.utils import swagger_auto_schema
22
from rest_framework.exceptions import ValidationError
33
from rest_framework.generics import RetrieveAPIView, get_object_or_404
4+
from rest_framework.permissions import AllowAny
45
from rest_framework.response import Response
56

67
from thunderstore.cache.cache import ManualCacheCommunityMixin
@@ -59,6 +60,7 @@ class PackageVersionDetailApiView(PackageVersionDetailMixin):
5960
Get a single package version
6061
"""
6162

63+
permission_classes = [AllowAny]
6264
serializer_class = PackageVersionSerializerExperimental
6365

6466
@swagger_auto_schema(
@@ -74,6 +76,7 @@ class PackageVersionChangelogApiView(PackageVersionDetailMixin):
7476
Get a package verion's changelog
7577
"""
7678

79+
permission_classes = [AllowAny]
7780
serializer_class = MarkdownResponseSerializer
7881

7982
@swagger_auto_schema(
@@ -94,6 +97,7 @@ class PackageVersionReadmeApiView(PackageVersionDetailMixin):
9497
Get a package verion's readme
9598
"""
9699

100+
permission_classes = [AllowAny]
97101
serializer_class = MarkdownResponseSerializer
98102

99103
@swagger_auto_schema(

django/thunderstore/repository/api/experimental/views/wiki.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from rest_framework import serializers
1010
from rest_framework.exceptions import PermissionDenied
1111
from rest_framework.generics import GenericAPIView, RetrieveAPIView, get_object_or_404
12+
from rest_framework.permissions import AllowAny
1213
from rest_framework.response import Response
1314

1415
from thunderstore.repository.models import Package, PackageWiki
@@ -23,6 +24,7 @@
2324

2425

2526
class PackageWikiApiView(RetrieveAPIView):
27+
permission_classes = [AllowAny]
2628
queryset = Wiki.objects.all().prefetch_related("pages")
2729
serializer_class = WikiSerializer
2830

@@ -136,6 +138,7 @@ class PackageWikiListResponse(serializers.Serializer):
136138

137139

138140
class PackageWikiListAPIView(GenericAPIView):
141+
permission_classes = [AllowAny]
139142
queryset = (
140143
PackageWiki.objects.all()
141144
.annotate(namespace=F("package__owner__name"), name=F("package__name"))

django/thunderstore/repository/api/v1/views/deprecate.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from drf_yasg.utils import swagger_auto_schema
44
from rest_framework.exceptions import NotFound, PermissionDenied
5+
from rest_framework.permissions import AllowAny
56
from rest_framework.response import Response
67

78
from thunderstore.core.jwt_helpers import JWTApiView
@@ -18,6 +19,8 @@ class DeprecateModApiView(JWTApiView):
1819
* Only users with special permissions may use this action
1920
"""
2021

22+
permission_classes = [AllowAny]
23+
2124
def get_package(self, package_name):
2225
if package_name is None:
2326
raise NotFound()

django/thunderstore/repository/api/v1/viewsets.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from rest_framework.authentication import BasicAuthentication, SessionAuthentication
1111
from rest_framework.decorators import action
1212
from rest_framework.generics import get_object_or_404
13-
from rest_framework.permissions import IsAuthenticated
13+
from rest_framework.permissions import AllowAny, IsAuthenticated
1414
from rest_framework.renderers import JSONRenderer
1515
from rest_framework.response import Response
1616

@@ -74,6 +74,7 @@ class PackageViewSet(
7474
CommunityMixin,
7575
viewsets.ReadOnlyModelViewSet,
7676
):
77+
permission_classes = [AllowAny]
7778
cache_database_fallback = False
7879
serializer_class = PACKAGE_SERIALIZER
7980
lookup_field = "package__uuid4"

django/thunderstore/schema_server/api/experimental/views/channel.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from rest_framework.exceptions import NotFound, PermissionDenied, ValidationError
1010
from rest_framework.generics import get_object_or_404
1111
from rest_framework.parsers import FileUploadParser
12+
from rest_framework.permissions import AllowAny
1213
from rest_framework.response import Response
1314
from rest_framework.views import APIView
1415

@@ -28,7 +29,7 @@ def get_filename(self, stream, media_type, parser_context):
2829

2930

3031
class SchemaChannelApiView(APIView):
31-
permission_classes = []
32+
permission_classes = [AllowAny]
3233
parser_classes = [SchemaFileUploadParser]
3334
throttle_classes = []
3435

@@ -65,7 +66,7 @@ def post(self, request, channel: str, *args, **kwargs):
6566

6667

6768
class SchemaChannelLatestApiView(APIView):
68-
permission_classes = []
69+
permission_classes = [AllowAny]
6970

7071
@swagger_auto_schema(
7172
responses={200: Schema(title="content", type=TYPE_FILE)},

django/thunderstore/social/api/experimental/views/current_user.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from drf_yasg.utils import swagger_auto_schema
77
from pydantic import BaseModel
88
from rest_framework import serializers
9+
from rest_framework.permissions import AllowAny
910
from rest_framework.response import Response
1011
from rest_framework.views import APIView
1112

@@ -20,6 +21,8 @@ class CurrentUserExperimentalApiView(APIView):
2021
Gets information about the current user, such as rated packages and permissions
2122
"""
2223

24+
permission_classes = [AllowAny]
25+
2326
@swagger_auto_schema(tags=["experimental"])
2427
def get(self, request, format=None):
2528
if request.user.is_authenticated:

django/thunderstore/social/api/experimental/views/overwolf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from pydantic import BaseModel
1010
from rest_framework import serializers
1111
from rest_framework.exceptions import AuthenticationFailed
12-
from rest_framework.permissions import BasePermission
12+
from rest_framework.permissions import AllowAny, BasePermission
1313
from rest_framework.request import Request
1414
from rest_framework.response import Response
1515
from rest_framework.views import APIView
@@ -54,7 +54,7 @@ class OverwolfLoginApiView(APIView):
5454
login process triggered from a browser.
5555
"""
5656

57-
permission_classes: Sequence[Type[BasePermission]] = []
57+
permission_classes: Sequence[Type[BasePermission]] = [AllowAny]
5858

5959
@swagger_auto_schema(
6060
operation_id="experimental.auth.overwolf.login",

django/thunderstore/social/api/experimental/views/validate_session.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from django.http import HttpResponse
22
from drf_yasg.utils import swagger_auto_schema # type: ignore
3+
from rest_framework.permissions import AllowAny
34
from rest_framework.request import Request
45
from rest_framework.response import Response
56
from rest_framework.status import HTTP_401_UNAUTHORIZED
@@ -11,6 +12,8 @@ class ValidateSessionApiView(APIView):
1112
Check that valid session key is provided in Authorization header.
1213
"""
1314

15+
permission_classes = [AllowAny]
16+
1417
@swagger_auto_schema(
1518
operation_id="experimental.auth.validate",
1619
responses={

django/thunderstore/social/api/v1/views/current_user.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from drf_yasg.utils import swagger_auto_schema
22
from rest_framework.authentication import BasicAuthentication, SessionAuthentication
3+
from rest_framework.permissions import AllowAny
34
from rest_framework.response import Response
45
from rest_framework.views import APIView
56

@@ -10,6 +11,7 @@ class CurrentUserInfoView(APIView):
1011
"""
1112

1213
authentication_classes = [SessionAuthentication, BasicAuthentication]
14+
permission_classes = [AllowAny]
1315

1416
@swagger_auto_schema(tags=["v1"])
1517
def get(self, request, format=None, community_identifier=None):

django/thunderstore/wiki/api/experimental/views.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
from drf_yasg.utils import swagger_auto_schema
22
from rest_framework.generics import RetrieveAPIView
3+
from rest_framework.permissions import AllowAny
34

45
from thunderstore.wiki.api.experimental.serializers import WikiPageSerializer
56
from thunderstore.wiki.models import WikiPage
67

78

89
class WikiPageApiView(RetrieveAPIView):
10+
permission_classes = [AllowAny]
911
queryset = WikiPage.objects.all()
1012
serializer_class = WikiPageSerializer
1113

0 commit comments

Comments
 (0)