Skip to content

Commit e78d2a1

Browse files
Merge pull request #54 from NHSDigital/NPA-2273_Add_404_Response
NPA-2273 Add 404 Not Found Response
2 parents c03bcad + 9d313f5 commit e78d2a1

File tree

4 files changed

+49
-47
lines changed

4 files changed

+49
-47
lines changed

proxies/live/apiproxy/policies/AssignMessage.OAuthPolicyErrorResponse.xml

Lines changed: 0 additions & 28 deletions
This file was deleted.

proxies/live/apiproxy/policies/ExtractVariables.OAuthErrorFaultString.xml

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<!--
3+
This policy raises a 404 error response for an invalid resource request.
4+
5+
Raisefault policies stop the execution of the current flow and move to the error flow, which returns the error response defined here to the requesting application.
6+
7+
For more information on RaiseFault policies within Apigee see the following resource:
8+
* https://docs.apigee.com/api-platform/reference/policies/raise-fault-policy
9+
-->
10+
<RaiseFault async="false" continueOnError="false" enabled="true" name="RaiseFault.404NotFound">
11+
<DisplayName>RaiseFault.404NotFound</DisplayName>
12+
<Properties/>
13+
<FaultResponse>
14+
<Set>
15+
<Headers/>
16+
<StatusCode>404</StatusCode>
17+
<ReasonPhrase>NotFound</ReasonPhrase>
18+
<Payload>
19+
{
20+
"issue": [
21+
{
22+
"code": "processing",
23+
"details": {
24+
"coding": [
25+
{
26+
"code": "INVALIDATED_RESOURCE",
27+
"display": "Resource that has been marked as invalid was requested - invalid resources cannot be retrieved",
28+
"system": "https://fhir.nhs.uk/R4/CodeSystem/ValidatedRelationships-ErrorOrWarningCode",
29+
"version": "1"
30+
}
31+
]
32+
},
33+
"severity": "error"
34+
}
35+
],
36+
"resourceType": "OperationOutcome"
37+
}
38+
</Payload>
39+
</Set>
40+
</FaultResponse>
41+
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
42+
</RaiseFault>

proxies/live/apiproxy/targets/target.xml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,20 @@
2626
</Response>
2727
</PostFlow>
2828
<FaultRules>
29+
<FaultRule name="404_Not_Found">
30+
<Step>
31+
<Name>RaiseFault.404NotFound</Name>
32+
</Step>
33+
<Condition>response.header.x-amzn-ErrorType = "IncompleteSignatureException"</Condition>
34+
</FaultRule>
2935
<FaultRule name="unauthorized">
3036
<Step>
3137
<Name>RaiseFault.401Unauthorized</Name>
3238
<Condition>
33-
oauthV2.OauthV2.VerifyAccessToken.failed = true or fault.name = "invalid_access_token" or fault.name = "InvalidAccessToken" or fault.name = "access_token_not_approved" or fault.name = "apiresource_doesnot_exist" or fault.name = "InvalidAPICallAsNo" or fault.name = "ApiProductMatchFound"
39+
oauthV2.OauthV2.VerifyAccessToken.failed = true or fault.name = "invalid_access_token" or fault.name = "InvalidAccessToken" or fault.name = "access_token_not_approved" or fault.name = "apiresource_doesnot_exist" or fault.name = "InvalidAPICallAsNo" or fault.name = "ApiProductMatchFound" or fault.name = "access_token_expired"
3440
</Condition>
3541
</Step>
3642
</FaultRule>
37-
<FaultRule name="access_token_expired">
38-
<Step>
39-
<Name>ExtractVariables.OAuthErrorFaultString</Name>
40-
</Step>
41-
<Step>
42-
<Name>AssignMessage.OAuthPolicyErrorResponse</Name>
43-
</Step>
44-
<Condition>oauthV2.OauthV2.VerifyAccessToken.failed</Condition>
45-
</FaultRule>
4643
</FaultRules>
4744
<HTTPTargetConnection>
4845
<LoadBalancer>

0 commit comments

Comments
 (0)