From 63ffc7df3ea2b7d2d2a2c240e0f4ddae69ef7348 Mon Sep 17 00:00:00 2001 From: Stas Kravets Date: Mon, 4 Apr 2011 12:27:21 +0400 Subject: [PATCH] Merging with latest head; Yandex OpenID 2.0 support added - no need to specify Yandex username anymore, but it still works if you do. --- example/templates/home.html | 3 ++- setup.py | 3 ++- social_auth/backends/contrib/yandex.py | 9 ++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/example/templates/home.html b/example/templates/home.html index 56dd162..48ec11f 100644 --- a/example/templates/home.html +++ b/example/templates/home.html @@ -38,7 +38,7 @@
  • {% csrf_token %}
    - +
    @@ -61,6 +61,7 @@

    Login using other authentication systems:

    {% endblock %} diff --git a/setup.py b/setup.py index 0919265..c98508d 100644 --- a/setup.py +++ b/setup.py @@ -36,7 +36,8 @@ setup(name='django-social-auth', 'social_auth.backends', 'social_auth.backends.contrib'], 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', 'Development Status :: 4 - Beta', diff --git a/social_auth/backends/contrib/yandex.py b/social_auth/backends/contrib/yandex.py index 15e4e72..5155d09 100644 --- a/social_auth/backends/contrib/yandex.py +++ b/social_auth/backends/contrib/yandex.py @@ -3,6 +3,8 @@ Yandex OpenID support. This contribution adds support for Yandex.ru OpenID service in the form openid.yandex.ru/user. Username is retrieved from the identity url. + +If username is not specified, OpenID 2.0 url used for authentication. """ import urlparse @@ -12,6 +14,7 @@ from social_auth.backends import OpenIDBackend, OpenIdAuth, USERNAME # Yandex conf YANDEX_URL = 'http://openid.yandex.ru/%s' YANDEX_USER_FIELD = 'openid_ya_user' +YANDEX_OID_2_URL = 'http://yandex.ru' class YandexBackend(OpenIDBackend): @@ -25,7 +28,6 @@ class YandexBackend(OpenIDBackend): urlparse.urlsplit(response.identity_url)\ .path.strip('/') - values['email'] = values.get('email') or values[USERNAME] + '@yandex.ru' return values @@ -36,8 +38,9 @@ class YandexAuth(OpenIdAuth): def openid_url(self): """Returns Yandex authentication URL""" if YANDEX_USER_FIELD not in self.data: - raise ValueError, 'Missing Yandex user identifier' - return YANDEX_URL % self.data[YANDEX_USER_FIELD] + return YANDEX_OID_2_URL + else: + return YANDEX_URL % self.data[YANDEX_USER_FIELD] # Backend definition BACKENDS = { -- 2.39.5