From caaf92eb91a24dcc9deb5dccfb3852cc6e3f5e4c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mat=C3=ADas=20Aguirre?= Date: Mon, 6 Feb 2012 16:49:58 -0200 Subject: [PATCH] PEP8 --- social_auth/backends/google.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/social_auth/backends/google.py b/social_auth/backends/google.py index 0daf57d..6a94cc0 100644 --- a/social_auth/backends/google.py +++ b/social_auth/backends/google.py @@ -30,9 +30,9 @@ from social_auth.backends import OpenIdAuth, ConsumerBasedOAuth, BaseOAuth2, \ # Google OAuth base configuration GOOGLE_OAUTH_SERVER = 'www.google.com' -GOOGLE_OAUTH_AUTHORIZATION_URL = 'https://www.google.com/accounts/OAuthAuthorizeToken' -GOOGLE_OAUTH_REQUEST_TOKEN_URL = 'https://www.google.com/accounts/OAuthGetRequestToken' -GOOGLE_OAUTH_ACCESS_TOKEN_URL = 'https://www.google.com/accounts/OAuthGetAccessToken' +AUTHORIZATION_URL = 'https://www.google.com/accounts/OAuthAuthorizeToken' +REQUEST_TOKEN_URL = 'https://www.google.com/accounts/OAuthGetRequestToken' +ACCESS_TOKEN_URL = 'https://www.google.com/accounts/OAuthGetAccessToken' # Google OAuth2 base configuration GOOGLE_OAUTH2_SERVER = 'accounts.google.com' @@ -45,9 +45,6 @@ GOOGLEAPIS_EMAIL = 'https://www.googleapis.com/userinfo/email' GOOGLE_OPENID_URL = 'https://www.google.com/accounts/o8/id' -# white-listed domains (else accept all) -GOOGLE_WHITE_LISTED_DOMAINS = getattr(settings, 'GOOGLE_WHITE_LISTED_DOMAINS', []) - # Backends class GoogleOAuthBackend(OAuthBackend): """Google OAuth authentication backend""" @@ -81,12 +78,15 @@ class GoogleBackend(OpenIDBackend): name = 'google' def get_user_id(self, details, response): - """Return user unique id provided by service. For google user email + """ + Return user unique id provided by service. For google user email is unique enought to flag a single user. Email comes from schema: - http://axschema.org/contact/email""" - # only include white-listed domains - if GOOGLE_WHITE_LISTED_DOMAINS and details['email'].split('@')[1] not in GOOGLE_WHITE_LISTED_DOMAINS: - raise ValueError('INVALID DOMAIN') + http://axschema.org/contact/email + """ + # White listed domains (accepts all if list is empty) + domains = setting('GOOGLE_WHITE_LISTED_DOMAINS', []) + if domains and details['email'].split('@', 1)[1] not in domains: + raise ValueError('Domain not allowed') return details['email'] @@ -103,9 +103,9 @@ class GoogleAuth(OpenIdAuth): class BaseGoogleOAuth(ConsumerBasedOAuth): """Base class for Google OAuth mechanism""" - AUTHORIZATION_URL = GOOGLE_OAUTH_AUTHORIZATION_URL - REQUEST_TOKEN_URL = GOOGLE_OAUTH_REQUEST_TOKEN_URL - ACCESS_TOKEN_URL = GOOGLE_OAUTH_ACCESS_TOKEN_URL + AUTHORIZATION_URL = AUTHORIZATION_URL + REQUEST_TOKEN_URL = REQUEST_TOKEN_URL + ACCESS_TOKEN_URL = ACCESS_TOKEN_URL SERVER_URL = GOOGLE_OAUTH_SERVER def user_data(self, access_token): -- 2.39.5