-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎨 Adds authentication for new style dynamic services and platform ven…
…dor services⚠️ (#6484) Co-authored-by: Andrei Neagu <[email protected]>
- Loading branch information
Showing
17 changed files
with
271 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
packages/pytest-simcore/src/pytest_simcore/dev_vendors_compose.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from pathlib import Path | ||
from typing import Any | ||
|
||
import pytest | ||
|
||
from .helpers.docker import run_docker_compose_config | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def dev_vendors_docker_compose( | ||
osparc_simcore_root_dir: Path, | ||
osparc_simcore_scripts_dir: Path, | ||
env_file_for_testing: Path, | ||
temp_folder: Path, | ||
) -> dict[str, Any]: | ||
docker_compose_path = ( | ||
osparc_simcore_root_dir / "services" / "docker-compose-dev-vendors.yml" | ||
) | ||
assert docker_compose_path.exists() | ||
|
||
return run_docker_compose_config( | ||
project_dir=osparc_simcore_root_dir / "services", | ||
scripts_dir=osparc_simcore_scripts_dir, | ||
docker_compose_paths=docker_compose_path, | ||
env_file_path=env_file_for_testing, | ||
destination_path=temp_folder / "ops_docker_compose.yml", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import json | ||
from typing import Final | ||
|
||
from settings_library.utils_session import DEFAULT_SESSION_COOKIE_NAME | ||
|
||
pytest_plugins = [ | ||
"pytest_simcore.dev_vendors_compose", | ||
"pytest_simcore.docker_compose", | ||
"pytest_simcore.repository_paths", | ||
] | ||
|
||
|
||
_SERVICE_TO_MIDDLEWARE_MAPPING: Final[dict[str, str]] = { | ||
"manual": "pytest-simcore_manual-auth" | ||
} | ||
|
||
|
||
def test_dev_vendors_docker_compose_auth_enabled( | ||
dev_vendors_docker_compose: dict[str, str] | ||
): | ||
|
||
assert isinstance(dev_vendors_docker_compose["services"], dict) | ||
for service_name, service_spec in dev_vendors_docker_compose["services"].items(): | ||
print( | ||
f"Checking vendor service '{service_name}'\n{json.dumps(service_spec, indent=2)}" | ||
) | ||
labels = service_spec["deploy"]["labels"] | ||
|
||
# NOTE: when adding a new service it should also be added to the mapping | ||
auth_middleware_name = _SERVICE_TO_MIDDLEWARE_MAPPING[service_name] | ||
|
||
prefix = f"traefik.http.middlewares.{auth_middleware_name}.forwardauth" | ||
|
||
assert labels[f"{prefix}.trustForwardHeader"] == "true" | ||
assert "http://webserver:8080/v0/auth:check" in labels[f"{prefix}.address"] | ||
assert DEFAULT_SESSION_COOKIE_NAME in labels[f"{prefix}.authResponseHeaders"] | ||
assert ( | ||
auth_middleware_name | ||
in labels["traefik.http.routers.pytest-simcore_manual.middlewares"] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
# NOTE: this stack is only for development and testing of vendor services. | ||
# the actualy code is deployed inside the ops repository. | ||
|
||
services: | ||
|
||
manual: | ||
image: ${VENDOR_DEV_MANUAL_IMAGE} | ||
init: true | ||
hostname: "{{.Node.Hostname}}-{{.Task.Slot}}" | ||
deploy: | ||
replicas: ${VENDOR_DEV_MANUAL_REPLICAS} | ||
labels: | ||
- io.simcore.zone=${TRAEFIK_SIMCORE_ZONE} | ||
- traefik.enable=true | ||
- traefik.docker.network=${SWARM_STACK_NAME}_default | ||
# auth | ||
- traefik.http.middlewares.${SWARM_STACK_NAME}_manual-auth.forwardauth.address=http://${WEBSERVER_HOST}:${WEBSERVER_PORT}/v0/auth:check | ||
- traefik.http.middlewares.${SWARM_STACK_NAME}_manual-auth.forwardauth.trustForwardHeader=true | ||
- traefik.http.middlewares.${SWARM_STACK_NAME}_manual-auth.forwardauth.authResponseHeaders=Set-Cookie,osparc-sc | ||
# routing | ||
- traefik.http.services.${SWARM_STACK_NAME}_manual.loadbalancer.server.port=80 | ||
- traefik.http.services.${SWARM_STACK_NAME}_manual.loadbalancer.healthcheck.path=/ | ||
- traefik.http.services.${SWARM_STACK_NAME}_manual.loadbalancer.healthcheck.interval=2000ms | ||
- traefik.http.services.${SWARM_STACK_NAME}_manual.loadbalancer.healthcheck.timeout=1000ms | ||
- traefik.http.routers.${SWARM_STACK_NAME}_manual.entrypoints=http | ||
- traefik.http.routers.${SWARM_STACK_NAME}_manual.priority=10 | ||
- traefik.http.routers.${SWARM_STACK_NAME}_manual.rule=HostRegexp(`${VENDOR_DEV_MANUAL_SUBDOMAIN}\.(?P<host>.+)`) | ||
- traefik.http.routers.${SWARM_STACK_NAME}_manual.middlewares=${SWARM_STACK_NAME}_gzip@swarm, ${SWARM_STACK_NAME}_manual-auth | ||
networks: | ||
- simcore_default | ||
|
||
networks: | ||
simcore_default: | ||
name: ${SWARM_STACK_NAME}_default | ||
external: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.