jpadilla / django-rest-framework-jwt

JSON Web Token Authentication support for Django REST Framework
http://jpadilla.github.io/django-rest-framework-jwt/
MIT License
3.19k stars 650 forks source link

drf set DEFAULT_THROTTLE_CLASSES, the obtain_jwt_token always get AttributeError 'NoneType' object has no attribute 'is_authenticated' #444

Open rubbish822 opened 6 years ago

rubbish822 commented 6 years ago

REST_FRAMEWORK = { "DEFAULT_RENDERER_CLASSES": ( "rest_framework.renderers.JSONRenderer", ), 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.BasicAuthentication',

'rest_framework.authentication.SessionAuthentication',

    # 'rest_framework.authentication.TokenAuthentication',
    # 'user.authentication.RedisAuthentication',
    'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
),
'DEFAULT_THROTTLE_CLASSES': (
    'rest_framework.throttling.AnonRateThrottle',
    'rest_framework.throttling.UserRateThrottle'
),
'DEFAULT_THROTTLE_RATES': {
    'anon': '2/hour',
    'user': '50/hour'
},
'DEFAULT_PERMISSION_CLASSES': (
   'rest_framework.permissions.IsAuthenticated',

), 'UNICODE_JSON': False,

'EXCEPTION_HANDLER': 'user.exception_handler.custom_exception_handler',

'DEFAULT_PAGINATION_CLASS': 'user.utils.StandardResultsSetPagination',
'PAGE_SIZE': 20,
'DEFAULT_FILTER_BACKENDS': (
    'rest_framework.filters.SearchFilter',
    'django_filters.rest_framework.DjangoFilterBackend',
    'rest_framework.filters.OrderingFilter'
),
'UNAUTHENTICATED_USER': None,
'DATETIME_FORMAT': '%Y-%m-%d %H:%M',

}

from rest_framework_jwt.views import obtain_jwt_token, refresh_jwt_token urlpatterns = [ url(r'^api-token-auth/', obtain_jwt_token), ] AttributeError at /api-token-auth/ 'NoneType' object has no attribute 'is_authenticated'

when i change the source code, add throttle_classes = () , it's work!!! and i don't kown why???? class JSONWebTokenAPIView(APIView): """ Base API View that various JWT interactions inherit from. """ permission_classes = () authentication_classes = ()

add throttle_classes = () , it's work!!!

throttle_classes = ()
rubbish822 commented 6 years ago

djangorestframework 3.6.3
djangorestframework-jwt 1.11.0 this is a bug???