Skip to content

Commit

Permalink
- Api permissions classes: align to rest_api_v2_proof_of_concept branch
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani committed Oct 9, 2020
1 parent e096e87 commit 698e6b2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions mapstore2_adapter/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

from rest_framework import viewsets
from rest_framework.authentication import SessionAuthentication, BasicAuthentication
from rest_framework.permissions import IsAdminUser, IsAuthenticated
from rest_framework.permissions import IsAdminUser, IsAuthenticated, IsAuthenticatedOrReadOnly # noqa
from oauth2_provider.contrib.rest_framework import OAuth2Authentication
from geonode.base.api.permissions import IsOwnerOrReadOnly

from .models import MapStoreResource
from .serializers import (UserSerializer,
Expand All @@ -29,7 +31,7 @@ class UserViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows users to be viewed or edited.
"""
authentication_classes = (SessionAuthentication, BasicAuthentication)
authentication_classes = (SessionAuthentication, BasicAuthentication, OAuth2Authentication)
permission_classes = (IsAdminUser,)
queryset = get_user_model().objects.all()
serializer_class = UserSerializer
Expand All @@ -38,8 +40,8 @@ class UserViewSet(viewsets.ModelViewSet):
class MapStoreResourceViewSet(viewsets.ModelViewSet):
""" Only Authenticate User perform CRUD Operations on Respective Data
"""
authentication_classes = (SessionAuthentication, BasicAuthentication)
permission_classes = (IsAuthenticated,)
authentication_classes = [SessionAuthentication, BasicAuthentication, OAuth2Authentication]
permission_classes = [IsAuthenticatedOrReadOnly, IsOwnerOrReadOnly]
model = MapStoreResource
serializer_class = MapStoreResourceSerializer

Expand Down

0 comments on commit 698e6b2

Please sign in to comment.