API crashes if Authentication header is wrong formatted
Created by: temparus
The API crashes if the request header contains Authentication: Token
without providing an actual token.
Here's the traceback when the described situation occurs:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/eve/flaskapp.py", line 1033, in __call__
return super(Eve, self).__call__(environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/local/lib/python2.7/dist-packages/eve/endpoints.py", line 54, in collections_endpoint
response = get(resource, lookup)
File "/usr/local/lib/python2.7/dist-packages/eve/methods/common.py", line 284, in rate_limited
return f(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/eve/auth.py", line 79, in decorated
return f(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/eve/methods/common.py", line 1032, in decorated
getattr(app, event_name)(*gh_params)
File "/usr/local/lib/python2.7/dist-packages/events/events.py", line 77, in __call__
f(*a, **kw)
File "./amivapi/auth/auth.py", line 221, in authenticate
token = token.split(' ')[1]
IndexError: list index out of range