From 4c876749e1561c06bff52d7c7f11f6609ffab59d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89loi=20Rivard?= Date: Wed, 21 Feb 2024 11:31:16 +0100 Subject: [PATCH] refactor: replace SERVER_FQDN by SERVER_NAME --- web.env.example | 3 ++- web/b3desk/__init__.py | 7 ------- web/b3desk/settings.py | 23 ++++++++++++++++------- web/tests/conftest.py | 2 +- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/web.env.example b/web.env.example index 3577d02f..18e510e6 100644 --- a/web.env.example +++ b/web.env.example @@ -2,7 +2,8 @@ FLASK_DEBUG=True SECRET_KEY=SomethingNotEntirelySecret TITLE=BBB-Visio -SERVER_FQDN=http://localhost:5000 +SERVER_NAME=localhost:5000 +PREFERRED_URL_SCHEME=http WTF_CSRF_TIME_LIMIT=3600 STATS_URL=http://localhost:5000/static/local/stats.csv diff --git a/web/b3desk/__init__.py b/web/b3desk/__init__.py index e746142a..7e6c4bf3 100644 --- a/web/b3desk/__init__.py +++ b/web/b3desk/__init__.py @@ -45,13 +45,6 @@ def setup_configuration(app, config=None): config_obj = MainSettings.model_validate(config or {}) app.config.from_object(config_obj) - # TODO: properly deprecate and remove "SERVER_FQDN" in favor of "SERVER_NAME" - # https://flask.palletsprojects.com/en/3.0.x/config/#SERVER_NAME - if not app.config.get("SERVER_NAME"): - app.config["SERVER_NAME"] = ( - app.config["SERVER_FQDN"].replace("http://", "").replace("https://", "") - ) - def setup_celery(app): from b3desk.tasks import celery diff --git a/web/b3desk/settings.py b/web/b3desk/settings.py index fe630177..ce0c5b6a 100644 --- a/web/b3desk/settings.py +++ b/web/b3desk/settings.py @@ -118,6 +118,22 @@ class MainSettings(BaseSettings): https://flask.palletsprojects.com/en/3.0.x/config/#SECRET_KEY """ + SERVER_NAME: str + """Le nom de domaine sur lequel est déployé l'instance B3Desk. + + Par exemple ``b3desk.example.org``, sans `https://`. + + Plus d'infos sur https://flask.palletsprojects.com/en/3.0.x/config/#SERVER_NAME. + """ + + PREFERRED_URL_SCHEME: str = "https" + """La méthode préférée utilisée pour générer des URL. Peut être `http` ou + `https`. + + Plus d'infos sur + https://flask.palletsprojects.com/en/3.0.x/config/#PREFERRED_URL_SCHEME. + """ + REDIS_URL: Optional[str] = None """L’URL du serveur redis utilisé pour les tâches asynchrones. @@ -174,13 +190,6 @@ class MainSettings(BaseSettings): TITLE: str = "BBB-Visio" """Titre HTML par défaut pour les pages HTML.""" - # TODO: Replace this with SERVER_NAME + url_for(..., _external=True) - SERVER_FQDN: str - """L’adresse publique du serveur B3Desk. - - Par exemple ``https://b3desk.example.org``. - """ - EXTERNAL_UPLOAD_DESCRIPTION: str = "Fichiers depuis votre Nextcloud" """Description dans BBB des fichiers téléversés dans Nextcloud.""" diff --git a/web/tests/conftest.py b/web/tests/conftest.py index 9f34bb98..e598fd40 100644 --- a/web/tests/conftest.py +++ b/web/tests/conftest.py @@ -41,8 +41,8 @@ def configuration(tmp_path, iam_server, iam_client, smtpd): smtpd.config.use_starttls = True return { "SECRET_KEY": "test-secret-key", - "SERVER_FQDN": "http://localhost:5000", "SERVER_NAME": "localhost:5000", + "PREFERRED_URL_SCHEME": "http", "SQLALCHEMY_DATABASE_URI": "sqlite:///:memory:", "WTF_CSRF_ENABLED": False, "TESTING": True,