I'm using Django 2.0
and Django RESET Framework
to write REST API
for my application.
I have configured following authentication methods
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
'rest_framework.authentication.BasicAuthentication',
'rest_framework.authentication.SessionAuthentication',
),
}
As of now, It allows all authenticated users to access web api
view.
What I want is to allow few users (probably superadmin users) to be able to access API from Session Authentication or from web browser by logging in.
Edit 2: contacts/views.py
class ContactViewSet(viewsets.ModelViewSet):
queryset = Contact.objects.all()
serializer_class = ContactSerializer
permission_classes = (IsAuthenticated,)
def perform_create(self, serializer):
serializer.save(user_id=self.request.user)