CAS authentification

This commit is contained in:
Quentin VERMANDE 2020-10-22 19:24:16 +02:00
parent 9c0b7a66fa
commit 8f6ef82f99
7 changed files with 55 additions and 2 deletions

View file

@ -39,6 +39,7 @@ MIDDLEWARE = [
"django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware", "django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware",
'django_cas_ng.middleware.CASMiddleware'
] ]
ROOT_URLCONF = "gestiojeux.urls" ROOT_URLCONF = "gestiojeux.urls"
@ -61,6 +62,11 @@ TEMPLATES = [
WSGI_APPLICATION = "gestiojeux.wsgi.application" WSGI_APPLICATION = "gestiojeux.wsgi.application"
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'django_cas_ng.backends.CASBackend',
)
# Password validation # Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
@ -78,3 +84,10 @@ AUTH_PASSWORD_VALIDATORS = [
STATIC_URL = "/static/" STATIC_URL = "/static/"
MEDIA_URL = "/media/" MEDIA_URL = "/media/"
CAS_SERVER_URL = "https://cas.eleves.ens.fr/"
CAS_VERSION = "2"
CAS_LOGIN_MSG = None
CAS_IGNORE_REFERER = True
CAS_EMAIL_FORMAT = "%s@clipper.ens.fr"

View file

@ -0,0 +1,22 @@
# Generated by Django 3.1.2 on 2020-10-21 19:57
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('auth', '0012_alter_user_first_name_max_length'),
]
operations = [
migrations.CreateModel(
name='CasUser',
fields=[
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to='auth.user')),
],
),
]

View file

@ -30,7 +30,7 @@ def login(req):
"cas_url": reverse("gestiojeux_auth:cas_ng_login"), "cas_url": reverse("gestiojeux_auth:cas_ng_login"),
} }
return render(req, "registration/login_switch.html", context=context) return render(req, "login_switch.html", context=context)
@login_required @login_required

View file

@ -0,0 +1,18 @@
# Generated by Django 3.1.2 on 2020-10-21 19:57
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('inventory', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='game',
name='image',
field=models.ImageField(blank=True, upload_to='game_img/', verbose_name='image'),
),
]

View file

@ -1,4 +1,4 @@
{% extends "base_minimal.html" %} {% extends "base.html" %}
{% block "content" %} {% block "content" %}
<h1>Accès refusé</h1> <h1>Accès refusé</h1>