hiidef/oauth2app — pull request #41 by alexsdutton (2013-03-04 09:15:33+00:00)
Title: Handle malformed Authorization headers without a 500.

There's an uncaught exception when the Authentication header is empty, as handily pointed out by the Googlebot:

```Traceback (most recent call last):

File "/usr/lib/python2.6/dist-packages/django/core/handlers/base.py", line 89, in get_response
response = middleware_method(request)

File "/usr/lib/python2.6/dist-packages/dataox/oauth2/middleware.py", line 10, in process_request
authenticator.validate(request)

File "/etc/puppet/src/oauth2app/oauth2app/authenticate.py", line 97, in validate
self.auth_type = auth[0].lower()

IndexError: list index out of range

,
POST:,
COOKIES:{},
META:{'DOCUMENT_ROOT': '/etc/apache2/htdocs',
'GATEWAY_INTERFACE': 'CGI/1.1',
'HTTPS': '1',
'HTTP_ACCEPT': '*/*',
'HTTP_ACCEPT_ENCODING': 'gzip,deflate',
'HTTP_AUTHORIZATION': '',
'HTTP_CONNECTION': 'Keep-alive',
'HTTP_FROM': 'googlebot(at)googlebot.com',
'HTTP_HOST': 'data.ox.ac.uk',
'HTTP_IF_MODIFIED_SINCE': 'Fri, 11 Jan 2013 04:50:27 GMT',
'HTTP_USER_AGENT': 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)',>```

I noticed another part susceptible to this problem in oauth2app.token, where an Authentication header that didn't split() into at least two parts would throw an error, which I've also fixed.