From: tschmidt Date: Tue, 17 Jan 2012 18:42:38 +0000 (-0800) Subject: changed Google OpenID WHITE_LISTED_DOMAINS setting to only check strings and added... X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=8707ef5ba100ed44febd2bbd185b0fd2c8b85149;p=django-social-auth.git changed Google OpenID WHITE_LISTED_DOMAINS setting to only check strings and added documentation --- diff --git a/doc/backends/google.rst b/doc/backends/google.rst index c3cbcfd..271f2f6 100644 --- a/doc/backends/google.rst +++ b/doc/backends/google.rst @@ -65,6 +65,16 @@ To enable OAuth2 support: Check which applications can be included in their `Google Data Protocol Directory`_ +Google OpenID +------------- + +Configurable settings: + +- Supply a list of domain strings to be checked. The default (empty list) allows all domains. If a list is provided and a user attempts to sign in with a Google account that is not in the list, then a ValueError will be raised and the user will be redirected to your login error page:: + + WHITE_LISTED_DOMAINS = ['mydomain.com'] + + Orkut ----- diff --git a/social_auth/backends/google.py b/social_auth/backends/google.py index b81acc7..0748998 100644 --- a/social_auth/backends/google.py +++ b/social_auth/backends/google.py @@ -84,10 +84,8 @@ class GoogleBackend(OpenIDBackend): is unique enought to flag a single user. Email comes from schema: http://axschema.org/contact/email""" # only include white-listed domains - import re - for domain in WHITE_LISTED_DOMAINS: - if not re.search(domain, details['email']): - raise ValueError('INVALID DOMAIN') + if WHITE_LISTED_DOMAINS and details['email'].split('@')[1] not in WHITE_LISTED_DOMAINS: + raise ValueError('INVALID DOMAIN') return details['email']