diff --git a/services/web/server/src/simcore_service_webserver/statics/_handlers.py b/services/web/server/src/simcore_service_webserver/statics/_handlers.py index eed82fa588c..ecda8a0a83e 100644 --- a/services/web/server/src/simcore_service_webserver/statics/_handlers.py +++ b/services/web/server/src/simcore_service_webserver/statics/_handlers.py @@ -14,15 +14,13 @@ async def get_cached_frontend_index(request: web.Request): - # NOTE: always deliver a front-end product_name = get_product_name(request) assert ( # nosec product_name in FRONTEND_APPS_AVAILABLE ), "Every product is mapped with a front-end app with IDENTICAL name" - # NOTE: CANNOT redirect , i.e. - # raise web.HTTPFound(f"/{target_frontend}/index.html") + # NOTE: CANNOT redirect , i.e. `web.HTTPFound(f"/{target_frontend}/index.html")` # because it losses fragments and therefore it fails in study links. # # SEE services/web/server/tests/unit/isolated/test_redirections.py diff --git a/services/web/server/tests/unit/isolated/test_products_middlewares.py b/services/web/server/tests/unit/isolated/test_products_middlewares.py index e3b91ce67fd..8dbf517492d 100644 --- a/services/web/server/tests/unit/isolated/test_products_middlewares.py +++ b/services/web/server/tests/unit/isolated/test_products_middlewares.py @@ -29,16 +29,22 @@ def mock_postgres_product_table(): column_defaults["login_settings"] = LOGIN_SETTINGS_DEFAULT + _SUBDOMAIN_PREFIX = r"[\w-]+\." + return [ - dict(name="osparc", host_regex=r"([\.-]{0,1}osparc[\.-])", **column_defaults), + dict( + name="osparc", + host_regex=rf"^({_SUBDOMAIN_PREFIX})*osparc[\.-]", + **column_defaults, + ), dict( name="s4l", - host_regex=r"(^s4l[\.-])|(^sim4life\.)|(^api.s4l[\.-])|(^api.sim4life\.)", + host_regex=rf"^({_SUBDOMAIN_PREFIX})*(s4l|sim4life)[\.-]", **column_defaults, ), dict( name="tis", - host_regex=r"(^tis[\.-])|(^ti-solutions\.)", + host_regex=rf"^({_SUBDOMAIN_PREFIX})*(tis|^ti-solutions)[\.-]", vendor={ "name": "ACME", "address": "sesame street", @@ -68,7 +74,6 @@ def mock_app(mock_postgres_product_table: dict[str, Any]) -> web.Application: "request_url,x_product_name_header,expected_product", [ ("https://tis-master.domain.io/", "tis", "tis"), - ("https://s4l-staging.domain.com/v0/", "s4l", "s4l"), ("https://osparc-master.domain.com/v0/projects", None, "osparc"), ("https://s4l.domain.com/", "s4l", "s4l"), ("https://some-valid-but-undefined-product.io/", None, FRONTEND_APP_DEFAULT), @@ -77,10 +82,11 @@ def mock_app(mock_postgres_product_table: dict[str, Any]) -> web.Application: ("https://ti-solutions.io/", "tis", "tis"), ("https://osparc.io/", None, "osparc"), # e.g. an old front-end ("https://staging.osparc.io/", "osparc", "osparc"), + ("https://s4l-staging.domain.com/v0/", "s4l", "s4l"), # new auth of subdomains. SEE https://github.com/ITISFoundation/osparc-simcore/pull/6484 ( - "https://34c878cd-f801-433f-9ddb-7dccba9251af.services.s4l-solutions.com/notebooks/lab", - "s4l", + "https://34c878cd-f801-433f-9ddb-7dccba9251af.services.s4l-staging.domain.com", + None, "s4l", ), ], @@ -99,6 +105,7 @@ async def test_middleware_product_discovery( url = URL(request_url) headers = { "Host": url.host, + "X-Forwarded-Host": url.host, } if x_product_name_header: headers.update({X_PRODUCT_NAME_HEADER: x_product_name_header})