Skip to content

Commit 996b2ff

Browse files
Merge pull request #59 from NHSDigital/NPA-2777_400_mime_type
NPA-2777 All Errors Have Correct Mime Type
2 parents 0cc5137 + e1b5f75 commit 996b2ff

File tree

5 files changed

+83
-63
lines changed

5 files changed

+83
-63
lines changed

proxies/live/apiproxy/policies/RaiseFault.400BadRequest.xml

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

proxies/live/apiproxy/policies/RaiseFault.401Unauthorized.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
<Properties/>
1313
<FaultResponse>
1414
<Set>
15-
<Headers/>
15+
<Headers>
16+
<Header name="Content-Type">application/fhir+json</Header>
17+
</Headers>
1618
<StatusCode>401</StatusCode>
1719
<ReasonPhrase>Unauthorized</ReasonPhrase>
1820
<Payload>
@@ -35,9 +37,9 @@
3537
}
3638
],
3739
"resourceType": "OperationOutcome"
38-
}
40+
}
3941
</Payload>
4042
</Set>
4143
</FaultResponse>
4244
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
43-
</RaiseFault>
45+
</RaiseFault>

proxies/live/apiproxy/policies/RaiseFault.404NotFound.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
<Properties/>
1313
<FaultResponse>
1414
<Set>
15-
<Headers/>
15+
<Headers>
16+
<Header name="Content-Type">application/fhir+json</Header>
17+
</Headers>
1618
<StatusCode>404</StatusCode>
1719
<ReasonPhrase>NotFound</ReasonPhrase>
1820
<Payload>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<!--
3+
This policy raises when an error occurs in the AWS Application.
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.DefaultError">
11+
<DisplayName>RaiseFault.DefaultError</DisplayName>
12+
<Properties/>
13+
<FaultResponse>
14+
<Set>
15+
<Headers>
16+
<Header name="Content-Type">application/fhir+json</Header>
17+
</Headers>
18+
</Set>
19+
</FaultResponse>
20+
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
21+
</RaiseFault>
Lines changed: 54 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,58 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
12
<TargetEndpoint name="validated-relationships-service-api-target">
2-
<PreFlow>
3-
<Request>
3+
<PreFlow>
4+
<Request>
5+
<Step>
6+
<Name>VerifyAccessTokenUserNhsLoginP9</Name>
7+
</Step>
8+
<Step>
9+
<Name>FlowCallout.ApplyRateLimiting</Name>
10+
</Step>
11+
<Step>
12+
<Name>AddProxyURL</Name>
13+
</Step>
14+
<Step>
15+
<Name>AddUserAuthLevel</Name>
16+
</Step>
17+
<Step>
18+
<Name>AddUserNHSNumber</Name>
19+
</Step>
20+
</Request>
21+
</PreFlow>
22+
<PostFlow>
23+
<Response>
24+
<Step>
25+
<Name>SetMimeType</Name>
26+
</Step>
27+
</Response>
28+
</PostFlow>
29+
<FaultRules>
30+
<FaultRule name="401_Unauthorized">
31+
<Step>
32+
<Name>RaiseFault.401Unauthorized</Name>
33+
</Step>
34+
<Condition>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"</Condition>
35+
</FaultRule>
36+
<FaultRule name="404_Not_Found">
37+
<Step>
38+
<Name>RaiseFault.404NotFound</Name>
39+
</Step>
40+
<Condition>response.header.x-amzn-ErrorType = "IncompleteSignatureException"</Condition>
41+
</FaultRule>
42+
</FaultRules>
43+
<DefaultFaultRule name="DefaultFaultRule">
444
<Step>
5-
<Name>VerifyAccessTokenUserNhsLoginP9</Name>
45+
<Name>RaiseFault.DefaultError</Name>
646
</Step>
7-
<Step>
8-
<Name>FlowCallout.ApplyRateLimiting</Name>
9-
</Step>
10-
<Step>
11-
<Name>AddProxyURL</Name>
12-
</Step>
13-
<Step>
14-
<Name>AddUserAuthLevel</Name>
15-
</Step>
16-
<Step>
17-
<Name>AddUserNHSNumber</Name>
18-
</Step>
19-
</Request>
20-
</PreFlow>
21-
<PostFlow>
22-
<Response>
23-
<Step>
24-
<Name>SetMimeType</Name>
25-
</Step>
26-
</Response>
27-
</PostFlow>
28-
<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>
35-
<FaultRule name="unauthorized">
36-
<Step>
37-
<Name>RaiseFault.401Unauthorized</Name>
38-
<Condition>
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"
40-
</Condition>
41-
</Step>
42-
</FaultRule>
43-
</FaultRules>
44-
<HTTPTargetConnection>
45-
<LoadBalancer>
46-
<Server name="validated-relationships-service-api"/>
47-
</LoadBalancer>
48-
<Properties>
49-
<Property name="supports.http10">true</Property>
50-
<Property name="request.retain.headers">User-Agent,Referer,Accept-Language</Property>
51-
</Properties>
52-
</HTTPTargetConnection>
47+
<AlwaysEnforce>true</AlwaysEnforce>
48+
</DefaultFaultRule>
49+
<HTTPTargetConnection>
50+
<LoadBalancer>
51+
<Server name="validated-relationships-service-api"/>
52+
</LoadBalancer>
53+
<Properties>
54+
<Property name="supports.http10">true</Property>
55+
<Property name="request.retain.headers">User-Agent,Referer,Accept-Language</Property>
56+
</Properties>
57+
</HTTPTargetConnection>
5358
</TargetEndpoint>

0 commit comments

Comments
 (0)