Skip to content

Commit

Permalink
refactor: replace SERVER_FQDN by SERVER_NAME
Browse files Browse the repository at this point in the history
  • Loading branch information
azmeuk committed Feb 21, 2024
1 parent 67d2c0c commit 4c87674
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
3 changes: 2 additions & 1 deletion web.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 0 additions & 7 deletions web/b3desk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 16 additions & 7 deletions web/b3desk/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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."""

Expand Down
2 changes: 1 addition & 1 deletion web/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 4c87674

Please sign in to comment.