Skip to content

Commit 6db5298

Browse files
committed
Fix JWT default times and encoding value
1 parent 36e7f7f commit 6db5298

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

gateway-api/src/gateway_api/clinical_jwt/jwt.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@ class JWT:
1717

1818
# Time fields
1919
issued_at: int = field(default_factory=lambda: int(time()))
20-
expiration: int = field(default_factory=lambda: int(time()) + 300)
20+
expiration: int = 0
2121

2222
# These are here for future proofing but are not expected ever to be changed
2323
algorithm: str = "none"
2424
type: str = "JWT"
2525
reason_for_request: str = "directcare"
2626
requested_scope: str = "patient/*.read"
2727

28+
def __post_init__(self) -> None:
29+
if self.expiration == 0:
30+
object.__setattr__(self, "expiration", self.issued_at + 300)
31+
2832
@property
2933
def issue_time(self) -> str:
3034
return datetime.fromtimestamp(self.issued_at, tz=UTC).isoformat()

gateway-api/src/gateway_api/provider/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class GpProviderClient:
6262
consumer_asid (str): The ASID for the consumer.
6363
token (JWT): JWT object for authentication with the provider API.
6464
endpoint_path (str): The endpoint path for the operation
65-
(default: "FHIR/STU3/patient/$gpc.getstructuredrecord").
65+
(default: "Patient/$gpc.getstructuredrecord").
6666
6767
Methods:
6868
access_structured_record(trace_id: str, body: str) -> Response:
@@ -89,8 +89,8 @@ def _build_headers(self, trace_id: str) -> dict[str, str]:
8989
"""
9090
# TODO: Post-steel-thread, probably check whether JWT is valid/not expired
9191
return {
92-
"Content-Type": "application/fhir+json;charset=utf-8",
93-
"Accept": "application/fhir+json;charset=utf-8",
92+
"Content-Type": "application/fhir+json; charset=utf-8",
93+
"Accept": "application/fhir+json; charset=utf-8",
9494
"Ssp-InteractionID": ACCESS_RECORD_STRUCTURED_INTERACTION_ID,
9595
"Ssp-To": self.provider_asid,
9696
"Ssp-From": self.consumer_asid,

gateway-api/src/gateway_api/provider/test_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ def test_valid_gpprovider_access_structured_record_with_correct_headers_post_200
116116
token=valid_jwt,
117117
)
118118
expected_headers = {
119-
"Content-Type": "application/fhir+json;charset=utf-8",
120-
"Accept": "application/fhir+json;charset=utf-8",
119+
"Content-Type": "application/fhir+json; charset=utf-8",
120+
"Accept": "application/fhir+json; charset=utf-8",
121121
"Ssp-TraceID": str(trace_id),
122122
"Ssp-From": consumer_asid,
123123
"Ssp-To": provider_asid,

0 commit comments

Comments
 (0)