Skip to content

Commit

Permalink
Merge branch 'main' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
azmeuk committed Apr 5, 2024
2 parents de3255d + 4f56a58 commit f9d08d9
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 21 deletions.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.poetry]
version = "1.2.0"
name = "b3desk"
version = "1.2.1"
description = "Outil de visioconférence pour les agents de l'Education Nationale et de l'Etat en général."
authors = ["Your Name <[email protected]>"]
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion web/b3desk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from .utils import enum_converter
from .utils import model_converter

__version__ = "1.2.0"
__version__ = "1.2.1"

LANGUAGES = ["en", "fr"]

Expand Down
36 changes: 17 additions & 19 deletions web/b3desk/settings.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import datetime
import json
from typing import Annotated
from typing import Any
from typing import Dict
from typing import List
from typing import Optional

from flask_babel import lazy_gettext as _
from pydantic import BeforeValidator
from pydantic import ValidationInfo
from pydantic import computed_field
from pydantic import field_validator
Expand All @@ -14,6 +16,17 @@

from b3desk.constants import DEFAULT_EMAIL_WHITELIST


def split_comma_separated_strings(value):
if not isinstance(value, str):
return value

return map(str.strip, value.split(","))


ListOfStrings = Annotated[List[str], BeforeValidator(split_comma_separated_strings)]


AVAILABLE_WORDINGS = {
"MEETING": {"cours": "cours", "reunion": "réunion", "seminaire": "séminaire"},
"MEETINGS": {"cours": "cours", "reunion": "réunions", "seminaire": "séminaires"},
Expand Down Expand Up @@ -289,18 +302,14 @@ def get_allowed_mime_types_server_side(
OIDC_OPENID_REALM: str = "apps"
"""Probablement un relicat de flask-oidc, semble inutilisé."""

OIDC_SCOPES: List[str] = ["openid", "email", "profile"]
OIDC_SCOPES: ListOfStrings = ["openid", "email", "profile"]
"""Liste des scopes OpenID Connect pour lesquels une autorisation sera
demandée au serveur d’identité, séparés par des virgules.
Passé en paramètre ``auth_request_params`` de flask-pyoidc.
Plus d’infos sur https://flask-pyoidc.readthedocs.io/en/latest/api.html#module-flask_pyoidc.provider_configuration
"""

@field_validator("OIDC_SCOPES", mode="before")
def get_oidc_scopes(cls, oidc_scopes: List[str], info: ValidationInfo) -> str:
return oidc_scopes.split(",") if isinstance(oidc_scopes, str) else oidc_scopes

OIDC_USERINFO_HTTP_METHOD: str = "POST"
"""Méthode ``GET`` ou ``POST`` à utiliser pour les requêtes sur le point
d’entrée *UserInfo* du serveur d’identité.
Expand Down Expand Up @@ -415,7 +424,7 @@ def get_oidc_scopes(cls, oidc_scopes: List[str], info: ValidationInfo) -> str:
Si non renseigné, prend la valeur de ``OIDC_SERVICE_NAME``.
"""

OIDC_ATTENDEE_SCOPES: Optional[List[str]] = None
OIDC_ATTENDEE_SCOPES: Optional[ListOfStrings] = None
"""Liste des scopes OpenID Connect pour lesquels une autorisation sera
demandée au serveur d’identité des participants authentifiés, séparés par
des virgules.
Expand Down Expand Up @@ -474,8 +483,7 @@ def get_attendee_attendee_service_name(
def get_attendee_attendee_scopes(
cls, attendee_scopes: str, info: ValidationInfo
) -> str:
scopes = attendee_scopes or info.data.get("OIDC_SCOPES")
return scopes.split(",") if isinstance(scopes, str) else scopes
return attendee_scopes or info.data.get("OIDC_SCOPES")

DOCUMENTATION_LINK_URL: Optional[str] = None
"""Surcharge l’adresse de la page de documentation si renseigné."""
Expand Down Expand Up @@ -967,23 +975,13 @@ def get_email_whitelist(
https://docs.bigbluebutton.org/development/api/#create
"""

RIE_NETWORK_IPS: Optional[List[str]] = None
RIE_NETWORK_IPS: Optional[ListOfStrings] = None
"""Plages d’adresses IP du réseau interministériel de l'État.
Affiche un encart particulier pour les utilisateurs se connectant
depuis ce réseau.
"""

@field_validator("RIE_NETWORK_IPS", mode="before")
def get_rie_network_ips(
cls, rie_network_ips: List[str], info: ValidationInfo
) -> str:
return (
rie_network_ips.split(",")
if isinstance(rie_network_ips, str)
else rie_network_ips
)

MAX_PARTICIPANTS: int = 200
"""Nombre moyen de participants indicatif sur la plateforme.
Expand Down
11 changes: 11 additions & 0 deletions web/tests/test_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from b3desk.settings import MainSettings


def test_list_of_strings_type(configuration):
configuration["OIDC_SCOPES"] = "openid, profile, ect.scope.cv"
configuration["OIDC_ATTENDEE_SCOPES"] = "openid, profile, ect.scope.cv"

config_obj = MainSettings.model_validate(configuration)

assert config_obj.OIDC_SCOPES == ["openid", "profile", "ect.scope.cv"]
assert config_obj.OIDC_ATTENDEE_SCOPES == ["openid", "profile", "ect.scope.cv"]

0 comments on commit f9d08d9

Please sign in to comment.