Archived
Removes authentication view
This commit is contained in:
1 parent
325ec39570
commit
e9002dc035
3 files changed
+4
-23
No files matched your search
@@ -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
|
||||
|
||||
@@ -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')),
|
||||
)
|
||||
@@ -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)
|
||||
Reference in new issue
Block a user