Skip to content

Commit 43e2baa

Browse files
authored
Merge pull request #6177 from tenevdev/feat-tls-options-self-signed
[WIP] feat: configure traefik self-signed TLS
2 parents 33370b9 + c8876d1 commit 43e2baa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+759
-735
lines changed

.github/workflows/stack-integration_tests.yml

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,81 @@ jobs:
8181
run: |
8282
tox -e stack.test.integration
8383
84+
stack-integration-tests-tls:
85+
strategy:
86+
max-parallel: 3
87+
matrix:
88+
os: [ubuntu-latest]
89+
python-version: [3.9]
90+
91+
runs-on: ${{matrix.os}}
92+
93+
steps:
94+
- uses: actions/checkout@v2
95+
96+
- name: Check for file changes
97+
uses: dorny/paths-filter@v2
98+
id: changes
99+
with:
100+
token: ${{ github.token }}
101+
filters: .github/file-filters.yml
102+
103+
- name: Set up Python ${{ matrix.python-version }}
104+
uses: actions/setup-python@v2
105+
if: steps.changes.outputs.stack == 'true'
106+
with:
107+
python-version: ${{ matrix.python-version }}
108+
109+
- name: Get pip cache dir
110+
if: steps.changes.outputs.stack == 'true'
111+
id: pip-cache
112+
run: |
113+
echo "::set-output name=dir::$(pip cache dir)"
114+
115+
- name: pip cache
116+
uses: actions/cache@v2
117+
if: steps.changes.outputs.stack == 'true'
118+
with:
119+
path: ${{ steps.pip-cache.outputs.dir }}
120+
key: ${{ runner.os }}-pip-py${{ matrix.python-version }}
121+
restore-keys: |
122+
${{ runner.os }}-pip-py${{ matrix.python-version }}
123+
124+
- name: Upgrade pip
125+
if: steps.changes.outputs.stack == 'true'
126+
run: |
127+
pip install --upgrade --user pip
128+
129+
- name: Install tox
130+
if: steps.changes.outputs.stack == 'true'
131+
run: |
132+
pip install tox --upgrade
133+
134+
- name: Install Docker Compose
135+
if: runner.os == 'Linux'
136+
shell: bash
137+
run: |
138+
mkdir -p ~/.docker/cli-plugins
139+
DOCKER_COMPOSE_VERSION=v2.1.1
140+
curl -sSL https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose
141+
chmod +x ~/.docker/cli-plugins/docker-compose
142+
143+
- name: Install mkcert
144+
if: runner.os == 'Linux'
145+
shell: bash
146+
run: |
147+
sudo apt install libnss3-tools -y
148+
MKCERT_VERSION=v1.4.3
149+
curl -sSL https://github.com/FiloSottile/mkcert/releases/download/${MKCERT_VERSION}/mkcert-${MKCERT_VERSION}-linux-amd64 -o /usr/local/bin/mkcert
150+
chmod +x /usr/local/bin/mkcert
151+
which mkcert
152+
153+
- name: Run integration tests
154+
if: steps.changes.outputs.stack == 'true'
155+
timeout-minutes: 30
156+
run: |
157+
tox -e stack.test.integration.tls
158+
84159
stack-integration-tests-windows:
85160
strategy:
86161
max-parallel: 3
@@ -155,7 +230,7 @@ jobs:
155230
pip install -e packages/hagrid
156231
set HAGRID_ART=false
157232
hagrid launch test_network_1 network to docker:9081 --tail=false --headless=true
158-
hagrid launch test_domain_1 domain to docker:9082 --tail=false --build=false --headless=true
233+
hagrid launch test_domain_1 domain to docker:9082 --tail=false --headless=true
159234
hagrid launch test_domain_2 domain to docker:9083 --tail=false --build=false --headless=true
160235
bash -c "(docker logs test_domain_1-backend_stream-1 -f &) | grep -q 'Application startup complete' || true"
161236
bash -c "(docker logs test_domain_2-backend_stream-1 -f &) | grep -q 'Application startup complete' || true"

packages/grid/.env

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#!/bin/bash
22
DOMAIN=localhost
3-
DOMAIN_NAME=grid.openmined.org
3+
DOMAIN_NAME=default_node_name
44
NODE_TYPE=domain
5-
DOMAIN_PORT=80
5+
HTTP_PORT=80
6+
HTTPS_PORT=443
67
HEADSCALE_PORT=8080
78
NETWORK_NAME=omnet
9+
IGNORE_TLS_ERRORS=False
810

911
STACK_NAME=grid-openmined-org
1012
TRAEFIK_PUBLIC_NETWORK=traefik-public
@@ -15,6 +17,7 @@ DOCKER_IMAGE_BACKEND=openmined/grid-backend
1517
DOCKER_IMAGE_FRONTEND=openmined/grid-frontend
1618
DOCKER_IMAGE_HEADSCALE=openmined/grid-vpn-headscale
1719
DOCKER_IMAGE_TAILSCALE=openmined/grid-vpn-tailscale
20+
DOCKER_IMAGE_TRAEFIK=traefik:v2.5
1821
VERSION=latest
1922
VERSION_HASH=unknown
2023
STACK_API_KEY=hex_key_value
@@ -31,7 +34,7 @@ SMTP_HOST=
3134
SMTP_USER=
3235
SMTP_PASSWORD=
3336
EMAILS_FROM_EMAIL=[email protected]
34-
SERVER_HOST="http://${DOMAIN}"
37+
SERVER_HOST="https://${DOMAIN}"
3538

3639
USERS_OPEN_REGISTRATION=False
3740

packages/grid/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ packer/output/*
99
packer/packer_cache/*
1010
packer/base-manifest.json
1111
packer/azure_vars.json
12+
tls/
1213

1314
# devspace
14-
.devspace/
15+
.devspace/

packages/grid/.gitlab-ci.yml

Lines changed: 0 additions & 74 deletions
This file was deleted.

packages/grid/backend/grid/api/meta/ping.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
# syft absolute
1313
from syft.core.node.common.node_service.ping.ping_messages import PingMessageWithReply
14+
from syft.grid import GridURL
1415

1516
# grid absolute
1617
from grid.api.dependencies.current_user import get_current_user
@@ -27,7 +28,7 @@ def remote_ping(
2728

2829
# Build Syft Message
2930
msg = (
30-
PingMessageWithReply(kwargs={"host_or_ip": host_or_ip})
31+
PingMessageWithReply(kwargs={"grid_url": GridURL.from_url(host_or_ip)})
3132
.to(address=node.address, reply_to=node.address)
3233
.sign(signing_key=user_key)
3334
)

packages/grid/backend/grid/api/vpn/vpn.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
VPNStatusMessageWithReply,
2222
)
2323
from syft.core.node.common.node_service.vpn.vpn_messages import VPNJoinMessageWithReply
24+
from syft.grid import GridURL
2425
from syft.lib.python.util import upcast
2526

2627
# grid absolute
@@ -44,7 +45,7 @@ def connect(
4445
msg = (
4546
VPNConnectMessageWithReply(
4647
kwargs={
47-
"host_or_ip": host_or_ip,
48+
"grid_url": GridURL.from_url(host_or_ip),
4849
"vpn_auth_key": vpn_auth_key,
4950
}
5051
)
@@ -72,7 +73,7 @@ def join(
7273
) -> Dict[str, Any]:
7374
user_key = SigningKey(current_user.private_key.encode(), encoder=HexEncoder)
7475
msg = (
75-
VPNJoinMessageWithReply(kwargs={"host_or_ip": host_or_ip})
76+
VPNJoinMessageWithReply(kwargs={"grid_url": GridURL.from_url(host_or_ip)})
7677
.to(address=node.address, reply_to=node.address)
7778
.sign(signing_key=user_key)
7879
)

packages/grid/backend/grid/core/config.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class Settings(BaseSettings):
2020
SECRET_KEY: str = secrets.token_urlsafe(32)
2121
# 60 minutes * 24 hours * 8 days = 8 days
2222
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 8
23-
SERVER_NAME: str = "unconfigured"
2423
SERVER_HOST: str = "https://localhost"
2524
# BACKEND_CORS_ORIGINS is a JSON-formatted list of origins
2625
# e.g: '["http://localhost", "http://localhost:4200", "http://localhost:3000", \
@@ -93,7 +92,7 @@ def get_emails_enabled(cls, v: bool, values: Dict[str, Any]) -> bool:
9392
FIRST_SUPERUSER_PASSWORD: str = "changethis"
9493
USERS_OPEN_REGISTRATION: bool = False
9594

96-
DOMAIN_NAME: str = "grid_domain"
95+
DOMAIN_NAME: str = "default_node_name"
9796
STREAM_QUEUE: bool = False
9897
NODE_TYPE: str = "Domain"
9998

packages/grid/backend/grid/tests/conftest.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# stdlib
22
import logging
3-
import os
43
from typing import Generator
54

65
# third party
@@ -56,17 +55,3 @@ def emit(self, record: logging.LogRecord) -> None:
5655
sink_handler_id = logger.add(PropagateHandler(), format=log_handler.format_record)
5756
yield caplog
5857
logger.remove(sink_handler_id)
59-
60-
61-
# patch windows to use uft-8 output
62-
if os.name == "nt":
63-
try:
64-
print("Patching Windows Default Locale to use UTF-8")
65-
# third party
66-
import _locale
67-
68-
_locale._gdl_bak = _locale._getdefaultlocale
69-
_locale._getdefaultlocale = lambda *args: (_locale._gdl_bak()[0], "utf8")
70-
print("Finished Patching Windows Default Locale to use UTF-8")
71-
except Exception as e:
72-
print(f"Failed to patch Windows Default Locale. {e}")

packages/grid/devspace.yaml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,6 @@ deployments:
148148
successThreshold: 1
149149
failureThreshold: 3
150150
env:
151-
- name: SYFT_USE_UVLOOP
152-
value: "0"
153151
- name: DOMAIN_NAME
154152
value: ${DOMAIN_NAME}
155153
- name: POSTGRES_SERVER
@@ -164,14 +162,14 @@ deployments:
164162
value: ${VERSION}
165163
- name: VERSION_HASH
166164
value: ${VERSION_HASH}
167-
- name: SERVER_NAME
168-
value: ${DOMAIN}
169165
- name: SERVER_HOST
170166
value: ${SERVER_HOST}
171167
- name: LOG_LEVEL
172168
value: debug
173169
- name: NODE_TYPE
174170
value: ${NODE_TYPE}
171+
- name: STACK_API_KEY
172+
value: ${STACK_API_KEY}
175173
service:
176174
name: ${SERVICE_NAME_BACKEND}
177175
ports:
@@ -209,8 +207,6 @@ deployments:
209207
successThreshold: 1
210208
failureThreshold: 3
211209
env:
212-
- name: SYFT_USE_UVLOOP
213-
value: "0"
214210
- name: DOMAIN_NAME
215211
value: ${DOMAIN_NAME}
216212
- name: POSTGRES_SERVER
@@ -225,8 +221,6 @@ deployments:
225221
value: ${VERSION}
226222
- name: VERSION_HASH
227223
value: ${VERSION_HASH}
228-
- name: SERVER_NAME
229-
value: ${DOMAIN}
230224
- name: SERVER_HOST
231225
value: ${SERVER_HOST}
232226
- name: LOG_LEVEL
@@ -235,6 +229,8 @@ deployments:
235229
value: "1"
236230
- name: NODE_TYPE
237231
value: ${NODE_TYPE}
232+
- name: STACK_API_KEY
233+
value: ${STACK_API_KEY}
238234
service:
239235
name: ${SERVICE_NAME_BACKEND_STREAM}
240236
ports:
@@ -256,8 +252,6 @@ deployments:
256252
"/worker-start.sh",
257253
]
258254
env:
259-
- name: SYFT_USE_UVLOOP
260-
value: "0"
261255
- name: DOMAIN_NAME
262256
value: ${DOMAIN_NAME}
263257
- name: POSTGRES_SERVER
@@ -272,8 +266,6 @@ deployments:
272266
value: ${VERSION}
273267
- name: VERSION_HASH
274268
value: ${VERSION_HASH}
275-
- name: SERVER_NAME
276-
value: ${DOMAIN}
277269
- name: SERVER_HOST
278270
value: ${SERVER_HOST}
279271
- name: CELERY_WORKER
@@ -284,6 +276,8 @@ deployments:
284276
value: ${NODE_TYPE}
285277
- name: C_FORCE_ROOT
286278
value: "1"
279+
- name: STACK_API_KEY
280+
value: ${STACK_API_KEY}
287281
- name: frontend
288282
helm:
289283
componentChart: true
@@ -295,7 +289,7 @@ deployments:
295289
value: ${VERSION}
296290
- name: VERSION_HASH
297291
value: ${VERSION_HASH}
298-
- name: TYPE
292+
- name: NODE_TYPE
299293
value: ${NODE_TYPE}
300294
service:
301295
name: ${SERVICE_NAME_FRONTEND}
@@ -310,6 +304,8 @@ deployments:
310304
env:
311305
- name: NETWORK_NAME
312306
value: ${NETWORK_NAME}
307+
- name: STACK_API_KEY
308+
value: ${STACK_API_KEY}
313309
volumeMounts:
314310
- containerPath: /headscale/data
315311
volume:
@@ -339,6 +335,8 @@ deployments:
339335
env:
340336
- name: HOSTNAME
341337
value: ${DOMAIN_NAME}
338+
- name: STACK_API_KEY
339+
value: ${STACK_API_KEY}
342340
volumeMounts:
343341
- containerPath: /var/lib/tailscale
344342
volume:

0 commit comments

Comments
 (0)