From: Stas Kravets Date: Wed, 9 May 2012 11:21:37 +0000 (+0400) Subject: Preparing for merge with main branch - cleaning up old merge differences X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=c08dde056f47f77c75e025bc3642eff0dcbc288d;p=django-social-auth.git Preparing for merge with main branch - cleaning up old merge differences --- diff --git a/README.rst b/README.rst index ba61ec3..2fddd11 100644 --- a/README.rst +++ b/README.rst @@ -10,11 +10,8 @@ third parties. You can check this documentation on `Read the Docs`_ too. -For Russian services backends (Yandex, Mail.ru, etc.) see http://www.ikrvss.ru/tag/django-social-auth/ - .. contents:: Table of Contents - Demo ---- @@ -52,6 +49,8 @@ credentials, some features are: * `Skyrock OAuth`_ * `Yahoo OAuth`_ * `Evernote OAuth`_ + * `Mail.ru OAuth`_ + * `Odnoklassniki OAuth`_ - Basic user data population and signaling, to allows custom fields values from providers response @@ -955,6 +954,11 @@ Vkontakte uses OAuth v2 for Authentication See the `names of the privileges VKontakte`_. +You can also use Vkontakte's own OpenAPI to log in, but you need to provide a HTML template +with JavaScript code to authenticate. See vkontakte.html in templates folder for details. + +To support authentication for VKontakte applications see `authentication for VKontakte applications`_. + MSN Live Connect ^^^^^^^^^^^^^^^^ @@ -1012,6 +1016,33 @@ Evernote OAuth 1.0 workflow. EVERNOTE_CONSUMER_KEY = '' EVERNOTE_CONSUMER_SECRET = '' +Yandex OAuth and OpenID +^^^^^^^^^^^^^^^^^^^^^^^ + +Yandex uses OAuth 2.0 workflow, fill and YANDEX_APP_ID and YANDEX_API_SECRET settings to log in. +Currently there are 2 backends for Yandex, one is Yaru to log in using Ya.ru service and another one is +YandexOAuth that could use service API from settings. Use YANDEX_OAUTH2_API_URL to set up which service to use. +Tested with 'https://api-yaru.yandex.ru/me/' for Ya.ru and 'http://api.moikrug.ru/v1/my/' for Moi Krug. + +Yandex also uses OpenID 2.0. You do not need to provide user's name because Yandex will do it for you. + +Mail.ru OAuth +^^^^^^^^^^^^^ + +Mail.ru uses OAuth2 workflow, to use it fill in settings + +MAILRU_OAUTH2_CLIENT_KEY = '' +MAILRU_OAUTH2_APP_KEY = '' +MAILRU_OAUTH2_CLIENT_SECRET = '' + +Odnoklassniki.ru +^^^^^^^^^^^^^^^^ + +Odnoklassniki.ru uses OAuth2 workflow, to use it fill in settings + +ODNOKLASSNIKI_OAUTH2_CLIENT_KEY = '' +ODNOKLASSNIKI_OAUTH2_APP_KEY = '' +ODNOKLASSNIKI_OAUTH2_CLIENT_SECRET = '' Testing ------- @@ -1158,6 +1189,10 @@ Attributions to whom deserves: - krvss_ (Stas Kravets): - Initial setup.py configuration + - LiveJournal support + - Mail.ru, Odnoklassniki support + - Yandex OpenID support + - VKontakte OpenAPI support - jezdez_ (Jannis Leidel): @@ -1311,3 +1346,6 @@ Base work is copyrighted by: .. _Yahoo Developer Center: https://developer.apps.yahoo.com/projects/ .. _Evernote API Key form: http://dev.evernote.com/support/api_key.php .. _hassek: https://github.com/hassek +.. _Mail.ru OAuth: http://api.mail.ru/docs/guides/oauth/ +.. _Odnoklassniki OAuth: http://dev.odnoklassniki.ru/wiki/display/ok/The+OAuth+2.0+Protocol +.. _authentication for VKontakte applications: http://www.ikrvss.ru/2011/11/08/django-social-auh-and-vkontakte-application/ \ No newline at end of file diff --git a/doc/backends/google.rst b/doc/backends/google.rst index 65d3b1f..eef9676 100644 --- a/doc/backends/google.rst +++ b/doc/backends/google.rst @@ -87,16 +87,6 @@ Configurable settings: GOOGLE_WHITE_LISTED_EMAILS = ['me@mygoogleappsdomain.com', 'you@gmail.com'] -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:: - - GOOGLE_WHITE_LISTED_DOMAINS = ['mydomain.com'] - - Orkut ----- diff --git a/doc/backends/vkontakte.rst b/doc/backends/vkontakte.rst index a11a422..6916fc2 100644 --- a/doc/backends/vkontakte.rst +++ b/doc/backends/vkontakte.rst @@ -15,6 +15,12 @@ Vkontakte uses OAuth v2 for Authentication See the `names of the privileges VKontakte`_. +You can also use Vkontakte's own OpenAPI to log in, but you need to provide HTML template +with JavaScript code to authenticate. See vkontakte.html in templates folder for details. + +To support authentication for VKontakte applications see `authentication for VKontakte applications`_ + .. _Vkontakte OAuth: http://vk.com/developers.php?oid=-1&p=%D0%90%D0%B2%D1%82%D0%BE%D1%80%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D1%8F_%D1%81%D0%B0%D0%B9%D1%82%D0%BE%D0%B2 .. _names of the privileges VKontakte: http://vk.com/developers.php?oid=-1&p=%D0%9F%D1%80%D0%B0%D0%B2%D0%B0_%D0%B4%D0%BE%D1%81%D1%82%D1%83%D0%BF%D0%B0_%D0%BF%D1%80%D0%B8%D0%BB%D0%BE%D0%B6%D0%B5%D0%BD%D0%B8%D0%B9 .. _Vkontakte API: http://vk.com/developers.php +.. _authentication for VKontakte applications: http://www.ikrvss.ru/2011/11/08/django-social-auh-and-vkontakte-application/ \ No newline at end of file diff --git a/doc/configuration.rst b/doc/configuration.rst index 86c9170..532b0a0 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -296,14 +296,6 @@ uppercase and replace ``-`` with ``_``), here's the supported settings so far:: SOCIAL_AUTH_LOGIN_REDIRECT_URL SOCIAL_AUTH_INACTIVE_USER_URL -- The app catches any exception and logs errors to ``logger`` or - ``django.contrib.messagess`` app. Having tracebacks is really useful when - debugging, for that purpose this setting was defined:: - - SOCIAL_AUTH_RAISE_EXCEPTIONS = DEBUG - - It's default value is ``DEBUG``, so you need to set it to ``False`` to avoid - tracebacks when ``DEBUG = True``. .. _Model Manager: http://docs.djangoproject.com/en/dev/topics/db/managers/#managers .. _Login URL: http://docs.djangoproject.com/en/dev/ref/settings/?from=olddocs#login-url diff --git a/example/app/views.py b/example/app/views.py index a201377..3c10064 100644 --- a/example/app/views.py +++ b/example/app/views.py @@ -8,6 +8,7 @@ from django.contrib.messages.api import get_messages from social_auth import __version__ as version from social_auth.utils import setting + def home(request): """Home view, displays login mechanism""" if request.user.is_authenticated(): diff --git a/requirements.txt b/requirements.txt index fc5acbf..8369636 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ +django>=1.2.5 oauth2>=1.5.167 python_openid>=2.2 diff --git a/setup.py b/setup.py index 0a93d40..d062c08 100644 --- a/setup.py +++ b/setup.py @@ -39,9 +39,10 @@ setup(name='django-social-auth', 'social_auth.backends.pipeline'], package_data={'social_auth':['locale/*/LC_MESSAGES/*']}, long_description=long_description(), - install_requires=['oauth2>=1.5.167', + install_requires=['django>=1.2.5', + 'oauth2>=1.5.167', 'python_openid>=2.2'], - classifiers=['Framework :: Django', + classifiers=['Framework :: Django', 'Development Status :: 4 - Beta', 'Topic :: Internet', 'License :: OSI Approved :: BSD License', diff --git a/social_auth/views.py b/social_auth/views.py index f9ff07f..13bd330 100644 --- a/social_auth/views.py +++ b/social_auth/views.py @@ -11,12 +11,12 @@ from django.contrib.auth.decorators import login_required from django.contrib import messages from django.views.decorators.csrf import csrf_exempt -from social_auth.utils import sanitize_redirect, setting,\ - backend_setting, clean_partial_pipeline +from social_auth.utils import sanitize_redirect, setting, \ + backend_setting, clean_partial_pipeline from social_auth.decorators import dsa_view -DEFAULT_REDIRECT = setting('SOCIAL_AUTH_LOGIN_REDIRECT_URL') or\ +DEFAULT_REDIRECT = setting('SOCIAL_AUTH_LOGIN_REDIRECT_URL') or \ setting('LOGIN_REDIRECT_URL') LOGIN_ERROR_URL = setting('LOGIN_ERROR_URL', setting('LOGIN_URL')) @@ -51,8 +51,8 @@ def associate_complete(request, backend, *args, **kwargs): return user else: url = backend_setting(backend, - 'SOCIAL_AUTH_NEW_ASSOCIATION_REDIRECT_URL') or\ - redirect_value or\ + 'SOCIAL_AUTH_NEW_ASSOCIATION_REDIRECT_URL') or \ + redirect_value or \ DEFAULT_REDIRECT return HttpResponseRedirect(url) @@ -62,8 +62,8 @@ def associate_complete(request, backend, *args, **kwargs): def disconnect(request, backend, association_id=None): """Disconnects given backend from current logged in user.""" backend.disconnect(request.user, association_id) - url = request.REQUEST.get(REDIRECT_FIELD_NAME, '') or\ - backend_setting(backend, 'SOCIAL_AUTH_DISCONNECT_REDIRECT_URL') or\ + url = request.REQUEST.get(REDIRECT_FIELD_NAME, '') or \ + backend_setting(backend, 'SOCIAL_AUTH_DISCONNECT_REDIRECT_URL') or \ DEFAULT_REDIRECT return HttpResponseRedirect(url) @@ -86,7 +86,7 @@ def auth_process(request, backend): return HttpResponseRedirect(backend.auth_url()) else: return HttpResponse(backend.auth_html(), - content_type='text/html;charset=UTF-8') + content_type='text/html;charset=UTF-8') def complete_process(request, backend, *args, **kwargs): @@ -108,7 +108,7 @@ def complete_process(request, backend, *args, **kwargs): # in authenticate process social_user = user.social_user if redirect_value: - request.session[REDIRECT_FIELD_NAME] = redirect_value or\ + request.session[REDIRECT_FIELD_NAME] = redirect_value or \ DEFAULT_REDIRECT if setting('SOCIAL_AUTH_SESSION_EXPIRATION', True): @@ -120,23 +120,23 @@ def complete_process(request, backend, *args, **kwargs): # store last login backend name in session key = setting('SOCIAL_AUTH_LAST_LOGIN', - 'social_auth_last_login_backend') + 'social_auth_last_login_backend') request.session[key] = social_user.provider # Remove possible redirect URL from session, if this is a new # account, send him to the new-users-page if defined. new_user_redirect = backend_setting(backend, - 'SOCIAL_AUTH_NEW_USER_REDIRECT_URL') + 'SOCIAL_AUTH_NEW_USER_REDIRECT_URL') if new_user_redirect and getattr(user, 'is_new', False): url = new_user_redirect else: - url = redirect_value or\ + url = redirect_value or \ backend_setting(backend, - 'SOCIAL_AUTH_LOGIN_REDIRECT_URL') or\ + 'SOCIAL_AUTH_LOGIN_REDIRECT_URL') or \ DEFAULT_REDIRECT else: url = backend_setting(backend, 'SOCIAL_AUTH_INACTIVE_USER_URL', - LOGIN_ERROR_URL) + LOGIN_ERROR_URL) else: msg = setting('LOGIN_ERROR_MESSAGE', None) if msg: @@ -154,9 +154,9 @@ def auth_complete(request, backend, user=None, *args, **kwargs): if request.session.get(name): data = request.session.pop(name) idx, args, kwargs = backend.from_session_dict(data, user=user, - request=request, - *args, **kwargs) + request=request, + *args, **kwargs) return backend.continue_pipeline(pipeline_index=idx, *args, **kwargs) else: return backend.auth_complete(user=user, request=request, *args, - **kwargs) \ No newline at end of file + **kwargs)