-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mTLS support for Python sync actions (CFT-3328)
- Loading branch information
Showing
13 changed files
with
222 additions
and
76 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ vendor/ | |
__pycache__/ | ||
docker/keys/* | ||
!docker/keys/genkeys.sh | ||
!docker/keys/keys-to-config-json.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 @@ | ||
3.12 |
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 |
---|---|---|
@@ -1,12 +1,17 @@ | ||
cd keys | ||
echo "creating rootCA" | ||
openssl genrsa -out rootCA.key 4096 | ||
openssl req -x509 -new -nodes -key rootCA.key -subj "/C=CZ/ST=CZ/O=authority" -days 1024 -out rootCA.crt | ||
|
||
echo "creating server keys" | ||
openssl genrsa -out server.key 2048 | ||
openssl req -new -key server.key -subj "/C=CZ/ST=CZ/O=mytest/CN=server.local" -out server.csr # CN = server.local name of service | ||
openssl x509 -req -in server.csr -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out server.crt -days 500 | ||
# SAN is required as it is the main place where modern clients check host name (in fact CN can be ignored -- and is by e.g. chrome or requests) | ||
openssl req -new -key server.key -subj "/C=CZ/ST=CZ/O=mytest/CN=server.local" -addext "subjectAltName=DNS:server.local" -out server.csr | ||
# Extensions such as SAN are not coppied by default from CSR when creating the certificate, -copy_extensions is required (semi-recent addition to OpenSSL) | ||
openssl x509 -req -in server.csr -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out server.crt -days 500 -copy_extensions copy | ||
|
||
echo "creating client keys" | ||
openssl genrsa -out client.key 2048 | ||
openssl req -new -key client.key -subj "/C=CZ/ST=CZ/O=mytest/CN=dev" -out client.csr # CN = dev name of service | ||
openssl x509 -req -in client.csr -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out client.crt -days 500 | ||
openssl req -new -key client.key -subj "/C=CZ/ST=CZ/O=mytest/CN=client.local" -addext "subjectAltName=DNS:client.local" -out client.csr | ||
openssl x509 -req -in client.csr -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out client.crt -days 500 -copy_extensions copy | ||
|
||
python3 keys-to-config-json.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,26 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import json | ||
|
||
|
||
with open("rootCA.crt") as f: | ||
ca_cert = f.read() | ||
|
||
with open("client.crt") as f: | ||
client_cert = f.read() | ||
|
||
with open("client.key") as f: | ||
client_key = f.read() | ||
|
||
with open("config.json", "w") as f: | ||
json.dump( | ||
{ | ||
"api": { | ||
"baseUrl": "https://server.local/", | ||
"caCertificate": ca_cert, | ||
"#clientCertificate": client_cert + client_key, | ||
} | ||
}, | ||
f, | ||
indent=4, | ||
) |
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 |
---|---|---|
@@ -1,25 +1,19 @@ | ||
FROM nikolaik/python-nodejs:python3.12-nodejs18 | ||
ENV PYTHONIOENCODING utf-8 | ||
|
||
COPY /src /code/src/ | ||
COPY /tests /code/tests/ | ||
COPY requirements.txt /code/requirements.txt | ||
COPY flake8.cfg /code/flake8.cfg | ||
|
||
# install gcc to be able to build packages - e.g. required by regex, dateparser, also required for pandas | ||
RUN apt-get update && apt-get install -y build-essential curl | ||
RUN apt-get update && apt-get install -y curl | ||
|
||
# Install curlconverter using npm | ||
RUN npm install --global curlconverter | ||
|
||
|
||
RUN pip install flake8 | ||
|
||
COPY requirements.txt /code/requirements.txt | ||
RUN pip install -r /code/requirements.txt | ||
|
||
COPY flake8.cfg /code/flake8.cfg | ||
|
||
COPY /src /code/src/ | ||
COPY /tests /code/tests/ | ||
|
||
WORKDIR /code/ | ||
|
||
|
||
CMD ["python", "-u", "/code/src/component.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
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,9 @@ | ||
keboola.component | ||
dataconf | ||
keboola.http-client | ||
keboola.utils | ||
keboola.json-to-csv==0.0.12 | ||
mock==5.1.0 | ||
freezegun==1.5.1 | ||
nested-lookup==0.2.25 | ||
python-dateutil==2.9.0.post0 |
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 |
---|---|---|
@@ -1,9 +1,68 @@ | ||
keboola.component==1.6.8 | ||
# This file was autogenerated by uv via the following command: | ||
# uv pip compile requirements.txt --universal --output-file requirements.all | ||
certifi==2025.1.31 | ||
# via requests | ||
charset-normalizer==3.4.1 | ||
# via requests | ||
dataconf==3.3.0 | ||
keboola.http-client==1.0.1 | ||
keboola.utils==1.1.0 | ||
keboola.json-to-csv==0.0.12 | ||
mock==5.1.0 | ||
# via -r requirements.txt | ||
dateparser==1.2.0 | ||
# via keboola-utils | ||
deprecated==1.2.18 | ||
# via keboola-component | ||
freezegun==1.5.1 | ||
# via -r requirements.txt | ||
idna==3.10 | ||
# via requests | ||
isodate==0.6.1 | ||
# via dataconf | ||
keboola-component==1.6.8 | ||
# via -r requirements.txt | ||
keboola-http-client==1.0.1 | ||
# via -r requirements.txt | ||
keboola-json-to-csv==0.0.12 | ||
# via -r requirements.txt | ||
keboola-utils==1.1.0 | ||
# via -r requirements.txt | ||
mock==5.1.0 | ||
# via -r requirements.txt | ||
nested-lookup==0.2.25 | ||
# via -r requirements.txt | ||
pygelf==0.4.2 | ||
# via keboola-component | ||
pyhocon==0.3.61 | ||
# via dataconf | ||
pyparsing==3.2.1 | ||
# via | ||
# dataconf | ||
# pyhocon | ||
python-dateutil==2.9.0.post0 | ||
# via | ||
# -r requirements.txt | ||
# dataconf | ||
# dateparser | ||
# freezegun | ||
pytz==2025.1 | ||
# via | ||
# dateparser | ||
# keboola-component | ||
# keboola-utils | ||
pyyaml==6.0.2 | ||
# via dataconf | ||
regex==2024.11.6 | ||
# via dateparser | ||
requests==2.32.3 | ||
# via keboola-http-client | ||
six==1.17.0 | ||
# via | ||
# isodate | ||
# nested-lookup | ||
# python-dateutil | ||
tzdata==2025.1 ; sys_platform == 'win32' | ||
# via tzlocal | ||
tzlocal==5.2 | ||
# via dateparser | ||
urllib3==2.3.0 | ||
# via requests | ||
wrapt==1.17.2 | ||
# via deprecated |
Oops, something went wrong.