added CAS authentification
This commit is contained in:
parent
0a3e9b28df
commit
14bc4927ed
6 changed files with 45 additions and 3 deletions
|
@ -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"
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -22,7 +22,9 @@ class ProfileForm(forms.ModelForm):
|
|||
class SearchForm(forms.Form):
|
||||
name = forms.CharField(label='Nom/Surnom', max_length=1023, required=False)
|
||||
year = forms.IntegerField(label='Promotion', required=False)
|
||||
department = forms.ModelMultipleChoiceField(queryset=Department.objects.all(), required=False)
|
||||
department = forms.ModelMultipleChoiceField(
|
||||
queryset=Department.objects.all(), required=False
|
||||
)
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super().clean()
|
||||
|
|
20
fiches/migrations/0004_auto_20200212_2130.py
Normal file
20
fiches/migrations/0004_auto_20200212_2130.py
Normal 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'),
|
||||
),
|
||||
]
|
|
@ -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>
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
django==2.2.*
|
||||
Pillow
|
||||
Pillow
|
||||
django_cas_ng
|
||||
|
|
Loading…
Reference in a new issue