Skip to content

Commit b3010f8

Browse files
committed
Don't encrypt tokens for UCS
1 parent 4f4a736 commit b3010f8

File tree

7 files changed

+10
-29
lines changed

7 files changed

+10
-29
lines changed

.devcontainer/.dev_config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ ucs_url: http://127.0.0.1/upload
88
access_url: http://127.0.0.1/access
99
audit_record_topic: audit-records
1010
audit_record_type: audit_record_logged
11-
ucs_public_key: dWoWghAEVPcpHILEb5drJx59nF+of6YKuAOhKRpmegY=
1211
work_order_signing_key: "{}"
1312
file_upload_box_topic: file-upload-boxes

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ The service requires the following configuration parameters:
104104
```
105105

106106

107-
- <a id="properties/ucs_public_key"></a>**`ucs_public_key`** *(string, required)*: The public key used to encrypt work order tokens sent to the UCS.
108-
109107
- <a id="properties/access_url"></a>**`access_url`** *(string, required)*: URL pointing to the internal access API.
110108

111109

config_schema.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@
4545
"type": "string",
4646
"writeOnly": true
4747
},
48-
"ucs_public_key": {
49-
"description": "The public key used to encrypt work order tokens sent to the UCS",
50-
"title": "Ucs Public Key",
51-
"type": "string"
52-
},
5348
"access_url": {
5449
"description": "URL pointing to the internal access API.",
5550
"examples": [
@@ -492,7 +487,6 @@
492487
"audit_record_type",
493488
"ucs_url",
494489
"work_order_signing_key",
495-
"ucs_public_key",
496490
"access_url",
497491
"service_instance_id",
498492
"kafka_servers",

example_config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ otel_trace_sampling_rate: 1.0
4747
port: 8080
4848
service_instance_id: '1'
4949
service_name: uos
50-
ucs_public_key: dWoWghAEVPcpHILEb5drJx59nF+of6YKuAOhKRpmegY=
5150
ucs_url: http://127.0.0.1/upload
5251
work_order_signing_key: '**********'
5352
workers: 1

src/uos/adapters/outbound/http.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
from uuid import UUID
2121

2222
import httpx
23-
from ghga_service_commons.utils.crypt import encrypt
2423
from ghga_service_commons.utils.utc_dates import UTCDatetime
2524
from jwcrypto import jwk
2625
from pydantic import UUID4, Field, SecretStr
2726
from pydantic_settings import BaseSettings
2827

2928
from uos.core.models import (
29+
BaseWorkOrderToken,
3030
ChangeFileBoxWorkOrder,
3131
CreateFileBoxWorkOrder,
3232
UploadGrant,
@@ -64,10 +64,6 @@ class UCSApiConfig(BaseSettings):
6464
description="The private key for signing work order tokens",
6565
examples=['{"crv": "P-256", "kty": "EC", "x": "...", "y": "..."}'],
6666
)
67-
ucs_public_key: str = Field(
68-
...,
69-
description="The public key used to encrypt work order tokens sent to the UCS",
70-
)
7167

7268

7369
class AccessClient(AccessClientPort):
@@ -261,7 +257,6 @@ class UCSClient(UCSClientPort):
261257

262258
def __init__(self, *, config: UCSApiConfig):
263259
self._ucs_url = config.ucs_url
264-
self._ucs_public_key = config.ucs_public_key
265260
self._signing_key = jwk.JWK.from_json(
266261
config.work_order_signing_key.get_secret_value()
267262
)
@@ -270,9 +265,9 @@ def __init__(self, *, config: UCSApiConfig):
270265
log.error(key_error)
271266
raise key_error
272267

273-
def _auth_header(self, signed_wot: str) -> dict[str, str]:
274-
encrypted_wot = encrypt(signed_wot, self._ucs_public_key)
275-
headers = {"Authorization": f"Bearer {encrypted_wot}"}
268+
def _auth_header(self, wot: BaseWorkOrderToken) -> dict[str, str]:
269+
signed_wot = sign_work_order_token(wot, self._signing_key)
270+
headers = {"Authorization": f"Bearer {signed_wot}"}
276271
return headers
277272

278273
async def create_file_upload_box(self, *, storage_alias: str) -> UUID4:
@@ -281,8 +276,7 @@ async def create_file_upload_box(self, *, storage_alias: str) -> UUID4:
281276
Raises:
282277
UCSCallError if there's a problem with the operation.
283278
"""
284-
signed_wot = sign_work_order_token(CreateFileBoxWorkOrder(), self._signing_key)
285-
headers = self._auth_header(signed_wot)
279+
headers = self._auth_header(CreateFileBoxWorkOrder())
286280
body = {"storage_alias": storage_alias}
287281
response = httpx.post(f"{self._ucs_url}/boxes", headers=headers, json=body)
288282
if response.status_code != 201:
@@ -310,8 +304,7 @@ async def lock_file_upload_box(self, *, box_id: UUID4) -> None:
310304
UCSCallError if there's a problem with the operation.
311305
"""
312306
wot = ChangeFileBoxWorkOrder(work_type="lock", box_id=box_id)
313-
signed_wot = sign_work_order_token(wot, self._signing_key)
314-
headers = self._auth_header(signed_wot)
307+
headers = self._auth_header(wot)
315308
body = {"lock": True}
316309
response = httpx.patch(
317310
f"{self._ucs_url}/boxes/{box_id}", headers=headers, json=body
@@ -334,8 +327,8 @@ async def unlock_file_upload_box(self, *, box_id: UUID4) -> None:
334327
UCSCallError if there's a problem with the operation.
335328
"""
336329
wot = ChangeFileBoxWorkOrder(work_type="unlock", box_id=box_id)
337-
signed_wot = sign_work_order_token(wot, self._signing_key)
338-
headers = self._auth_header(signed_wot)
330+
331+
headers = self._auth_header(wot)
339332
body = {"lock": False}
340333
response = httpx.patch(
341334
f"{self._ucs_url}/boxes/{box_id}", headers=headers, json=body
@@ -358,8 +351,7 @@ async def get_file_upload_list(self, *, box_id: UUID4) -> list[UUID4]:
358351
UCSCallError if there's a problem with the operation.
359352
"""
360353
wot = ViewFileBoxWorkOrder(box_id=box_id)
361-
signed_wot = sign_work_order_token(wot, self._signing_key)
362-
headers = self._auth_header(signed_wot)
354+
headers = self._auth_header(wot)
363355
response = httpx.get(f"{self._ucs_url}/boxes/{box_id}/uploads", headers=headers)
364356
if response.status_code != 200:
365357
log.error(

tests/fixtures/test_config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ audit_record_topic: audit-records
1010
audit_record_type: audit_record_logged
1111
file_upload_box_topic: file-upload-boxes
1212
work_order_signing_key: "{}"
13-
ucs_public_key: dWoWghAEVPcpHILEb5drJx59nF+of6YKuAOhKRpmegY=

tests/unit/test_orchestrator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ async def test_get_upload_box_files_happy(rig: JointRig):
175175
)
176176

177177
# Mock the UCS client to return a list of file IDs
178-
test_file_ids = [uuid4(), uuid4(), uuid4()]
178+
test_file_ids = sorted([uuid4(), uuid4(), uuid4()])
179179
rig.ucs_client.get_file_upload_list.return_value = test_file_ids # type: ignore
180180

181181
# Mock the access client for non-data steward case

0 commit comments

Comments
 (0)