From 377cad94ae72d1248b25230a26be8ba2c6c06580 Mon Sep 17 00:00:00 2001 From: Evarin Date: Wed, 18 Apr 2018 23:05:15 +0200 Subject: [PATCH] =?UTF-8?q?D=C3=A9but=20int=C3=A9gration=20allauth?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- avisstage/urls.py | 2 +- experiENS/settings_base.py | 34 ++++++++++++++++++++++++++++++++-- experiENS/urls.py | 10 +++++++--- requirements.txt | 5 +++-- 4 files changed, 43 insertions(+), 8 deletions(-) diff --git a/avisstage/urls.py b/avisstage/urls.py index 15c3bc9..b3acb8a 100644 --- a/avisstage/urls.py +++ b/avisstage/urls.py @@ -9,7 +9,7 @@ v1_api.register(api.AuteurResource()) urlpatterns = [ url(r'^$', views.index, name='index'), - url(r'^perso/$', views.perso, name='perso'), + url(r'^compte/profil/$', views.perso, name='perso'), url(r'^faq/$', views.faq, name='faq'), url(r'^stage/nouveau/$', views.manage_stage, name='stage_ajout'), url(r'^stage/(?P\w+)/$', views.StageView.as_view(), name='stage'), diff --git a/experiENS/settings_base.py b/experiENS/settings_base.py index 40b0332..319e47a 100644 --- a/experiENS/settings_base.py +++ b/experiENS/settings_base.py @@ -1,3 +1,4 @@ +#coding: utf-8 """ Django settings for experiENS project. @@ -11,6 +12,7 @@ https://docs.djangoproject.com/en/1.7/ref/settings/ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os from django.core.urlresolvers import reverse_lazy +from django.contrib import messages BASE_DIR = os.path.dirname(os.path.dirname(__file__)) @@ -29,11 +31,19 @@ INSTALLED_APPS = ( 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.gis', + 'django.contrib.sites', 'django_elasticsearch_dsl', + 'widget_tweaks', + 'allauth_ens', + 'allauth', + 'allauth.account', + 'allauth.socialaccount', + 'allauth_cas', + 'allauth_ens.providers.clipper', + 'tastypie', - 'django_cas_ng', 'braces', 'tinymce', 'taggit', @@ -67,6 +77,7 @@ TEMPLATES = [ 'django.template.context_processors.static', 'django.template.context_processors.tz', 'django.contrib.messages.context_processors.messages', + 'django.template.context_processors.request', ], }, }, @@ -101,9 +112,12 @@ STATIC_URL = '/static/' AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', - 'experiENS.auth.ENSCASBackend', + 'allauth.account.auth_backends.AuthenticationBackend', +# 'experiENS.auth.ENSCASBackend', ) +SITE_ID = 1 + CAS_SERVER_URL = "https://cas.eleves.ens.fr/" #SPI CAS CAS_VERIFY_URL = "https://cas.eleves.ens.fr/" CAS_IGNORE_REFERER = True @@ -114,3 +128,19 @@ CAS_VERSION = 'CAS_2_SAML_1_0' LOGIN_URL = reverse_lazy('login') LOGOUT_URL = reverse_lazy('logout') +LOGIN_REDIRECT_URL = reverse_lazy('avisstage:perso') +ACCOUNT_HOME_URL = reverse_lazy('avisstage:perso') +ACCOUNT_DETAILS_URL = reverse_lazy('avisstage:profil_edit') + +SOCIALACCOUNT_PROVIDERS = { + # … + + 'clipper': { + + # These settings control whether a message containing a link to + # disconnect from the CAS server is added when users log out. + 'MESSAGE_SUGGEST_LOGOUT_ON_LOGOUT': True, + 'MESSAGE_SUGGEST_LOGOUT_ON_LOGOUT_LEVEL': messages.INFO, + + }, +} diff --git a/experiENS/urls.py b/experiENS/urls.py index c247442..72cfbd4 100644 --- a/experiENS/urls.py +++ b/experiENS/urls.py @@ -2,13 +2,17 @@ from django.conf import settings from django.conf.urls import include, url from django.contrib import admin -from django_cas_ng import views as django_cas_views +#from django_cas_ng import views as django_cas_views +from allauth_ens.views import capture_login, capture_logout urlpatterns = [ url(r'^', include('avisstage.urls', namespace='avisstage')), + url(r'^compte/', include('allauth.urls')), - url(r'^login/$', django_cas_views.login, name = "login"), - url(r'^logout/$', django_cas_views.logout, name = "logout"), + url(r'^login/$', capture_login, name="login"), + url(r'^logout/$', capture_logout, name="logout"), +# url(r'^login/$', django_cas_views.login, name = "login"), +# url(r'^logout/$', django_cas_views.logout, name = "logout"), url(r'^tinymce/', include('tinymce.urls')), url(r'^taggit_autosuggest/', include('taggit_autosuggest.urls')), url(r'^admin/', include(admin.site.urls)), diff --git a/requirements.txt b/requirements.txt index f52c4b6..98740c4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -django +django==1.11.* django-cas-ng django-taggit python-ldap @@ -8,4 +8,5 @@ django-taggit-autosuggest pytz django-tastypie lxml -git+https://github.com/sabricot/django-elasticsearch-dsl +git+https://github.com/sabricot/django-elasticsearch-dsl#egg=django_elasticsearch_dsl +django-allauth-ens