Permalink
Browse files

Merge remote-tracking branch 'upstream/master'

  • Loading branch information...
2 parents 2e54187 + 59e13a5 commit c0d2222ee27e3472030bafdb97332fb6270acacf @krvss krvss committed Feb 1, 2012
Showing with 158 additions and 10 deletions.
  1. +1 −1 LICENSE
  2. +33 −0 Makefile
  3. +3 −0 README.rst
  4. +108 −0 django-social-auth.spec
  5. +3 −0 doc/configuration.rst
  6. +10 −9 social_auth/views.py
View
@@ -1,4 +1,4 @@
-Copyright (c) 2010, Matías Aguirre
+Copyright (c) 2010-2012, Matías Aguirre
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
View
@@ -0,0 +1,33 @@
+doc-tar:
+ tar -czvf doc-example.tar.gz example/ doc/
+
+rpm: doc-tar
+ rpmbuild --define "_topdir %(pwd)" \
+ --define "_builddir /tmp" \
+ --define "_rpmdir %{_topdir}" \
+ --define "_srcrpmdir %{_topdir}" \
+ --define "_specdir %{_topdir}" \
+ --define "_sourcedir %{_topdir}" \
+ -ba django-social-auth.spec
+
+ mv noarch/*.rpm .
+
+test:
+ rpmlint -i *.rpm *.spec
+
+clean:
+ rm -rf noarch/ BUILDROOT/
+ rm -f doc-example.tar.gz
+
+distclean: clean
+ rm -f *.rpm
+
+help:
+ @echo "Usage: make <target> "
+ @echo " "
+ @echo " doc-tar - create tarball with docs and example for RPM "
+ @echo " rpm - create rpm package "
+ @echo " test - test all packages/spec files with rpmlint "
+ @echo " clean - clean files used to build "
+ @echo " distclean - execute clean and remove all output files "
+ @echo " help - show this help and exit "
View
@@ -128,6 +128,9 @@ Configuration
Take into account that backends **must** be defined in AUTHENTICATION_BACKENDS_
or Django won't pick them when trying to authenticate the user.
+ Don't miss ``django.contrib.auth.backends.ModelBackend`` if using ``django.auth``
+ user model or users won't be able to login.
+
- Define desired backends for your site::
SOCIAL_AUTH_ENABLED_BACKENDS = ('google', 'google-oauth', 'facebook', ...)
View
@@ -0,0 +1,108 @@
+%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
+%{!?pyver: %define pyver %(%{__python} -c "import sys ; print sys.version[:3]")}
+
+Name: %(%{__python} setup.py --name)
+Version: %(%{__python} setup.py --version)
+Release: 1%{?dist}
+Summary: %(%{__python} setup.py --description)
+
+Group: Development/Libraries
+License: BSD
+URL: %(%{__python} setup.py --url)
+Source0: http://pypi.python.org/packages/source/d/django-social-auth/%{name}-%{version}.tar.gz
+Source1: LICENSE
+Source2: LICENSE.django-openid-auth
+Source3: COPYRIGHT.django-twitter-oauth
+Source4: doc-example.tar.gz
+
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+
+BuildArch: noarch
+BuildRequires: python-devel
+
+# Needs python-sphinx-1.0.7 which is not available in RHEL-6
+%if 0%{?rhel} > 6 || 0%{?fedora} > 12
+BuildRequires: python-sphinx
+%endif
+
+# NB: update this when updating requirements.txt
+Requires: Django >= 1.2.5
+Requires: python-oauth2 >= 1.5.167
+Requires: python-openid >= 2.2
+
+
+%description
+Django Social Auth is an easy to setup social authentication/authorization
+mechanism for Django projects.
+
+This application provides user registration and login using social sites
+supporting OpenID, OAuth and OAuth2 such as Google, Yahoo, Twitter, Facebook,
+LiveJournal, Orkut, LinkedIn, Foursquare, GitHub, DropBox, Flickr.
+
+%package docs
+Summary: Documentation for %{name}
+Group: Documentation
+Requires: %{name} = %{version}-%{release}
+
+%description docs
+This package contains the documentation and example for %{name}
+
+%prep
+%setup -q
+
+# extract doc/ and example/
+tar -xzf %{SOURCE4}
+
+%build
+%{__python} setup.py build
+
+# build the docs if we have
+%if 0%{?rhel} > 6 || 0%{?fedora} >= 12
+ make html -C doc/
+%endif
+
+%install
+rm -rf $RPM_BUILD_ROOT
+%{__python} setup.py install --skip-build --root $RPM_BUILD_ROOT
+
+mkdir -p %{buildroot}/%{_docdir}/%{name}-%{version}
+install -m 0644 %{SOURCE1} %{buildroot}/%{_docdir}/%{name}-%{version}
+install -m 0644 %{SOURCE2} %{buildroot}/%{_docdir}/%{name}-%{version}
+install -m 0644 %{SOURCE3} %{buildroot}/%{_docdir}/%{name}-%{version}
+
+
+# If it's rhel6+ or any Fedora over 12 build docs
+%if 0%{?rhel} > 6 || 0%{?fedora} >= 12
+ # build documentation
+ (cd docs && make html)
+%else
+ cp -r doc/ %{buildroot}/%{_docdir}/%{name}-%{version}
+%endif
+
+cp -r example/ %{buildroot}/%{_docdir}/%{name}-%{version}
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+
+%files
+%defattr(-,root,root,-)
+%doc %{_docdir}/%{name}-%{version}/LICENSE*
+%doc %{_docdir}/%{name}-%{version}/COPYRIGHT*
+%{python_sitelib}/social_auth/*
+
+# Leaving these since people may want to rebuild on lower dists
+%if 0%{?fedora} >= 9 || 0%{?rhel} >= 6
+ %{python_sitelib}/*.egg-info
+%endif
+
+%files docs
+%defattr(-,root,root,-)
+%doc %{_docdir}/%{name}-%{version}/doc
+%doc %{_docdir}/%{name}-%{version}/example
+
+
+%changelog
+
+* Fri Jan 20 2011 Alexander Todorov <atodorov@nospam.otb.bg> - 0.6.1-1
+- initial package
View
@@ -29,6 +29,9 @@ Configuration
Take into account that backends **must** be defined in AUTHENTICATION_BACKENDS_
or Django won't pick them when trying to authenticate the user.
+ Don't miss ``django.contrib.auth.backends.ModelBackend`` if using ``django.auth``
+ user model or users won't be able to login.
+
- Define desired backends for your site::
SOCIAL_AUTH_ENABLED_BACKENDS = ('google', 'google-oauth', 'facebook', ...)
View
@@ -107,16 +107,16 @@ def associate(request, backend):
@dsa_view()
def associate_complete(request, backend, *args, **kwargs):
"""Authentication complete process"""
+ # pop redirect value before the session is trashed on login()
+ redirect_value = request.session.get(REDIRECT_FIELD_NAME, '')
user = auth_complete(request, backend, request.user, *args, **kwargs)
if not user:
url = LOGIN_ERROR_URL
elif isinstance(user, HttpResponse):
return user
else:
- url = NEW_ASSOCIATION_REDIRECT if NEW_ASSOCIATION_REDIRECT else \
- request.session.pop(REDIRECT_FIELD_NAME, '') or \
- DEFAULT_REDIRECT
+ url = NEW_ASSOCIATION_REDIRECT or redirect_value or DEFAULT_REDIRECT
return HttpResponseRedirect(url)
@@ -153,8 +153,9 @@ def auth_process(request, backend):
def complete_process(request, backend, *args, **kwargs):
"""Authentication complete process"""
+ # pop redirect value before the session is trashed on login()
+ redirect_value = request.session.get(REDIRECT_FIELD_NAME, '')
user = auth_complete(request, backend, *args, **kwargs)
- redirect_value = request.session.pop(REDIRECT_FIELD_NAME, '')
if isinstance(user, HttpResponse):
return user
@@ -166,7 +167,7 @@ def complete_process(request, backend, *args, **kwargs):
# in authenticate process
social_user = user.social_user
- if SESSION_EXPIRATION :
+ if SESSION_EXPIRATION:
# Set session expiration date if present and not disabled by
# setting. Use last social-auth instance for current provider,
# users can associate several accounts with a same provider.
@@ -178,10 +179,10 @@ def complete_process(request, backend, *args, **kwargs):
# Remove possible redirect URL from session, if this is a new
# account, send him to the new-users-page if defined.
- url = NEW_USER_REDIRECT if NEW_USER_REDIRECT and \
- getattr(user, 'is_new', False) else \
- redirect_value or \
- DEFAULT_REDIRECT
+ if NEW_USER_REDIRECT and getattr(user, 'is_new', False):
+ url = NEW_USER_REDIRECT
+ else:
+ url = redirect_value or DEFAULT_REDIRECT
else:
url = INACTIVE_USER_URL or LOGIN_ERROR_URL
else:

0 comments on commit c0d2222

Please sign in to comment.