Skip to content

Commit c2143f3

Browse files
committed
NPA-4513 Replace Auth Error
1 parent fc9f024 commit c2143f3

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<!--
3+
This policy raises a 401 error response for an invalid or missing access token.
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.403Forbidden">
11+
<DisplayName>RaiseFault.403Forbidden</DisplayName>
12+
<Properties/>
13+
<FaultResponse>
14+
<Set>
15+
<Headers>
16+
<Header name="Content-Type">application/fhir+json</Header>
17+
</Headers>
18+
<StatusCode>403</StatusCode>
19+
<ReasonPhrase>Forbidden</ReasonPhrase>
20+
<Payload>
21+
{
22+
"issue": [
23+
{
24+
"code": "forbidden",
25+
"details": {
26+
"coding": [
27+
{
28+
"code": "FORBIDDEN",
29+
"display": "Access Denied",
30+
"system": "https://fhir.nhs.uk/R4/CodeSystem/ValidatedRelationships-ErrorOrWarningCode",
31+
"version": "1",
32+
}
33+
]
34+
},
35+
"diagnostics": "Access denied to resource.",
36+
"severity": "error",
37+
}
38+
],
39+
"resourceType": "OperationOutcome",
40+
}
41+
</Payload>
42+
</Set>
43+
</FaultResponse>
44+
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
45+
</RaiseFault>

proxies/live/apiproxy/targets/target.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
<Name>AddUserAuthHeaders</Name>
2222
</Step>
2323
<Step>
24-
<Name>RaiseFault.401Unauthorized</Name>
24+
<Name>RaiseFault.403Forbidden</Name>
2525
<Condition>accesstoken.auth_level != "aal3" and proxy.pathsuffix = "/FHIR/R4/Consent" and request.verb = "POST"</Condition>
2626
</Step>
2727
<Step>
28-
<Name>RaiseFault.401Unauthorized</Name>
28+
<Name>RaiseFault.403Forbidden</Name>
2929
<Condition>accesstoken.auth_level != "p9" and (proxy.pathsuffix != "/FHIR/R4/Consent" or request.verb != "POST")</Condition>
3030
</Step>
3131
<Step>

0 commit comments

Comments
 (0)