Django 1.10: Sign google oauth requests using csrf token.

In Django 1.10, the get_token function returns a salted version of
csrf token which changes whenever get_token is called. This gives
us wrong result when we compare the state after returning from
Google authentication servers. The solution is to unsalt the token
and use that token to find the HMAC so that we get the same value
as long as t he token is same.
This commit is contained in:
Umair Khan
2016-11-07 15:16:40 +05:00
parent d837753d4b
commit 1e91b946d9
2 changed files with 10 additions and 1 deletions

View File

@@ -520,6 +520,7 @@ class GoogleOAuthTest(ZulipTestCase):
if 'google' not in result.url:
return result
self.client.cookies = result.cookies
# Now extract the CSRF token from the redirect URL
parsed_url = urllib.parse.urlparse(result.url)
csrf_state = urllib.parse.parse_qs(parsed_url.query)['state']