Skip to content

Commit

Permalink
Fix bug in handling of failed github authentication request
Browse files Browse the repository at this point in the history
- The error scenario from the flask.oauthlib.authorized_response() doesn't
  return None.  It can return an Exception object as well.  So, checking for
  None is not very effective.
- This fixes the limited issue we've seen in production related to the return
  from the oauthlib not having the `access_token` in it.  This bug was leading
  to a `KeyError` and masking the real reason github didn't return us the
  token.
  • Loading branch information
durden committed Jun 27, 2016
1 parent a44d657 commit 066518c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pskb_website/views.py
Expand Up @@ -138,9 +138,9 @@ def authorized():
"""URL for Github auth callback"""

resp = remote.github.authorized_response()
if resp is None:
flash('Access denied: reason=%s error=%s' % (
request.args['error'], request.args['error_description']),
if resp is None or resp.get('access_token') is None:
flash('Access denied: reason=%s error=%s resp=%s' % (
request.args['error'], request.args['error_description'], resp),
category='error')
return redirect(url_for('index'))

Expand Down

0 comments on commit 066518c

Please sign in to comment.