Skip to content

Commit

Permalink
facebook: pass state directly instead of encoding into redirect URL
Browse files Browse the repository at this point in the history
...so the redirect URL can match the Strict Mode whitelist.
https://developers.facebook.com/blog/post/2017/12/18/strict-uri-matching/
  • Loading branch information
snarfed committed Dec 18, 2017
1 parent edb7cd5 commit 35df066
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -312,6 +312,10 @@ you have it as a relative directory. pip requires fully qualified directories.

Changelog
---
### 1.11 - unreleased
* Facebook
* Pass `state` to the initial OAuth endpoint directly, instead of encoding it into the redirect URL, so the redirect can [match the Strict Mode whitelist](https://developers.facebook.com/blog/post/2017/12/18/strict-uri-matching/).

### 1.10 - 2017-12-10
Mostly just internal changes to webutil to support granary v1.10.

Expand Down
8 changes: 5 additions & 3 deletions oauth_dropins/facebook.py
Expand Up @@ -34,6 +34,7 @@
'client_id=%(client_id)s',
# redirect_uri here must be the same in the access token request!
'redirect_uri=%(redirect_uri)s',
'state=%(state)s',
'response_type=code',
)))
# https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow#exchangecode
Expand Down Expand Up @@ -143,8 +144,9 @@ def redirect_url(self, state=None, app_id=None):
'scope': self.scope,
# TODO: CSRF protection identifier.
# http://developers.facebook.com/docs/authentication/
'redirect_uri': urllib.quote_plus(self.to_url(state=state)),
})
'redirect_uri': urllib.quote_plus(self.to_url()),
'state': state,
})


class CallbackHandler(handlers.CallbackHandler):
Expand All @@ -160,7 +162,7 @@ def get(self):
'auth_code': auth_code,
'client_id': appengine_config.FACEBOOK_APP_ID,
'client_secret': appengine_config.FACEBOOK_APP_SECRET,
'redirect_uri': urllib.quote_plus(self.request_url_with_state()),
'redirect_uri': urllib.quote_plus(self.request.path_url),
}
try:
resp = json.loads(util.urlopen(url).read())
Expand Down

0 comments on commit 35df066

Please sign in to comment.