Skip to content

Commit

Permalink
[NRL-796] Make X-Request-Id a required header for all API requests
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdean3-nhs committed Aug 6, 2024
1 parent 0efda69 commit fa0e899
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<RaiseFault async="false" continueOnError="false" enabled="true" name="RaiseFault.400MissingRequestIdHeader">
<FaultResponse>
<Set>
<Payload contentType="application/json">
{
"resourceType": "OperationOutcome",
"issue": [ {
"severity": "error",
"code": "invalid",
"details": {
"coding": [ {
"system": "https://fhir.nhs.uk/CodeSystem/Spine-ErrorOrWarningCode",
"code": "MISSING_OR_INVALID_HEADER",
"display": "There is a required header missing or invalid"
} ]
},
"diagnostics": "The X-Request-Id header is missing or invalid"
} ]
}
</Payload>
<StatusCode>400</StatusCode>
<ReasonPhrase>Bad Request</ReasonPhrase>
</Set>
</FaultResponse>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</RaiseFault>
8 changes: 8 additions & 0 deletions proxies/live/apiproxy/proxies/default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
<Condition>(proxy.pathsuffix MatchesPath "/_status") and ((request.verb = "GET") or (request.verb = "HEAD"))
</Condition>
</Flow>
<Flow name="Raise400ForMissingRequestIdHeader">
<Request>
<Step>
<Name>RaiseFault.400MissingRequestIdHeader</Name>
</Step>
</Request>
<Condition>request.verb != "OPTIONS" and (request.header.X-Request-Id = null or request.header.X-Request-Id = "")</Condition>
</Flow>
<Flow name="Raise400ForMissingODSHeader">
<Request>
<Step>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<RaiseFault async="false" continueOnError="false" enabled="true" name="RaiseFault.400MissingRequestIdHeader">
<FaultResponse>
<Set>
<Payload contentType="application/json">
{
"resourceType": "OperationOutcome",
"issue": [ {
"severity": "error",
"code": "invalid",
"details": {
"coding": [ {
"system": "https://fhir.nhs.uk/CodeSystem/Spine-ErrorOrWarningCode",
"code": "MISSING_OR_INVALID_HEADER",
"display": "There is a required header missing or invalid"
} ]
},
"diagnostics": "The X-Request-Id header is missing or invalid"
} ]
}
</Payload>
<StatusCode>400</StatusCode>
<ReasonPhrase>Bad Request</ReasonPhrase>
</Set>
</FaultResponse>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</RaiseFault>
8 changes: 8 additions & 0 deletions proxies/sandbox/apiproxy/proxies/default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
<Condition>(proxy.pathsuffix MatchesPath "/_status") and ((request.verb = "GET") or (request.verb = "HEAD"))
</Condition>
</Flow>
<Flow name="Raise400ForMissingRequestIdHeader">
<Request>
<Step>
<Name>RaiseFault.400MissingRequestIdHeader</Name>
</Step>
</Request>
<Condition>request.verb != "OPTIONS" and (request.header.X-Request-Id = null or request.header.X-Request-Id = "")</Condition>
</Flow>
<Flow name="Raise400ForMissingODSHeader">
<Request>
<Step>
Expand Down

0 comments on commit fa0e899

Please sign in to comment.