added CAS authentification

This commit is contained in:
Ju Luiselli 2020-02-12 23:21:24 +01:00
parent 49a5675bd7
commit 1cf12421f0
6 changed files with 43 additions and 3 deletions

View file

@ -36,6 +36,7 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_cas_ng',
'fiches'
]
@ -67,6 +68,11 @@ TEMPLATES = [
},
]
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'django_cas_ng.backends.CASBackend',
)
WSGI_APPLICATION = 'annuaire.wsgi.application'
@ -123,3 +129,8 @@ STATIC_URL = '/static/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
CAS_SERVER_URL = 'https://cas.eleves.ens.fr/'
CAS_VERSION = "2"

View file

@ -18,12 +18,15 @@ from django.contrib import admin
from django.urls import path, include
from django.conf.urls.static import static
from fiches.views import home, birthday
import django_cas_ng.views as cas_views
urlpatterns = [
path('admin/', admin.site.urls),
path('fiche/', include('fiches.urls')),
path('', home, name='home'),
path('birthday', birthday, name='birthday')
path('birthday', birthday, name='birthday'),
path('login', cas_views.LoginView.as_view(), name='cas_ng_login'),
path('logout', cas_views.LogoutView.as_view(), name='cas_ng_logout'),
]
if settings.DEBUG:

View file

@ -24,7 +24,7 @@ class SearchForm(forms.Form):
year = forms.IntegerField(label='Promotion', required=False)
department = forms.ModelMultipleChoiceField(
queryset=Department.objects.all(), required=False
)
)
def clean(self):
cleaned_data = super().clean()

View file

@ -0,0 +1,20 @@
# Generated by Django 2.2.9 on 2020-02-12 21:30
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('fiches', '0003_auto_20200108_2306'),
]
operations = [
migrations.AlterField(
model_name='profile',
name='user',
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='profile', to=settings.AUTH_USER_MODEL, verbose_name='utilisateur'),
),
]

View file

@ -29,6 +29,11 @@
<a href='{% url "fiche_modif" %}'> Modifier sa fiche d'annuaire </a>
<a href='{% url "fiche" request.user.profile.id %}'> Consulter sa fiche d'annuaire </a>
<a href='{% url "birthday" %}'> Anniversaires à venir </a>
{% if user.is_authenticated %}
<a href='{% url "cas_ng_logout" %}'> Se déconnecter</a>
{% else %}
<a href='{% url "cas_ng_login" %}'> Se connecter</a>
{% endif %}
</nav>
</div>

View file

@ -1,2 +1,3 @@
django==2.2.*
Pillow
Pillow
django_cas_ng