diff --git a/dusken/authentication.py b/dusken/authentication.py index 65226f8..187a3b1 100644 --- a/dusken/authentication.py +++ b/dusken/authentication.py @@ -32,7 +32,10 @@ class OAuth20Authentication(Authentication): if not key: auth_header_value = request.META.get('HTTP_AUTHORIZATION') if auth_header_value: - key = auth_header_value.split(': ')[1].split(" ")[1] + if 'Authorization' in auth_header_value: + key = auth_header_value.split(': ')[1].split(" ")[1] + else: + key = auth_header_value.split(' ')[1] if not key: logging.info('OAuth20Authentication. No consumer_key found.') return None diff --git a/dusken/urls.py b/dusken/urls.py index cdd4183..abf4f1c 100644 --- a/dusken/urls.py +++ b/dusken/urls.py @@ -18,6 +18,5 @@ v1_api.register(InstitutionResource()) urlpatterns = patterns('', url(r'^admin/', include(admin.site.urls)), url(r'^api/', include(v1_api.urls)), - url(r'^authenticate/', 'dusken.views.authenticate'), url(r'oauth2/', include('provider.oauth2.urls', namespace='oauth2')), ) diff --git a/dusken/views.py b/dusken/views.py index 4f5a4e7..e69de29 100644 --- a/dusken/views.py +++ b/dusken/views.py @@ -1,21 +0,0 @@ -import json -from django.contrib.auth.forms import AuthenticationForm -from django.http import HttpResponse -from django.views.decorators.csrf import csrf_exempt - -@csrf_exempt -def authenticate(request): - # TODO is this right? - if request.method == "POST": - form = AuthenticationForm(data=request.POST) - if form.is_valid(): - # get apikey and return it - user = form.get_user() - api_key = user.api_key.key - response = HttpResponse(json.dumps({'api_key': api_key}), content_type='application/javascript; charset=utf8', ) - response['Access-Control-Allow-Origin'] = '*' - return response - else: - return HttpResponse(json.dumps({'error': 'unauthorized'}), content_type='application/javascript; charset=utf8', status=401) - else: - return HttpResponse(json.dumps({'error': 'unauthorized'}), content_type='application/javascript; charset=utf8', status=401)