Migration vers django_cas_ng
Précédemment, GestioCOF utilisait django-cas, qui n'est plus maintenu. Ceci le remplace par django-cas-ng, un fork plus récent et maintenu. En particulier, django-cas-ng est compatible avec Python 3, contrairement à django-cas.
This commit is contained in:
parent
498fa2809b
commit
21641c9468
7 changed files with 14 additions and 9 deletions
|
@ -46,6 +46,7 @@ INSTALLED_APPS = (
|
|||
'autocomplete_light',
|
||||
'eav',
|
||||
'captcha',
|
||||
'django_cas_ng',
|
||||
'debug_toolbar',
|
||||
)
|
||||
|
||||
|
|
|
@ -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'),
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
{% block content %}
|
||||
<div id="main-login-container">
|
||||
<div id="main-login">
|
||||
<a id="login_clipper" href="{% url 'django_cas.views.login' %}">
|
||||
<a id="login_clipper" href="{% url 'django_cas_ng.views.login' %}">
|
||||
Compte clipper
|
||||
</a>
|
||||
<a id="login_outsider" href="{% url 'gestioncof.views.login_ext' %}">
|
||||
|
|
|
@ -56,7 +56,7 @@ def logout(request):
|
|||
except CofProfile.DoesNotExist:
|
||||
profile, created = CofProfile.objects.get_or_create(user = request.user)
|
||||
if profile.login_clipper:
|
||||
return redirect("django_cas.views.logout")
|
||||
return redirect("django_cas_ng.views.logout")
|
||||
else:
|
||||
return redirect("django.contrib.auth.views.logout")
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ configparser==3.5.0
|
|||
Django==1.8.13
|
||||
django-autocomplete-light==2.3.3
|
||||
django-autoslug==1.8.0
|
||||
-e hg+https://bitbucket.org/cpcc/django-cas@47d19f3a871fa744dabe884758f90fff6ba135d5#egg=django_cas
|
||||
django-cas-ng==3.5.4
|
||||
django-grappelli==2.6.5
|
||||
django-recaptcha==1.0.5
|
||||
eav-django==1.4.7
|
||||
|
|
Loading…
Reference in a new issue