0
토큰 인증과 함께 django restframework를 사용하고 있습니다. 장고 개발 서버에서 실행할 때 제대로 작동하지만 아파치에서 실행하면 401 인증 오류로 실패합니다. 내가django-restframework with token 인증은 아파치에서 401을 반환합니다.
@permission_classes((IsAuthenticated,))
@staff_member_required
을 제거하면
# settings.py
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.BasicAuthentication',
)
}
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'myapp',
'django.contrib.admin',
'rest_framework',
'rest_framework.authtoken',
)
@api_view(['GET', 'POST'])
@authentication_classes((TokenAuthentication, SessionAuthentication, BasicAuthentication))
@permission_classes((IsAuthenticated,))
@staff_member_required
def api(request):
params = request.data
res = rest_api.get_data(params)
return HttpResponse(json.dumps(res), content_type="application/json")
그것은 아파치에 작동하지만 그것은 불안이다. 아이디어가 무엇이며 어떻게 수정해야합니까? 이 인증은 아파치에 의해 처리 될 것으로 가정으로 mod_wsgi에를 사용하여 아파치에 배포하는 경우, 인증 헤더가 아닌에서, 기본적으로 WSGI 응용 프로그램에 통과되지 않도록
완벽합니다. 나는 httpd.conf에 넣었고 작동 중이다. 하메드 고마워. – max