From 3d5d728d676403ba096f737356bcc17d8a6103df Mon Sep 17 00:00:00 2001 From: Oscar Krause Date: Fri, 23 Dec 2022 13:22:06 +0100 Subject: [PATCH 01/12] code styling --- app/main.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/app/main.py b/app/main.py index 08c0310..ea4fc62 100644 --- a/app/main.py +++ b/app/main.py @@ -53,6 +53,7 @@ LEASE_EXPIRE_DELTA = relativedelta(days=int(getenv('LEASE_EXPIRE_DAYS', 90))) DLS_URL = str(getenv('DLS_URL', 'localhost')) DLS_PORT = int(getenv('DLS_PORT', '443')) SITE_KEY_XID = getenv('SITE_KEY_XID', '00000000-0000-0000-0000-000000000000') +INSTANCE_REF = '00000000-0000-0000-0000-000000000000' INSTANCE_KEY_RSA = load_key(join(dirname(__file__), 'cert/instance.private.pem')) INSTANCE_KEY_PUB = load_key(join(dirname(__file__), 'cert/instance.public.pem')) @@ -109,15 +110,6 @@ async def client_token(): cur_time = datetime.utcnow() exp_time = cur_time + relativedelta(years=12) - service_instance_public_key_configuration = { - "service_instance_public_key_me": { - "mod": hex(INSTANCE_KEY_PUB.public_key().n)[2:], - "exp": INSTANCE_KEY_PUB.public_key().e, - }, - "service_instance_public_key_pem": INSTANCE_KEY_PUB.export_key().decode('utf-8'), - "key_retention_mode": "LATEST_ONLY" - } - payload = { "jti": str(uuid4()), "iss": "NLS Service Instance", @@ -129,7 +121,7 @@ async def client_token(): "scope_ref_list": [str(uuid4())], "fulfillment_class_ref_list": [], "service_instance_configuration": { - "nls_service_instance_ref": "00000000-0000-0000-0000-000000000000", + "nls_service_instance_ref": INSTANCE_REF, "svc_port_set_list": [ { "idx": 0, @@ -139,7 +131,14 @@ async def client_token(): ], "node_url_list": [{"idx": 0, "url": DLS_URL, "url_qr": DLS_URL, "svc_port_set_idx": 0}] }, - "service_instance_public_key_configuration": service_instance_public_key_configuration, + "service_instance_public_key_configuration": { + "service_instance_public_key_me": { + "mod": hex(INSTANCE_KEY_PUB.public_key().n)[2:], + "exp": INSTANCE_KEY_PUB.public_key().e, + }, + "service_instance_public_key_pem": INSTANCE_KEY_PUB.export_key().decode('utf-8'), + "key_retention_mode": "LATEST_ONLY" + }, } content = jws.sign(payload, key=jwt_encode_key, headers=None, algorithm=ALGORITHMS.RS256) From 332b9b23cd884db32a286752403702a860d7bf92 Mon Sep 17 00:00:00 2001 From: Oscar Krause Date: Fri, 23 Dec 2022 13:31:23 +0100 Subject: [PATCH 02/12] code styling --- app/main.py | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/app/main.py b/app/main.py index ea4fc62..ea26f64 100644 --- a/app/main.py +++ b/app/main.py @@ -134,7 +134,7 @@ async def client_token(): "service_instance_public_key_configuration": { "service_instance_public_key_me": { "mod": hex(INSTANCE_KEY_PUB.public_key().n)[2:], - "exp": INSTANCE_KEY_PUB.public_key().e, + "exp": int(INSTANCE_KEY_PUB.public_key().e), }, "service_instance_public_key_pem": INSTANCE_KEY_PUB.export_key().decode('utf-8'), "key_retention_mode": "LATEST_ONLY" @@ -154,7 +154,7 @@ async def client_token(): # {"candidate_origin_ref":"00112233-4455-6677-8899-aabbccddeeff","environment":{"fingerprint":{"mac_address_list":["ff:ff:ff:ff:ff:ff"]},"hostname":"my-hostname","ip_address_list":["192.168.178.123","fe80::","fe80::1%enp6s18"],"guest_driver_version":"510.85.02","os_platform":"Debian GNU/Linux 11 (bullseye) 11","os_version":"11 (bullseye)"},"registration_pending":false,"update_pending":false} @app.post('/auth/v1/origin') async def auth_v1_origin(request: Request): - j = json.loads((await request.body()).decode('utf-8')) + j, cur_time = json.loads((await request.body()).decode('utf-8')), datetime.utcnow() origin_ref = j['candidate_origin_ref'] logging.info(f'> [ origin ]: {origin_ref}: {j}') @@ -168,7 +168,6 @@ async def auth_v1_origin(request: Request): db['origin'].upsert(data, ['origin_ref']) - cur_time = datetime.utcnow() response = { "origin_ref": origin_ref, "environment": j['environment'], @@ -187,12 +186,11 @@ async def auth_v1_origin(request: Request): # {"code_challenge":"...","origin_ref":"00112233-4455-6677-8899-aabbccddeeff"} @app.post('/auth/v1/code') async def auth_v1_code(request: Request): - j = json.loads((await request.body()).decode('utf-8')) + j, cur_time = json.loads((await request.body()).decode('utf-8')), datetime.utcnow() origin_ref = j['origin_ref'] logging.info(f'> [ code ]: {origin_ref}: {j}') - cur_time = datetime.utcnow() delta = relativedelta(minutes=15) expires = cur_time + delta @@ -221,7 +219,7 @@ async def auth_v1_code(request: Request): # {"auth_code":"...","code_verifier":"..."} @app.post('/auth/v1/token') async def auth_v1_token(request: Request): - j = json.loads((await request.body()).decode('utf-8')) + j, cur_time = json.loads((await request.body()).decode('utf-8')), datetime.utcnow() payload = jwt.decode(token=j['auth_code'], key=jwt_decode_key) origin_ref = payload['origin_ref'] @@ -231,7 +229,6 @@ async def auth_v1_token(request: Request): if payload['challenge'] != b64enc(sha256(j['code_verifier'].encode('utf-8')).digest()).rstrip(b'=').decode('utf-8'): raise HTTPException(status_code=401, detail='expected challenge did not match verifier') - cur_time = datetime.utcnow() access_expires_on = cur_time + TOKEN_EXPIRE_DELTA new_payload = { @@ -259,13 +256,12 @@ async def auth_v1_token(request: Request): # {'fulfillment_context': {'fulfillment_class_ref_list': []}, 'lease_proposal_list': [{'license_type_qualifiers': {'count': 1}, 'product': {'name': 'NVIDIA RTX Virtual Workstation'}}], 'proposal_evaluation_mode': 'ALL_OF', 'scope_ref_list': ['00112233-4455-6677-8899-aabbccddeeff']} @app.post('/leasing/v1/lessor') async def leasing_v1_lessor(request: Request): - j, token = json.loads((await request.body()).decode('utf-8')), get_token(request) + j, token, cur_time = json.loads((await request.body()).decode('utf-8')), get_token(request), datetime.utcnow() origin_ref = token['origin_ref'] scope_ref_list = j['scope_ref_list'] logging.info(f'> [ create ]: {origin_ref}: create leases for scope_ref_list {scope_ref_list}') - cur_time = datetime.utcnow() lease_result_list = [] for scope_ref in scope_ref_list: expires = cur_time + LEASE_EXPIRE_DELTA @@ -300,14 +296,13 @@ async def leasing_v1_lessor(request: Request): # venv/lib/python3.9/site-packages/nls_dal_service_instance_dls/schema/service_instance/V1_0_21__product_mapping.sql @app.get('/leasing/v1/lessor/leases') async def leasing_v1_lessor_lease(request: Request): - token = get_token(request) + token, cur_time = get_token(request), datetime.utcnow() origin_ref = token['origin_ref'] active_lease_list = list(map(lambda x: x['lease_ref'], db['lease'].find(origin_ref=origin_ref))) logging.info(f'> [ leases ]: {origin_ref}: found {len(active_lease_list)} active leases') - cur_time = datetime.utcnow() response = { "active_lease_list": active_lease_list, "sync_timestamp": cur_time.isoformat(), @@ -320,7 +315,7 @@ async def leasing_v1_lessor_lease(request: Request): # venv/lib/python3.9/site-packages/nls_core_lease/lease_single.py @app.put('/leasing/v1/lease/{lease_ref}') async def leasing_v1_lease_renew(request: Request, lease_ref: str): - token = get_token(request) + token, cur_time = get_token(request), datetime.utcnow() origin_ref = token['origin_ref'] logging.info(f'> [ renew ]: {origin_ref}: renew {lease_ref}') @@ -328,8 +323,11 @@ async def leasing_v1_lease_renew(request: Request, lease_ref: str): if db['lease'].count(origin_ref=origin_ref, lease_ref=lease_ref) == 0: raise HTTPException(status_code=404, detail='requested lease not available') - cur_time = datetime.utcnow() expires = cur_time + LEASE_EXPIRE_DELTA + + data = dict(origin_ref=origin_ref, lease_ref=lease_ref, lease_expires=expires, lease_last_update=cur_time) + db['lease'].update(data, ['origin_ref', 'lease_ref']) + response = { "lease_ref": lease_ref, "expires": expires.isoformat(), @@ -339,15 +337,12 @@ async def leasing_v1_lease_renew(request: Request, lease_ref: str): "sync_timestamp": cur_time.isoformat(), } - data = dict(origin_ref=origin_ref, lease_ref=lease_ref, lease_expires=expires, lease_last_update=cur_time) - db['lease'].update(data, ['origin_ref', 'lease_ref']) - return JSONResponse(response) @app.delete('/leasing/v1/lessor/leases') async def leasing_v1_lessor_lease_remove(request: Request): - token = get_token(request) + token, cur_time = get_token(request), datetime.utcnow() origin_ref = token['origin_ref'] @@ -355,13 +350,13 @@ async def leasing_v1_lessor_lease_remove(request: Request): deletions = db['lease'].delete(origin_ref=origin_ref) logging.info(f'> [ remove ]: {origin_ref}: removed {deletions} leases') - cur_time = datetime.utcnow() response = { "released_lease_list": released_lease_list, "release_failure_list": None, "sync_timestamp": cur_time.isoformat(), "prompts": None } + return JSONResponse(response) From 6b7c70e59af7c02b329a62c07b94d1bae9e7cea1 Mon Sep 17 00:00:00 2001 From: Oscar Krause Date: Fri, 23 Dec 2022 13:42:02 +0100 Subject: [PATCH 03/12] tests improved --- test/main.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/test/main.py b/test/main.py index aeb52e3..0711de5 100644 --- a/test/main.py +++ b/test/main.py @@ -1,3 +1,6 @@ +from uuid import uuid4 + +from jose import jwt from starlette.testclient import TestClient import importlib.util import sys @@ -11,6 +14,8 @@ spec.loader.exec_module(main) client = TestClient(main.app) +ORIGIN_REF = str(uuid4()) + def test_index(): response = client.get('/') @@ -41,14 +46,25 @@ def test_auth_v1_origin(): "host_driver_version": "host_driver_version" }, "update_pending": False, - "candidate_origin_ref": "00112233-4455-6677-8899-aabbccddeeff" + "candidate_origin_ref": ORIGIN_REF, } + response = client.post('/auth/v1/origin', json=payload) assert response.status_code == 200 + assert response.json()['origin_ref'] == ORIGIN_REF def test_auth_v1_code(): - pass + payload = { + "code_challenge": "0wmaiAMAlTIDyz4Fgt2/j0tXnGv72TYbbLs4ISRCZlY", + "origin_ref": ORIGIN_REF, + } + + response = client.post('/auth/v1/code', json=payload) + assert response.status_code == 200 + + payload = jwt.get_unverified_claims(token=response.json()['auth_code']) + assert payload['origin_ref'] == ORIGIN_REF def test_auth_v1_token(): From 599eaba14afa38568c635b9fafb486705c2e45dd Mon Sep 17 00:00:00 2001 From: Oscar Krause Date: Tue, 27 Dec 2022 09:19:05 +0100 Subject: [PATCH 04/12] README.md - added supported and tested driver versions --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e729b89..ef842d3 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Generate client token, (see [installation](#installation)). There are some more internal api endpoints for handling authentication and lease process. -# Setup +# Setup (Service) ## Docker @@ -194,10 +194,15 @@ with `systemctl start fastapi-dls.service`. | `DATABASE` | `sqlite:///db.sqlite` | See [official dataset docs](https://dataset.readthedocs.io/en/latest/quickstart.html) | | `CORS_ORIGINS` | `https://{DLS_URL}` | Sets `Access-Control-Allow-Origin` header (comma separated string) | -# Installation +# Installation (Client) **The token file has to be copied! It's not enough to C&P file contents, because there can be special characters.** +Successfully tested with this package versions: + +- `14.3` (Linux-Host: `510.108.03`, Linux-Guest: `510.108.03`, Windows-Guest: `513.91`) +- `15.0` (Linux-Host: `525.60.12`, Linux-Guest: `525.60.13`, Windows-Guest: `527.41`) + ## Linux ```shell From a91e1f7018d4d79e327ac89b9ca4de45fb8d381f Mon Sep 17 00:00:00 2001 From: Oscar Krause Date: Tue, 27 Dec 2022 11:03:53 +0100 Subject: [PATCH 05/12] README.md - added supported package version 14.4 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ef842d3..7d20426 100644 --- a/README.md +++ b/README.md @@ -201,6 +201,7 @@ with `systemctl start fastapi-dls.service`. Successfully tested with this package versions: - `14.3` (Linux-Host: `510.108.03`, Linux-Guest: `510.108.03`, Windows-Guest: `513.91`) +- `14.4` (Linux-Host: `510.108.03`, Linux-Guest: `510.108.03`, Windows-Guest: `514.08`) - `15.0` (Linux-Host: `525.60.12`, Linux-Guest: `525.60.13`, Windows-Guest: `527.41`) ## Linux From 6ddba90cd87076c18e9bb440bb399b4e4b689715 Mon Sep 17 00:00:00 2001 From: Oscar Krause Date: Tue, 27 Dec 2022 15:28:52 +0100 Subject: [PATCH 06/12] README fixed --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7d20426..cee024c 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,8 @@ DLS_URL=127.0.0.1 DLS_PORT=443 LEASE_EXPIRE_DAYS=90 DATABASE=sqlite:////opt/fastapi-dls/app/db.sqlite -EOF + +EOF ``` **Create service** @@ -177,11 +178,12 @@ NotifyAccess=all [Install] WantedBy=multi-user.target + EOF ``` Now you have to run `systemctl daemon-reload`. After that you can start service -with `systemctl start fastapi-dls.service`. +with `systemctl start fastapi-dls.service` (and enable autostart with `systemctl enable fastapi-dls.service`). # Configuration From 3d6da6fab9e30620838f9c91478f791108fb8c91 Mon Sep 17 00:00:00 2001 From: Oscar Krause Date: Tue, 27 Dec 2022 16:59:35 +0100 Subject: [PATCH 07/12] README - fixed debian installation via git --- README.md | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index cee024c..930ca4d 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,9 @@ volumes: Tested on `Debian 11 (bullseye)`, Ubuntu may also work. +**We are running on port `9443` because we are running service as `www-data`-user and non-root users are not allowed to +use ports below 1024!** + **Install requirements** ```shell @@ -112,6 +115,7 @@ python3 -m venv venv source venv/bin/activate pip install -r requirements.txt deactivate +chown -R www-data:www-data $WORKING_DIR ``` **Create keypair and webserver certificate** @@ -125,18 +129,16 @@ openssl genrsa -out $WORKING_DIR/instance.private.pem 2048 openssl rsa -in $WORKING_DIR/instance.private.pem -outform PEM -pubout -out $WORKING_DIR/instance.public.pem # create ssl certificate for integrated webserver (uvicorn) - because clients rely on ssl openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout $WORKING_DIR/webserver.key -out $WORKING_DIR/webserver.crt +chown -R www-data:www-data $WORKING_DIR ``` **Test Service** +This is only to test whether the service starts successfully. + ```shell cd /opt/fastapi-dls/app -/opt/fastapi-dls/venv/bin/uvicorn main:app \ - --host 127.0.0.1 --port 443 \ - --app-dir /opt/fastapi-dls/app \ - --ssl-keyfile /opt/fastapi-dls/app/cert/webserver.key \ - --ssl-certfile /opt/fastapi-dls/app/cert/webserver.crt \ - --proxy-headers +su - www-data -c "/opt/fastapi-dls/venv/bin/uvicorn main:app --app-dir=/opt/fastapi-dls/app" ``` **Create config file** @@ -144,7 +146,7 @@ cd /opt/fastapi-dls/app ```shell cat < /etc/fastapi-dls.env DLS_URL=127.0.0.1 -DLS_PORT=443 +DLS_PORT=9443 LEASE_EXPIRE_DAYS=90 DATABASE=sqlite:////opt/fastapi-dls/app/db.sqlite @@ -163,13 +165,14 @@ After=network.target User=www-data Group=www-data WorkingDirectory=/opt/fastapi-dls/app -ExecStart=/opt/fastapi-dls/venv/bin/uvicorn \ - --host $DLS_URL --port $DLS_PORT \ +EnvironmentFile=/etc/fastapi-dls.env +ExecStart=/opt/fastapi-dls/venv/bin/uvicorn main:app \ + --env-file /etc/fastapi-dls.env \ + --host \$DLS_URL --port \$DLS_PORT \ --app-dir /opt/fastapi-dls/app \ --ssl-keyfile /opt/fastapi-dls/app/cert/webserver.key \ --ssl-certfile /opt/fastapi-dls/app/cert/webserver.crt \ --proxy-headers -EnvironmentFile=/etc/fastapi-dls.env Restart=always KillSignal=SIGQUIT Type=notify From f9e37401506ce95f0b9817c6c4505d7c0358d74a Mon Sep 17 00:00:00 2001 From: Oscar Krause Date: Tue, 27 Dec 2022 17:42:58 +0100 Subject: [PATCH 08/12] main.py - added env variable for "INSTANCE_REF" --- app/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index ea26f64..4b04b69 100644 --- a/app/main.py +++ b/app/main.py @@ -52,8 +52,8 @@ LEASE_EXPIRE_DELTA = relativedelta(days=int(getenv('LEASE_EXPIRE_DAYS', 90))) DLS_URL = str(getenv('DLS_URL', 'localhost')) DLS_PORT = int(getenv('DLS_PORT', '443')) -SITE_KEY_XID = getenv('SITE_KEY_XID', '00000000-0000-0000-0000-000000000000') -INSTANCE_REF = '00000000-0000-0000-0000-000000000000' +SITE_KEY_XID = str(getenv('SITE_KEY_XID', '00000000-0000-0000-0000-000000000000')) +INSTANCE_REF = str(getenv('INSTANCE_REF', '00000000-0000-0000-0000-000000000000')) INSTANCE_KEY_RSA = load_key(join(dirname(__file__), 'cert/instance.private.pem')) INSTANCE_KEY_PUB = load_key(join(dirname(__file__), 'cert/instance.public.pem')) From e5f557eb964dadc2b03c5eb63c655dba2c6c588c Mon Sep 17 00:00:00 2001 From: Oscar Krause Date: Tue, 27 Dec 2022 17:49:52 +0100 Subject: [PATCH 09/12] README.md - added todos --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 930ca4d..3717a93 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,13 @@ Minimal Delegated License Service (DLS). This service can be used without internet connection. Only the clients need a connection to this service on configured port. +## ToDo#'s + +- provide `.deb` package (WIP) +- migrate from `dataset` to `sqlalchemy` (WIP) +- migrate from `fastapi` to `flask` +- Support http mode for using external https proxy + ## Endpoints ### `GET /` From cefee22202f9d61931d4c91fab229d4628dbf978 Mon Sep 17 00:00:00 2001 From: Oscar Krause Date: Tue, 27 Dec 2022 18:38:26 +0100 Subject: [PATCH 10/12] README.md - fixed srevice type --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3717a93..6c79e9b 100644 --- a/README.md +++ b/README.md @@ -182,7 +182,7 @@ ExecStart=/opt/fastapi-dls/venv/bin/uvicorn main:app \ --proxy-headers Restart=always KillSignal=SIGQUIT -Type=notify +Type=simple StandardError=syslog NotifyAccess=all From 11a2c1d12916d2528cd9e4ec8d684ded8615a80e Mon Sep 17 00:00:00 2001 From: Oscar Krause Date: Tue, 27 Dec 2022 18:51:20 +0100 Subject: [PATCH 11/12] added "CAP_NET_BIND_SERVICE" to debian service to allow low range ports for non root user "www-data" --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6c79e9b..6b014e5 100644 --- a/README.md +++ b/README.md @@ -102,9 +102,6 @@ volumes: Tested on `Debian 11 (bullseye)`, Ubuntu may also work. -**We are running on port `9443` because we are running service as `www-data`-user and non-root users are not allowed to -use ports below 1024!** - **Install requirements** ```shell @@ -153,7 +150,7 @@ su - www-data -c "/opt/fastapi-dls/venv/bin/uvicorn main:app --app-dir=/opt/fast ```shell cat < /etc/fastapi-dls.env DLS_URL=127.0.0.1 -DLS_PORT=9443 +DLS_PORT=443 LEASE_EXPIRE_DAYS=90 DATABASE=sqlite:////opt/fastapi-dls/app/db.sqlite @@ -171,6 +168,7 @@ After=network.target [Service] User=www-data Group=www-data +AmbientCapabilities=CAP_NET_BIND_SERVICE WorkingDirectory=/opt/fastapi-dls/app EnvironmentFile=/etc/fastapi-dls.env ExecStart=/opt/fastapi-dls/venv/bin/uvicorn main:app \ From 6d5ed1a14220024525efeeac396aaa5ec7b6e6c9 Mon Sep 17 00:00:00 2001 From: Oscar Krause Date: Tue, 27 Dec 2022 19:03:03 +0100 Subject: [PATCH 12/12] main.py - added origin update endpoint --- app/main.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/app/main.py b/app/main.py index 4b04b69..93a2b0b 100644 --- a/app/main.py +++ b/app/main.py @@ -181,6 +181,33 @@ async def auth_v1_origin(request: Request): return JSONResponse(response) +# venv/lib/python3.9/site-packages/nls_services_auth/test/test_origins_controller.py +# { "environment" : { "guest_driver_version" : "guest_driver_version", "hostname" : "myhost", "ip_address_list" : [ "192.168.1.129" ], "os_version" : "os_version", "os_platform" : "os_platform", "fingerprint" : { "mac_address_list" : [ "e4:b9:7a:e5:7b:ff" ] }, "host_driver_version" : "host_driver_version" }, "origin_ref" : "00112233-4455-6677-8899-aabbccddeeff" } +@app.post('/auth/v1/origin/update') +async def auth_v1_origin_update(request: Request): + j, cur_time = json.loads((await request.body()).decode('utf-8')), datetime.utcnow() + + origin_ref = j['origin_ref'] + logging.info(f'> [ update ]: {origin_ref}: {j}') + + data = dict( + origin_ref=origin_ref, + hostname=j['environment']['hostname'], + guest_driver_version=j['environment']['guest_driver_version'], + os_platform=j['environment']['os_platform'], os_version=j['environment']['os_version'], + ) + + db['origin'].upsert(data, ['origin_ref']) + + response = { + "environment": j['environment'], + "prompts": None, + "sync_timestamp": cur_time.isoformat() + } + + return JSONResponse(response) + + # venv/lib/python3.9/site-packages/nls_services_auth/test/test_auth_controller.py # venv/lib/python3.9/site-packages/nls_core_auth/auth.py - CodeResponse # {"code_challenge":"...","origin_ref":"00112233-4455-6677-8899-aabbccddeeff"}