From 85881a5cc576d135d6464cf5ec8cb2e43e8c6376 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sat, 22 Feb 2020 23:44:24 +0100 Subject: [PATCH] Client CAS --- note_kfet/settings/base.py | 3 +++ note_kfet/settings/development.py | 4 ++++ note_kfet/settings/production.py | 3 +++ note_kfet/urls.py | 9 +++++++-- requirements.txt | 1 + 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/note_kfet/settings/base.py b/note_kfet/settings/base.py index 280edd8e..07ab8a27 100644 --- a/note_kfet/settings/base.py +++ b/note_kfet/settings/base.py @@ -57,6 +57,7 @@ INSTALLED_APPS = [ 'dal_select2', # CAS 'cas_server', + 'cas', # Note apps 'activity', @@ -78,6 +79,7 @@ MIDDLEWARE = [ 'django.middleware.locale.LocaleMiddleware', 'django.contrib.sites.middleware.CurrentSiteMiddleware', 'note_kfet.middlewares.TurbolinksMiddleware', + 'cas.middleware.CASMiddleware', ] ROOT_URLCONF = 'note_kfet.urls' @@ -124,6 +126,7 @@ AUTH_PASSWORD_VALIDATORS = [ AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', # this is default 'guardian.backends.ObjectPermissionBackend', + 'cas.backends.CASBackend', ) REST_FRAMEWORK = { diff --git a/note_kfet/settings/development.py b/note_kfet/settings/development.py index 60055ee2..ad2cd2f1 100644 --- a/note_kfet/settings/development.py +++ b/note_kfet/settings/development.py @@ -48,3 +48,7 @@ CSRF_COOKIE_SECURE = False CSRF_COOKIE_HTTPONLY = False X_FRAME_OPTIONS = 'DENY' SESSION_COOKIE_AGE = 60 * 60 * 3 + +# CAS Client settings +# Can be modified in secrets.py +CAS_SERVER_URL = "https://note.comby.xyz/cas/" diff --git a/note_kfet/settings/production.py b/note_kfet/settings/production.py index 296c17a4..353d7b8a 100644 --- a/note_kfet/settings/production.py +++ b/note_kfet/settings/production.py @@ -47,3 +47,6 @@ CSRF_COOKIE_SECURE = False CSRF_COOKIE_HTTPONLY = False X_FRAME_OPTIONS = 'DENY' SESSION_COOKIE_AGE = 60 * 60 * 3 + +# CAS Client settings +CAS_SERVER_URL = "https://note.crans.org/cas/" diff --git a/note_kfet/urls.py b/note_kfet/urls.py index c9c09b64..ce2c745a 100644 --- a/note_kfet/urls.py +++ b/note_kfet/urls.py @@ -1,6 +1,7 @@ # Copyright (C) 2018-2020 by BDE ENS Paris-Saclay # SPDX-License-Identifier: GPL-3.0-or-later +from cas import views as cas_views from django.contrib import admin from django.urls import path, include from django.views.generic import RedirectView @@ -12,6 +13,10 @@ urlpatterns = [ # Include project routers path('note/', include('note.urls')), + # Include CAS Client routers + path('accounts/login/', cas_views.login, name='login'), + path('accounts/logout/', cas_views.logout, name='logout'), + # Include Django Contrib and Core routers path('i18n/', include('django.conf.urls.i18n')), path('accounts/', include('member.urls')), @@ -19,8 +24,8 @@ urlpatterns = [ path('admin/doc/', include('django.contrib.admindocs.urls')), path('admin/', admin.site.urls), - # Include CAS routers - path(r'cas/', include('cas_server.urls', namespace="cas_server")), + # Include CAS Server routers + path('cas/', include('cas_server.urls', namespace="cas_server")), # Include Django REST API path('api/', include('api.urls')), diff --git a/requirements.txt b/requirements.txt index 2bc32fff..244690bc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,6 +4,7 @@ defusedxml==0.6.0 Django~=2.2 django-allauth==0.39.1 django-autocomplete-light==3.5.1 +django-cas-client==1.5.3 django-cas-server==1.1.0 django-crispy-forms==1.7.2 django-extensions==2.1.9