Loading Dockerfile 0 → 100644 +15 −0 Original line number Diff line number Diff line FROM python:3-alpine # RUN mkdir -p /usr/src/app WORKDIR /usr/src/app COPY requirements.txt /usr/src/app/requirements.txt RUN apk add -U --no-cache gcc build-base linux-headers ca-certificates libffi-dev libressl-dev libxslt-dev RUN pip3 install --no-cache-dir -r requirements.txt COPY . /usr/src/app EXPOSE 8080 ENTRYPOINT ["python3", "main.py"] README.md +5 −16 Original line number Diff line number Diff line Loading @@ -25,22 +25,6 @@ This python script Creates a csr request, sends it to CAPIF to be signed, and ge pip3 install -r requirements.txt ``` 2. Modify config yaml: That yaml contains the configuration to connect with the database, modify the parameters. ``` mongo: { 'user': '<user>', 'password': '<password>', 'db': '<db>', 'col_invoker': '<invoker collection>', 'col_provider': '<provider collection>', 'col_services': '<service collection>', 'col_security': '<security collection>', 'host': '<host>', 'port': "<port>" } ``` 3. Launch backend ``` python main.py Loading Loading @@ -75,4 +59,9 @@ http://<hostname>:<port>/resources/invokers/events/<invoker_id> http://<hostname>:<port>/resources/providers http://<hostname>:<port>/resources/providers/services/<apf_id> http://<hostname>:<port>/resources/providers/events/<aef_id> http://<hostname>:<port>/resources/invokers/{invoker_id} http://<hostname>:<port>/resources/providers/{provider_id} http://<hostname>:<port>/resources/providers/services/{apf_id}/{service_id} http://<hostname>:<port>/resources/events/{subscriber_id}/{subscription_id} http://<hostname>:<port>/resources/events/{id} ``` No newline at end of file certs/create_cert_to_capif.py +15 −11 Original line number Diff line number Diff line from dis import dis import requests import json import os from OpenSSL.SSL import FILETYPE_PEM from OpenSSL.crypto import (dump_certificate_request, dump_privatekey, load_publickey, PKey, TYPE_RSA, X509Req, dump_publickey) from OpenSSL.crypto import (dump_certificate_request, dump_privatekey, PKey, TYPE_RSA, X509Req) EASY_RSA_HOSTNAME = os.getenv('EASY_RSA_HOSTNAME') EASY_RSA_PORT = os.getenv('EASY_RSA_PORT') HOSTAME = "localhost" def create_csr(): private_key_path = "private.key" Loading Loading @@ -35,8 +38,9 @@ def create_csr(): return csr_request def sign_certificate(publick_key): url = f"http://{HOSTAME}:8080/sign-csr" url = f"https://{EASY_RSA_HOSTNAME}:{EASY_RSA_PORT}/sign-csr" payload = dict() payload['csr'] = publick_key.decode("utf-8") Loading @@ -44,12 +48,11 @@ def sign_certificate(publick_key): payload['filename'] = "superadmin_information" headers = { 'Content-Type': 'application/json' } response = requests.request("POST", url, headers=headers, data=json.dumps(payload)) response = requests.request( "POST", url, headers=headers, data=json.dumps(payload),verify=False) response_payload = json.loads(response.text) cert = response_payload["certificate"] Loading @@ -58,15 +61,15 @@ def sign_certificate(publick_key): cert_file.close() return response_payload def get_ca_root(): url = f"http://{HOSTAME}:8080/ca-root" url = f"https://{EASY_RSA_HOSTNAME}:{EASY_RSA_PORT}/ca-root" #url = "http://localhost:8080/ca-root" headers = { 'Content-Type': "application/json" } response = requests.request("GET", url, headers=headers) response = requests.request("GET", url, headers=headers,verify=False) response_payload = json.loads(response.text) cert = response_payload["certificate"] Loading @@ -80,4 +83,5 @@ if __name__ == '__main__': get_ca_root() csr_request = create_csr() sign_certificate(csr_request) print("Obtained certs/ca to operate with CAPIF") config.pydeleted 100644 → 0 +0 −21 Original line number Diff line number Diff line import yaml import os #Config class to get config class Config: def __init__(self): self.cached = 0 self.file="./config.yaml" self.my_config = {} stamp = os.stat(self.file).st_mtime if stamp != self.cached: self.cached = stamp f = open(self.file) self.my_config = yaml.safe_load(f) f.close() def get_config(self): return self.my_config config.yamldeleted 100644 → 0 +0 −11 Original line number Diff line number Diff line mongo: { 'user': '<user>', 'password': '<password>', 'db': '<db>', 'col_invoker': '<invoker collection>', 'col_provider': '<provider collection>', 'col_services': '<service collection>', 'col_security': '<security collection>', 'host': '<host>', 'port': "<port>" } Loading
Dockerfile 0 → 100644 +15 −0 Original line number Diff line number Diff line FROM python:3-alpine # RUN mkdir -p /usr/src/app WORKDIR /usr/src/app COPY requirements.txt /usr/src/app/requirements.txt RUN apk add -U --no-cache gcc build-base linux-headers ca-certificates libffi-dev libressl-dev libxslt-dev RUN pip3 install --no-cache-dir -r requirements.txt COPY . /usr/src/app EXPOSE 8080 ENTRYPOINT ["python3", "main.py"]
README.md +5 −16 Original line number Diff line number Diff line Loading @@ -25,22 +25,6 @@ This python script Creates a csr request, sends it to CAPIF to be signed, and ge pip3 install -r requirements.txt ``` 2. Modify config yaml: That yaml contains the configuration to connect with the database, modify the parameters. ``` mongo: { 'user': '<user>', 'password': '<password>', 'db': '<db>', 'col_invoker': '<invoker collection>', 'col_provider': '<provider collection>', 'col_services': '<service collection>', 'col_security': '<security collection>', 'host': '<host>', 'port': "<port>" } ``` 3. Launch backend ``` python main.py Loading Loading @@ -75,4 +59,9 @@ http://<hostname>:<port>/resources/invokers/events/<invoker_id> http://<hostname>:<port>/resources/providers http://<hostname>:<port>/resources/providers/services/<apf_id> http://<hostname>:<port>/resources/providers/events/<aef_id> http://<hostname>:<port>/resources/invokers/{invoker_id} http://<hostname>:<port>/resources/providers/{provider_id} http://<hostname>:<port>/resources/providers/services/{apf_id}/{service_id} http://<hostname>:<port>/resources/events/{subscriber_id}/{subscription_id} http://<hostname>:<port>/resources/events/{id} ``` No newline at end of file
certs/create_cert_to_capif.py +15 −11 Original line number Diff line number Diff line from dis import dis import requests import json import os from OpenSSL.SSL import FILETYPE_PEM from OpenSSL.crypto import (dump_certificate_request, dump_privatekey, load_publickey, PKey, TYPE_RSA, X509Req, dump_publickey) from OpenSSL.crypto import (dump_certificate_request, dump_privatekey, PKey, TYPE_RSA, X509Req) EASY_RSA_HOSTNAME = os.getenv('EASY_RSA_HOSTNAME') EASY_RSA_PORT = os.getenv('EASY_RSA_PORT') HOSTAME = "localhost" def create_csr(): private_key_path = "private.key" Loading Loading @@ -35,8 +38,9 @@ def create_csr(): return csr_request def sign_certificate(publick_key): url = f"http://{HOSTAME}:8080/sign-csr" url = f"https://{EASY_RSA_HOSTNAME}:{EASY_RSA_PORT}/sign-csr" payload = dict() payload['csr'] = publick_key.decode("utf-8") Loading @@ -44,12 +48,11 @@ def sign_certificate(publick_key): payload['filename'] = "superadmin_information" headers = { 'Content-Type': 'application/json' } response = requests.request("POST", url, headers=headers, data=json.dumps(payload)) response = requests.request( "POST", url, headers=headers, data=json.dumps(payload),verify=False) response_payload = json.loads(response.text) cert = response_payload["certificate"] Loading @@ -58,15 +61,15 @@ def sign_certificate(publick_key): cert_file.close() return response_payload def get_ca_root(): url = f"http://{HOSTAME}:8080/ca-root" url = f"https://{EASY_RSA_HOSTNAME}:{EASY_RSA_PORT}/ca-root" #url = "http://localhost:8080/ca-root" headers = { 'Content-Type': "application/json" } response = requests.request("GET", url, headers=headers) response = requests.request("GET", url, headers=headers,verify=False) response_payload = json.loads(response.text) cert = response_payload["certificate"] Loading @@ -80,4 +83,5 @@ if __name__ == '__main__': get_ca_root() csr_request = create_csr() sign_certificate(csr_request) print("Obtained certs/ca to operate with CAPIF")
config.pydeleted 100644 → 0 +0 −21 Original line number Diff line number Diff line import yaml import os #Config class to get config class Config: def __init__(self): self.cached = 0 self.file="./config.yaml" self.my_config = {} stamp = os.stat(self.file).st_mtime if stamp != self.cached: self.cached = stamp f = open(self.file) self.my_config = yaml.safe_load(f) f.close() def get_config(self): return self.my_config
config.yamldeleted 100644 → 0 +0 −11 Original line number Diff line number Diff line mongo: { 'user': '<user>', 'password': '<password>', 'db': '<db>', 'col_invoker': '<invoker collection>', 'col_provider': '<provider collection>', 'col_services': '<service collection>', 'col_security': '<security collection>', 'host': '<host>', 'port': "<port>" }