Browse Source

authorization debug

master
Mohsen Taba 5 months ago
parent
commit
16434186dd
  1. 27
      apps/hadis/views/category.py
  2. 4
      config/settings/base.py

27
apps/hadis/views/category.py

@ -300,14 +300,25 @@ class CategoriesBySectView(ListAPIView):
def get(self, request, *args, **kwargs):
return self.list(request, *args, **kwargs)
from rest_framework.decorators import api_view
from rest_framework.decorators import api_view, permission_classes, authentication_classes
from rest_framework.permissions import AllowAny
from rest_framework.response import Response
from rest_framework import status
@api_view(['GET'])
@api_view(['GET', 'POST'])
@permission_classes([AllowAny]) # Let anyone access this
@authentication_classes([]) # Disable auth so we don't get 403
def test_deploy(request):
"""
List all transformers, or create a new transformer
"""
if request.method == 'GET':
return Response('test_deploy')
# This filters all headers Django receives and returns them as JSON
headers = {
k: v for k, v in request.META.items()
if k.startswith('HTTP_') or k == 'CONTENT_TYPE'
}
# Also check if Authentication settings are actually active
from django.conf import settings
auth_settings = settings.REST_FRAMEWORK.get('DEFAULT_AUTHENTICATION_CLASSES', 'NOT SET')
return Response({
"received_headers": headers,
"active_auth_settings": auth_settings
})

4
config/settings/base.py

@ -231,8 +231,8 @@ AUTH_PASSWORD_VALIDATORS = [
REST_FRAMEWORK = {
# 'DEFAULT_PAGINATION_CLASS': 'utils.pagination.StandardResultsSetPagination',
# 'PAGE_SIZE': 16,
'DEFAULT_PAGINATION_CLASS': 'utils.pagination.StandardResultsSetPagination',
'PAGE_SIZE': 16,
# 'DEFAULT_AUTHENTICATION_CLASSES': [
# 'apps.account.auth_back.TokenAuthentication2',
# ],

Loading…
Cancel
Save