diff --git a/cof/settings_dev.py b/cof/settings_dev.py index 633ec6a4..3246b6e5 100644 --- a/cof/settings_dev.py +++ b/cof/settings_dev.py @@ -45,6 +45,7 @@ INSTALLED_APPS = ( 'bda3', 'autocomplete_light', 'captcha', + 'django_cas_ng', 'debug_toolbar', ) diff --git a/cof/urls.py b/cof/urls.py index 991fb72f..3e63ae02 100644 --- a/cof/urls.py +++ b/cof/urls.py @@ -16,8 +16,8 @@ from gestioncof.petits_cours_views import DemandeListView urlpatterns = patterns('', url(r'^$', 'gestioncof.views.home', name = 'home'), url(r'^cof/denied$', TemplateView.as_view(template_name = 'cof-denied.html'), name = "cof-denied"), - url(r'^cas/login$', 'django_cas.views.login', name = "cas_login_view"), - url(r'^cas/logout$', 'django_cas.views.logout'), + url(r'^cas/login$', 'django_cas_ng.views.login', name = "cas_login_view"), + url(r'^cas/logout$', 'django_cas_ng.views.logout'), url(r'^outsider/login$', 'gestioncof.views.login_ext'), url(r'^outsider/logout$', 'django.contrib.auth.views.logout', {'next_page': '/gestion/'}), url(r'^outsider/password-change$', 'django.contrib.auth.views.password_change'), diff --git a/gestioncof/decorators.py b/gestioncof/decorators.py index b276d372..1a3d60c5 100644 --- a/gestioncof/decorators.py +++ b/gestioncof/decorators.py @@ -1,4 +1,4 @@ -from django_cas.decorators import user_passes_test +from django_cas_ng.decorators import user_passes_test def is_cof(user): try: diff --git a/gestioncof/shared.py b/gestioncof/shared.py index f46f7f90..5a6c7775 100644 --- a/gestioncof/shared.py +++ b/gestioncof/shared.py @@ -1,7 +1,8 @@ from django.contrib.sites.models import Site from django.conf import settings -from django_cas.backends import CASBackend, _verify as CASverify -from django_cas.models import User +from django_cas_ng.backends import CASBackend +from django_cas_ng.utils import get_cas_client +from django.contrib.auth import get_user_model from django.contrib.auth.models import User as DjangoUser from django.db import models, connection from django.core.mail import send_mail @@ -9,11 +10,14 @@ from django.template import Template, Context from gestioncof.models import CofProfile, CustomMail +User = get_user_model() + class COFCASBackend(CASBackend): def authenticate_cas(self, ticket, service, request): """Verifies CAS ticket and gets or creates User object""" - username, attributes = CASverify(ticket, service) + client = get_cas_client(service_url=service) + username, attributes, _= client.verify_ticket(ticket) if attributes: request.session['attributes'] = attributes if not username: diff --git a/gestioncof/templates/login_switch.html b/gestioncof/templates/login_switch.html index 84ae1878..fe816a78 100644 --- a/gestioncof/templates/login_switch.html +++ b/gestioncof/templates/login_switch.html @@ -3,7 +3,7 @@ {% block content %}