CAS: synchro configuration

This commit is contained in:
Emmanuel Viennet 2023-02-26 21:36:25 +01:00
parent d8a7f8affa
commit 5b8b474d5c
2 changed files with 4 additions and 2 deletions

View File

@ -56,11 +56,12 @@ def after_cas_logout():
return flask.redirect(url_for("scodoc.index")) return flask.redirect(url_for("scodoc.index"))
def set_cas_configuration(app: flask.app.Flask): def set_cas_configuration(app: flask.app.Flask = None):
"""Force la configuration du module flask_cas à partir des paramètres de """Force la configuration du module flask_cas à partir des paramètres de
la config de ScoDoc. la config de ScoDoc.
Appelé au démarrage et à chaque modif des paramètres. Appelé au démarrage et à chaque modif des paramètres.
""" """
app = app or current_app
if ScoDocSiteConfig.is_cas_enabled(): if ScoDocSiteConfig.is_cas_enabled():
app.config["CAS_SERVER"] = ScoDocSiteConfig.get("cas_server") app.config["CAS_SERVER"] = ScoDocSiteConfig.get("cas_server")
app.config["CAS_AFTER_LOGIN"] = "auth.after_cas_login" app.config["CAS_AFTER_LOGIN"] = "auth.after_cas_login"

View File

@ -54,6 +54,7 @@ from werkzeug.exceptions import BadRequest, NotFound
from app import db from app import db
from app.auth.models import User from app.auth.models import User
from app.auth.cas import set_cas_configuration
from app.decorators import ( from app.decorators import (
admin_required, admin_required,
scodoc7func, scodoc7func,
@ -149,7 +150,7 @@ def config_cas():
flash("Serveur CAS enregistré") flash("Serveur CAS enregistré")
if ScoDocSiteConfig.set("cas_attribute_id", form.data["cas_attribute_id"]): if ScoDocSiteConfig.set("cas_attribute_id", form.data["cas_attribute_id"]):
flash("Serveur CAS enregistré") flash("Serveur CAS enregistré")
set_cas_configuration()
return redirect(url_for("scodoc.configuration")) return redirect(url_for("scodoc.configuration"))
elif request.method == "GET": elif request.method == "GET":
form.cas_enable.data = ScoDocSiteConfig.get("cas_enable") form.cas_enable.data = ScoDocSiteConfig.get("cas_enable")