-
Notifications
You must be signed in to change notification settings - Fork 29
🎨 Adds authentication for new style dynamic services and platform vendor services ⚠️ #6484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
GitHK
merged 40 commits into
ITISFoundation:master
from
GitHK:pr-osparc-manual-for-logged-in-users
Oct 8, 2024
Merged
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
37162be
added mock unauthenticated manual service
85733af
cookies
0b53e9f
exposed manual
61a396c
dynamic-sidecar is now authenticated
9aa2728
extended EncryptedCookieStorage
9fb2a08
Merge remote-tracking branch 'upstream/master' into pr-osparc-manual-…
4673a62
using lightweight auth check endpoint
eb94357
director-v2 reads webserver endpoint form env vars
4445b34
refactor
1252409
link with cookie name
c8e8152
readme
5d8e115
fixed failing tests
e0c3398
added test for /auth:check
4f472d5
added notes for the future
05d93d3
refactor
3a69ec9
Merge remote-tracking branch 'upstream/master' into pr-osparc-manual-…
fe002fd
simplify service declaration
20a4145
ignore manual
8507df7
moved to vendors stack
212af33
extracted env vars to configure manual service
e6642b7
remove
199814b
Merge remote-tracking branch 'upstream/master' into pr-osparc-manual-…
132845b
disable manual by default
9fabb8a
Merge remote-tracking branch 'upstream/master' into pr-osparc-manual-…
d4f8626
revert this change
b51e457
fix failing tests
8e35dfc
Merge remote-tracking branch 'upstream/master' into pr-osparc-manual-…
3f2c54c
revert
066cf32
Merge remote-tracking branch 'upstream/master' into pr-osparc-manual-…
54dcd5f
refactor placement of services in stacks
4b4ba17
string refenreces
626307e
rename
12d1360
refactor interface
ef6b17f
added new tests and fixtures
1eb0ab0
refactor
62e96c3
fixed broken tests
bbb5ec9
Merge branch 'master' into pr-osparc-manual-for-logged-in-users
GitHK 7aa314f
fixed broken test
752a2a6
finally fixed test
cf4b23f
Merge branch 'pr-osparc-manual-for-logged-in-users' of github.com:Git…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 | ||
GitHK marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.