Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
Conflicts:
	doc/configuration.rst
	doc/signals.rst
  • Loading branch information
ChrisCooper committed Feb 17, 2013
2 parents b04d8f7 + 5664e07 commit 5f47bf5
Show file tree
Hide file tree
Showing 52 changed files with 450 additions and 664 deletions.
412 changes: 228 additions & 184 deletions doc/configuration.rst

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion doc/index.rst
Expand Up @@ -18,7 +18,6 @@ Contents:
pipeline
deprecated

signals
tokens
contributions
testing
Expand Down
30 changes: 29 additions & 1 deletion doc/miscellaneous.rst
Expand Up @@ -27,7 +27,7 @@ package and link it there.


Python 2.7.2rev4, 2.7.3 and Facebook backend
-------------------------------------------
--------------------------------------------

It seems that this bug described in StackOverflow_ hits users using
django-social-auth_ with Python versions 2.7.2rev4 and 2.7.3 (so far) and
Expand All @@ -46,9 +46,37 @@ This issue is usually solved by installing ``ntp`` in the server (which is
a good practice to have too), and syncing the time with some ntp pool service.


url Template Tag
----------------

Since Django 1.3 the URL templatetag ``{% url socialauth_begin ... %}`` syntax
is deprecated in favor the new format where the URL name is quoted (using
single quotes). See the `release notes`_ for details.

The new syntax is not enforced yet but will be on Django 1.5, and it's also
available by importing ``url`` tag from ``future`` module doing::

{% load url from future %}

In case of experiencing issues similar to `#303`_, check the tag being used and
its syntax.


Heroku and SSL
--------------

Seems that Heroku fails to pass the needed headers to indicate that the app is
behind SSL, this causes troubles when building the redirect URLs used in the
authentication process and providers respond with invalid redirect URL error.
To enforce ``https://`` when building the URLs just define this setting::

SOCIAL_AUTH_REDIRECT_IS_HTTPS = True

.. _South: http://south.aeracode.org/
.. _django-social-auth: https://github.com/omab/django-social-auth
.. _djangopackages.com: http://djangopackages.com/grids/g/social-auth-backends/
.. _django-social-auth discussion list: https://groups.google.com/group/django-social-auth
.. _StackOverflow: http://stackoverflow.com/questions/9835506/urllib-urlopen-works-on-sslv3-urls-with-python-2-6-6-on-1-machine-but-not-wit
.. _#315: https://github.com/omab/django-social-auth/issues/315
.. _release notes: https://docs.djangoproject.com/en/1.3/releases/1.3/#changes-to-url-and-ssi
.. _#303: https://github.com/omab/django-social-auth/issues/303
39 changes: 0 additions & 39 deletions doc/signals.rst

This file was deleted.

12 changes: 4 additions & 8 deletions social_auth/backends/__init__.py
Expand Up @@ -59,10 +59,6 @@
OPENID_ID_FIELD = 'openid_identifier'
SESSION_NAME = 'openid'

# key for username in user details dict used around, see get_user_details
# method
USERNAME = 'username'

PIPELINE = setting('SOCIAL_AUTH_PIPELINE', (
'social_auth.backends.pipeline.social.social_auth_user',
# Removed by default since it can be a dangerouse behavior that
Expand Down Expand Up @@ -160,7 +156,7 @@ def get_user_id(self, details, response):

def get_user_details(self, response):
"""Must return user details in a know internal struct:
{USERNAME: <username if any>,
{'username': <username if any>,
'email': <user email if any>,
'fullname': <user full name if any>,
'first_name': <user first name if any>,
Expand Down Expand Up @@ -270,7 +266,7 @@ def values_from_response(self, response, sreg_names=None, ax_names=None):

def get_user_details(self, response):
"""Return user details from an OpenID request"""
values = {USERNAME: '', 'email': '', 'fullname': '',
values = {'username': '', 'email': '', 'fullname': '',
'first_name': '', 'last_name': ''}
# update values using SimpleRegistration or AttributeExchange
# values
Expand All @@ -295,8 +291,8 @@ def get_user_details(self, response):
'fullname': fullname,
'first_name': first_name,
'last_name': last_name,
USERNAME: values.get(USERNAME) or
(first_name.title() + last_name.title())
'username': values.get('username') or
(first_name.title() + last_name.title())
})
return values

Expand Down
8 changes: 3 additions & 5 deletions social_auth/backends/browserid.py
@@ -1,15 +1,13 @@
"""
BrowserID support
"""
import time
from datetime import datetime
from urllib import urlencode

from django.contrib.auth import authenticate
from django.utils import simplejson

from social_auth.backends import SocialAuthBackend, BaseAuth, USERNAME
from social_auth.utils import log, setting, dsa_urlopen
from social_auth.backends import SocialAuthBackend, BaseAuth
from social_auth.utils import log, dsa_urlopen
from social_auth.exceptions import AuthFailed, AuthMissingParameter


Expand All @@ -33,7 +31,7 @@ def get_user_details(self, response):
# 'email': 'name@server.com',
# 'issuer': 'login.persona.org'}
email = response['email']
return {USERNAME: email.split('@', 1)[0],
return {'username': email.split('@', 1)[0],
'email': email,
'fullname': '',
'first_name': '',
Expand Down
4 changes: 2 additions & 2 deletions social_auth/backends/contrib/angel.py
Expand Up @@ -14,7 +14,7 @@

from django.utils import simplejson

from social_auth.backends import BaseOAuth2, OAuthBackend, USERNAME
from social_auth.backends import BaseOAuth2, OAuthBackend
from social_auth.utils import dsa_urlopen


Expand All @@ -37,7 +37,7 @@ def get_user_details(self, response):
last_name = response['name'].split(' ')[-1]
email = response['email']
return {
USERNAME: username,
'username': username,
'first_name': first_name,
'last_name': last_name,
'email': email,
Expand Down
4 changes: 2 additions & 2 deletions social_auth/backends/contrib/behance.py
Expand Up @@ -10,7 +10,7 @@
By default username and access_token are stored in extra_data field.
"""
from social_auth.backends import BaseOAuth2, OAuthBackend, USERNAME
from social_auth.backends import BaseOAuth2, OAuthBackend


# Behance configuration
Expand All @@ -33,7 +33,7 @@ def get_user_details(self, response):
"""Return user details from Behance account"""
user = response['user']
return {
USERNAME: user['username'],
'username': user['username'],
'last_name': user['last_name'],
'first_name': user['first_name'],
'fullname': user['display_name'],
Expand Down
8 changes: 4 additions & 4 deletions social_auth/backends/contrib/bitbucket.py
Expand Up @@ -11,8 +11,8 @@
extend it.
"""
from django.utils import simplejson
from social_auth.backends import ConsumerBasedOAuth, OAuthBackend, USERNAME
from social_auth.utils import setting, dsa_urlopen
from social_auth.backends import ConsumerBasedOAuth, OAuthBackend
from social_auth.utils import dsa_urlopen

# Bitbucket configuration
BITBUCKET_SERVER = 'bitbucket.org/api/1.0'
Expand All @@ -30,15 +30,15 @@ class BitbucketBackend(OAuthBackend):
name = 'bitbucket'
EXTRA_DATA = [
('username', 'username'),
('expires', setting('SOCIAL_AUTH_EXPIRATION', 'expires')),
('expires', 'expires'),
('email', 'email'),
('first_name', 'first_name'),
('last_name', 'last_name')
]

def get_user_details(self, response):
"""Return user details from Bitbucket account"""
return {USERNAME: response.get('username'),
return {'username': response.get('username'),
'email': response.get('email'),
'fullname': ' '.join((response.get('first_name'),
response.get('last_name'))),
Expand Down
5 changes: 2 additions & 3 deletions social_auth/backends/contrib/dailymotion.py
Expand Up @@ -16,7 +16,6 @@ class for details on how to extend it.
from django.utils import simplejson

from social_auth.utils import dsa_urlopen
from social_auth.backends import USERNAME
from social_auth.backends import BaseOAuth2
from social_auth.backends import SocialAuthBackend
from social_auth.exceptions import AuthCanceled
Expand All @@ -42,10 +41,10 @@ class DailymotionBackend(SocialAuthBackend):

def get_user_id(self, details, response):
"""Use dailymotion username as unique id"""
return details[USERNAME]
return details['username']

def get_user_details(self, response):
return {USERNAME: response['screenname']}
return {'username': response['screenname']}


class DailymotionAuth(BaseOAuth2):
Expand Down
10 changes: 5 additions & 5 deletions social_auth/backends/contrib/disqus.py
@@ -1,7 +1,6 @@
from django.utils import simplejson
from social_auth.backends import BaseOAuth2, OAuthBackend, USERNAME
from social_auth.backends import BaseOAuth2, OAuthBackend
from social_auth.utils import dsa_urlopen, backend_setting
from social_auth.utils import setting
from urllib import urlencode


Expand All @@ -20,7 +19,7 @@ class DisqusBackend(OAuthBackend):
('user_id', 'user_id'),
('email', 'email'),
('email_hash', 'emailHash'),
('expires', setting('SOCIAL_AUTH_EXPIRATION', 'expires')),
('expires', 'expires'),
('location', 'location'),
('meta', 'response'),
('name', 'name'),
Expand All @@ -35,15 +34,16 @@ def get_user_details(self, response):
rr = response.get('response', {})

return {
USERNAME: rr.get('username', ''),
'username': rr.get('username', ''),
'user_id': response.get('user_id', ''),
'email': rr.get('email', ''),
'name': rr.get('name', ''),
}

def extra_data(self, user, uid, response, details):
meta_response = dict(response, **response.get('response', {}))
return super(DisqusBackend, self).extra_data(user, uid, meta_response, details)
return super(DisqusBackend, self).extra_data(user, uid, meta_response,
details)


class DisqusAuth(BaseOAuth2):
Expand Down
7 changes: 3 additions & 4 deletions social_auth/backends/contrib/douban.py
Expand Up @@ -14,8 +14,7 @@ class for details on how to extend it.
from django.utils import simplejson

from social_auth.utils import dsa_urlopen
from social_auth.backends import ConsumerBasedOAuth, OAuthBackend, USERNAME, \
BaseOAuth2
from social_auth.backends import ConsumerBasedOAuth, OAuthBackend, BaseOAuth2
from social_auth.exceptions import AuthCanceled


Expand All @@ -39,7 +38,7 @@ def get_user_id(self, details, response):

def get_user_details(self, response):
"""Return user details from Douban"""
return {USERNAME: response["db:uid"]["$t"],
return {'username': response["db:uid"]["$t"],
'email': ''}


Expand Down Expand Up @@ -84,7 +83,7 @@ def get_user_id(self, details, response):

def get_user_details(self, response):
"""Return user details from Douban"""
return {USERNAME: response.get('uid', ''),
return {'username': response.get('uid', ''),
'fullname': response.get('name', ''),
'email': ''}

Expand Down
6 changes: 3 additions & 3 deletions social_auth/backends/contrib/dropbox.py
Expand Up @@ -11,7 +11,7 @@
from django.utils import simplejson

from social_auth.utils import setting
from social_auth.backends import ConsumerBasedOAuth, OAuthBackend, USERNAME
from social_auth.backends import ConsumerBasedOAuth, OAuthBackend


# Dropbox configuration
Expand All @@ -28,12 +28,12 @@ class DropboxBackend(OAuthBackend):
# Default extra data to store
EXTRA_DATA = [
('id', 'id'),
('expires', setting('SOCIAL_AUTH_EXPIRATION', 'expires'))
('expires', 'expires')
]

def get_user_details(self, response):
"""Return user details from Dropbox account"""
return {USERNAME: str(response.get('uid')),
return {'username': str(response.get('uid')),
'email': response.get('email'),
'first_name': response.get('display_name')}

Expand Down
6 changes: 3 additions & 3 deletions social_auth/backends/contrib/evernote.py
Expand Up @@ -13,7 +13,7 @@

from oauth2 import Token
from social_auth.utils import setting
from social_auth.backends import ConsumerBasedOAuth, OAuthBackend, USERNAME
from social_auth.backends import ConsumerBasedOAuth, OAuthBackend
from social_auth.exceptions import AuthCanceled


Expand Down Expand Up @@ -50,13 +50,13 @@ class EvernoteBackend(OAuthBackend):
('access_token', 'access_token'),
('oauth_token', 'oauth_token'),
('edam_noteStoreUrl', 'store_url'),
('edam_expires', setting('SOCIAL_AUTH_EXPIRATION', 'expires'))
('edam_expires', 'expires')
]

def get_user_details(self, response):
"""Return user details from Evernote account"""
return {
USERNAME: response['edam_userId'],
'username': response['edam_userId'],
'email': '',
}

Expand Down
8 changes: 3 additions & 5 deletions social_auth/backends/contrib/fitbit.py
Expand Up @@ -17,8 +17,7 @@

from oauth2 import Token

from social_auth.utils import setting
from social_auth.backends import ConsumerBasedOAuth, OAuthBackend, USERNAME
from social_auth.backends import ConsumerBasedOAuth, OAuthBackend


# Fitbit configuration
Expand All @@ -27,7 +26,6 @@
FITBIT_AUTHORIZATION_URL = '%s/oauth/authorize' % FITBIT_SERVER
FITBIT_ACCESS_TOKEN_URL = '%s/oauth/access_token' % FITBIT_SERVER
FITBIT_USERINFO = 'http://api.fitbit.com/1/user/-/profile.json'
EXPIRES_NAME = setting('SOCIAL_AUTH_EXPIRATION', 'expires')


class FitbitBackend(OAuthBackend):
Expand All @@ -36,7 +34,7 @@ class FitbitBackend(OAuthBackend):
# Default extra data to store
EXTRA_DATA = [('id', 'id'),
('username', 'username'),
('expires', EXPIRES_NAME)]
('expires', 'expires')]

def get_user_id(self, details, response):
"""
Expand All @@ -47,7 +45,7 @@ def get_user_id(self, details, response):

def get_user_details(self, response):
"""Return user details from Fitbit account"""
return {USERNAME: response.get('id'),
return {'username': response.get('id'),
'email': '',
'first_name': response.get('fullname')}

Expand Down

0 comments on commit 5f47bf5

Please sign in to comment.