forked from ScoDoc/ScoDoc
CAS: config routes login/logout/validate
This commit is contained in:
parent
6ec4011a3d
commit
e02db2a751
@ -85,6 +85,13 @@ def set_cas_configuration(app: flask.app.Flask = None):
|
||||
if ScoDocSiteConfig.is_cas_enabled():
|
||||
current_app.logger.debug("CAS: set_cas_configuration")
|
||||
app.config["CAS_SERVER"] = ScoDocSiteConfig.get("cas_server")
|
||||
app.config["CAS_LOGIN_ROUTE"] = ScoDocSiteConfig.get("cas_login_route", "/cas")
|
||||
app.config["CAS_LOGOUT_ROUTE"] = ScoDocSiteConfig.get(
|
||||
"cas_logout_route", "/cas/logout"
|
||||
)
|
||||
app.config["CAS_VALIDATE_ROUTE"] = ScoDocSiteConfig.get(
|
||||
"cas_validate_route", "/cas/serviceValidate"
|
||||
)
|
||||
app.config["CAS_AFTER_LOGIN"] = "auth.after_cas_login"
|
||||
app.config["CAS_AFTER_LOGOUT"] = "auth.after_cas_logout"
|
||||
app.config["CAS_ERROR_CALLBACK"] = cas_error_callback
|
||||
|
@ -45,6 +45,21 @@ class ConfigCASForm(FlaskForm):
|
||||
label="URL du serveur CAS",
|
||||
description="""url complète. Commence en général par <tt>https://</tt>.""",
|
||||
)
|
||||
cas_login_route = StringField(
|
||||
label="Route du login CAS",
|
||||
description="""ajouté à l'URL du serveur: exemple <tt>/cas</tt> (si commence par <tt>/</tt>, part de la racine)""",
|
||||
default="/cas",
|
||||
)
|
||||
cas_logout_route = StringField(
|
||||
label="Route du logout CAS",
|
||||
description="""ajouté à l'URL du serveur: exemple <tt>/cas/logout</tt>""",
|
||||
default="/cas/logout",
|
||||
)
|
||||
cas_validate_route = StringField(
|
||||
label="Route de validation CAS",
|
||||
description="""ajouté à l'URL du serveur: exemple <tt>/cas/serviceValidate</tt>""",
|
||||
default="/cas/serviceValidate",
|
||||
)
|
||||
|
||||
cas_attribute_id = StringField(
|
||||
label="Attribut CAS utilisé comme id (laissez vide pour prendre l'id par défaut)",
|
||||
|
@ -90,6 +90,9 @@ class ScoDocSiteConfig(db.Model):
|
||||
# CAS
|
||||
"cas_enable": bool,
|
||||
"cas_server": str,
|
||||
"cas_login_route": str,
|
||||
"cas_logout_route": str,
|
||||
"cas_valmidate_route": str,
|
||||
"cas_attribute_id": str,
|
||||
}
|
||||
|
||||
@ -237,10 +240,12 @@ class ScoDocSiteConfig(db.Model):
|
||||
return False
|
||||
|
||||
@classmethod
|
||||
def get(cls, name: str) -> str:
|
||||
"Get configuration param; empty string if unset"
|
||||
def get(cls, name: str, default: str = "") -> str:
|
||||
"Get configuration param; empty string or specified default if unset"
|
||||
cfg = ScoDocSiteConfig.query.filter_by(name=name).first()
|
||||
return (cfg.value or "") if cfg else ""
|
||||
if cfg is None:
|
||||
return default
|
||||
return cfg.value or ""
|
||||
|
||||
@classmethod
|
||||
def set(cls, name: str, value: str) -> bool:
|
||||
|
@ -150,6 +150,12 @@ def config_cas():
|
||||
flash("CAS " + ("forcé" if form.data["cas_force"] else "non forcé"))
|
||||
if ScoDocSiteConfig.set("cas_server", form.data["cas_server"]):
|
||||
flash("Serveur CAS enregistré")
|
||||
if ScoDocSiteConfig.set("cas_login_route", form.data["cas_login_route"]):
|
||||
flash("Serveur CAS enregistré")
|
||||
if ScoDocSiteConfig.set("cas_logout_route", form.data["cas_logout_route"]):
|
||||
flash("Serveur CAS enregistré")
|
||||
if ScoDocSiteConfig.set("cas_validate_route", form.data["cas_validate_route"]):
|
||||
flash("Serveur CAS enregistré")
|
||||
if ScoDocSiteConfig.set("cas_attribute_id", form.data["cas_attribute_id"]):
|
||||
flash("Serveur CAS enregistré")
|
||||
if ScoDocSiteConfig.set("cas_ssl_verify", form.data["cas_ssl_verify"]):
|
||||
|
@ -928,6 +928,31 @@ def partition_editor(formsemestre_id: int):
|
||||
return "\n".join(H)
|
||||
|
||||
|
||||
# Future page pour répartition parcours
|
||||
@bp.route("/students_groups_auto_assignment", methods=["GET", "POST"])
|
||||
@scodoc
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func
|
||||
def students_groups_auto_assignment(formsemestre_id: int):
|
||||
"""En cours de dev."""
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
H = [
|
||||
html_sco_header.sco_header(
|
||||
page_title=f"DEV",
|
||||
),
|
||||
f"""<h2>
|
||||
</h2>
|
||||
""",
|
||||
render_template(
|
||||
"scolar/students_groups_auto_assignment.j2",
|
||||
formsemestre=formsemestre,
|
||||
),
|
||||
html_sco_header.sco_footer(),
|
||||
]
|
||||
|
||||
return "\n".join(H)
|
||||
|
||||
|
||||
@bp.route("/create_partition_parcours", methods=["GET", "POST"])
|
||||
@scodoc
|
||||
@permission_required(Permission.ScoView)
|
||||
|
@ -49,7 +49,6 @@ def login():
|
||||
_external=True,
|
||||
),
|
||||
)
|
||||
|
||||
if "ticket" in flask.request.args:
|
||||
flask.session[cas_token_session_key] = flask.request.args["ticket"]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user