Skip to content

Commit

Permalink
Merge 6f30616 into a2c818e
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavi committed Jun 2, 2017
2 parents a2c818e + 6f30616 commit 75550c7
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 21 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
@@ -1,6 +1,6 @@
# Implicit dependencies (optional dependencies of dependencies)
pygments==2.2.0
python-social-auth==0.2.19
social-auth-app-django==1.2.0
elasticsearch==5.3.0
elasticsearch-dsl==5.2.0

Expand Down
51 changes: 50 additions & 1 deletion update.md
Expand Up @@ -1050,4 +1050,53 @@ Actions à faire pour mettre en prod la version : v24
Ticket #4313
------------

+ Via l'admin Django, ajouter la permission `member.change_bannedemailprovider` aux groupes autorisés à gérer les fournisseurs e-mail bannis.
+ Via l'admin Django, ajouter la permission `member.change_bannedemailprovider` aux groupes autorisés à gérer les fournisseurs e-mail bannis.

Ticket #4352 (python-social-auth)
---------------------------------

### Actions à faire AVANT de lancer le script de mise-à-jour

1. Installer la version 0.2.21 de *python-social-auth* : `pip install --upgrade "python-social-auth==0.2.21"`
2. Lancer la migration de la base de données pour cette application uniquement : `python manage.py migrate social_auth`

### Après la mise-à-jour

1. Désinstaller complètement *python-social-auth* : `pip uninstall python-social-auth`
2. Changer les valeurs suivantes dans le settings_prod.py :

```diff
# TEMPLATE
- 'social.apps.django_app.context_processors.backends',
- 'social.apps.django_app.context_processors.login_redirect',
+ 'social_django.context_processors.backends',
+ 'social_django.context_processors.login_redirect',

# SOCIAL_AUTH_PIPELINE
SOCIAL_AUTH_PIPELINE = (
- 'social.pipeline.social_auth.social_details',
- 'social.pipeline.social_auth.social_uid',
- 'social.pipeline.social_auth.auth_allowed',
- 'social.pipeline.social_auth.social_user',
- 'social.pipeline.user.get_username',
- 'social.pipeline.social_auth.associate_by_email',
- 'social.pipeline.user.create_user',
- 'zds.member.models.save_profile',
- 'social.pipeline.social_auth.associate_user',
- 'social.pipeline.social_auth.load_extra_data',
- 'social.pipeline.user.user_details'
+ 'social_core.pipeline.social_auth.social_details',
+ 'social_core.pipeline.social_auth.social_uid',
+ 'social_core.pipeline.social_auth.auth_allowed',
+ 'social_core.pipeline.social_auth.social_user',
+ 'social_core.pipeline.user.get_username',
+ 'social_core.pipeline.user.create_user',
+ 'zds.member.models.save_profile',
+ 'social_core.pipeline.social_auth.associate_user',
+ 'social_core.pipeline.social_auth.load_extra_data',
+ 'social_core.pipeline.user.user_details'
)

```

3. Relancer les services : `sudo systemct restart zds.{service,socket}
11 changes: 8 additions & 3 deletions zds/member/utils.py
@@ -1,17 +1,22 @@
# coding: utf-8

from __future__ import unicode_literals
from social.apps.django_app.middleware import SocialAuthExceptionMiddleware

import logging

from social_django.middleware import SocialAuthExceptionMiddleware

from django.contrib import messages
from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse
import logging

logger = logging.getLogger(__name__)


class ZDSCustomizeSocialAuthExceptionMiddleware(SocialAuthExceptionMiddleware):
"""
For more information, \
see http://python-social-auth.readthedocs.io/en/latest/configuration/django.html#exceptions-middleware.
see https://python-social-auth.readthedocs.io/en/latest/configuration/django.html#exceptions-middleware.
"""
def get_message(self, request, exception):
# this message aims to be displayed in our "error" widget
Expand Down
37 changes: 22 additions & 15 deletions zds/settings.py
Expand Up @@ -108,6 +108,7 @@
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'social_django.middleware.SocialAuthExceptionMiddleware',
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
'zds.utils.ThreadLocals',
Expand Down Expand Up @@ -139,8 +140,8 @@
'django.template.context_processors.request',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
'social.apps.django_app.context_processors.backends',
'social.apps.django_app.context_processors.login_redirect',
'social_django.context_processors.backends',
'social_django.context_processors.login_redirect',
# ZDS context processors
'zds.utils.context_processor.app_settings',
'zds.utils.context_processor.git_version',
Expand All @@ -165,7 +166,7 @@
'easy_thumbnails.optimize',
'crispy_forms',
'munin',
'social.apps.django_app.default',
'social_django',
'rest_framework',
'rest_framework_swagger',
'dry_rest_permissions',
Expand Down Expand Up @@ -589,23 +590,29 @@

LOGIN_REDIRECT_URL = '/'

AUTHENTICATION_BACKENDS = ('social.backends.facebook.FacebookOAuth2',
'social.backends.google.GoogleOAuth2',
'django.contrib.auth.backends.ModelBackend')
# python-social-auth (Django app)
# https://python-social-auth.readthedocs.io/en/latest/configuration/django.html

AUTHENTICATION_BACKENDS = (
'social_core.backends.facebook.FacebookOAuth2',
'social_core.backends.google.GoogleOAuth2',
'django.contrib.auth.backends.ModelBackend'
)

SOCIAL_AUTH_GOOGLE_OAUTH2_USE_DEPRECATED_API = True
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email']

SOCIAL_AUTH_PIPELINE = (
'social.pipeline.social_auth.social_details',
'social.pipeline.social_auth.social_uid',
'social.pipeline.social_auth.auth_allowed',
'social.pipeline.social_auth.social_user',
'social.pipeline.user.get_username',
'social.pipeline.user.create_user',
'social_core.pipeline.social_auth.social_details',
'social_core.pipeline.social_auth.social_uid',
'social_core.pipeline.social_auth.auth_allowed',
'social_core.pipeline.social_auth.social_user',
'social_core.pipeline.user.get_username',
'social_core.pipeline.user.create_user',
'zds.member.models.save_profile',
'social.pipeline.social_auth.associate_user',
'social.pipeline.social_auth.load_extra_data',
'social.pipeline.user.user_details'
'social_core.pipeline.social_auth.associate_user',
'social_core.pipeline.social_auth.load_extra_data',
'social_core.pipeline.user.user_details'
)

# redefine for real key and secret code
Expand Down
2 changes: 1 addition & 1 deletion zds/urls.py
Expand Up @@ -101,7 +101,7 @@ def location(self, item):
url(r'^munin/', include('zds.munin.urls')),
url(r'^mise-en-avant/', include('zds.featured.urls')),
url(r'^notifications/', include('zds.notification.urls')),
url('', include('social.apps.django_app.urls', namespace='social')),
url('', include('social_django.urls', namespace='social')),
url('', include('django.contrib.auth.urls', namespace='auth')),

url(r'^munin/', include('munin.urls')),
Expand Down

0 comments on commit 75550c7

Please sign in to comment.