Skip to content

Commit

Permalink
Merge branch 'master' of github.com:omab/django-social-auth
Browse files Browse the repository at this point in the history
  • Loading branch information
omab committed Aug 27, 2013
2 parents e9237ee + 5a6b801 commit b758990
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
4 changes: 0 additions & 4 deletions doc/configuration.rst
Expand Up @@ -472,10 +472,6 @@ Miscellaneous Settings

SOCIAL_AUTH_SESSION_EXPIRATION = False

- It's possible to disable user creations by ``django-social-auth`` with::

SOCIAL_AUTH_CREATE_USERS = False

- If you want to store extra parameters from POST or GET in session, like it
was made for ``next`` parameter, define this setting::

Expand Down
11 changes: 10 additions & 1 deletion social_auth/backends/contrib/linkedin.py
Expand Up @@ -56,8 +56,17 @@ def get_user_details(self, response):
'last_name': last_name,
'email': email}

@classmethod
def tokens(cls, instance):
""" Return list of OAuth v1 tokens from Linkedin """
token = super(LinkedinBackend, cls).tokens(instance)
if token and 'access_token' in token:
token = dict(tok.split('=')
for tok in token['access_token'].split('&'))
return token

class LinkedinOAuth2Backend(LinkedinBackend):

class LinkedinOAuth2Backend(OAuthBackend):
"""Linkedin OAuth2 authentication backend"""
name = 'linkedin-oauth2'

Expand Down
11 changes: 7 additions & 4 deletions social_auth/backends/google.py
Expand Up @@ -252,10 +252,13 @@ def validate_whitelists(backend, email):
"""
emails = setting('GOOGLE_WHITE_LISTED_EMAILS', [])
domains = setting('GOOGLE_WHITE_LISTED_DOMAINS', [])
if emails and email in emails:
return # you're good
if domains and email.split('@', 1)[1] not in domains:
raise AuthFailed(backend, 'Domain not allowed')
if not emails and not domains:
return True
if email in set(emails):
return True # you're good
if email.split('@', 1)[1] in set(domains):
return True
raise AuthFailed(backend, 'User not allowed')


# Backend definition
Expand Down
2 changes: 1 addition & 1 deletion social_auth/tests/facebook.py
Expand Up @@ -12,12 +12,12 @@ class FacebookTestCase(SocialAuthTestsCase):
SERVER_PORT = '8000'

def __init__(self, methodName='runTest'):
self.SERVER_NAME = Site.objects.get_current()
super(FacebookTestCase, self).__init__(methodName)

name = 'facebook'

def setUp(self, *args, **kwargs):
self.SERVER_NAME = Site.objects.get_current()
super(FacebookTestCase, self).setUp(*args, **kwargs)
self.user = setting('TEST_FACEBOOK_USER')
self.passwd = setting('TEST_FACEBOOK_PASSWORD')
Expand Down

0 comments on commit b758990

Please sign in to comment.