mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-30 18:09:59 +03:00
Add AUTHORIZATION_HEADER setting
This commit is contained in:
parent
287ff43cdd
commit
eae844d515
|
@ -12,6 +12,7 @@ from rest_framework.compat import CsrfViewMiddleware
|
||||||
from rest_framework.compat import oauth, oauth_provider, oauth_provider_store
|
from rest_framework.compat import oauth, oauth_provider, oauth_provider_store
|
||||||
from rest_framework.compat import oauth2_provider
|
from rest_framework.compat import oauth2_provider
|
||||||
from rest_framework.authtoken.models import Token
|
from rest_framework.authtoken.models import Token
|
||||||
|
from rest_framework.settings import api_settings
|
||||||
|
|
||||||
|
|
||||||
def get_authorization_header(request):
|
def get_authorization_header(request):
|
||||||
|
@ -20,7 +21,7 @@ def get_authorization_header(request):
|
||||||
|
|
||||||
Hide some test client ickyness where the header can be unicode.
|
Hide some test client ickyness where the header can be unicode.
|
||||||
"""
|
"""
|
||||||
auth = request.META.get('HTTP_AUTHORIZATION', b'')
|
auth = request.META.get(api_settings.AUTHORIZATION_HEADER, b'')
|
||||||
if type(auth) == type(''):
|
if type(auth) == type(''):
|
||||||
# Work around django test client oddness
|
# Work around django test client oddness
|
||||||
auth = auth.encode(HTTP_HEADER_ENCODING)
|
auth = auth.encode(HTTP_HEADER_ENCODING)
|
||||||
|
|
|
@ -70,6 +70,7 @@ DEFAULTS = {
|
||||||
# Authentication
|
# Authentication
|
||||||
'UNAUTHENTICATED_USER': 'django.contrib.auth.models.AnonymousUser',
|
'UNAUTHENTICATED_USER': 'django.contrib.auth.models.AnonymousUser',
|
||||||
'UNAUTHENTICATED_TOKEN': None,
|
'UNAUTHENTICATED_TOKEN': None,
|
||||||
|
'AUTHORIZATION_HEADER': 'HTTP_AUTHORIZATION',
|
||||||
|
|
||||||
# Browser enhancements
|
# Browser enhancements
|
||||||
'FORM_METHOD_OVERRIDE': '_method',
|
'FORM_METHOD_OVERRIDE': '_method',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user