Skip to content

Commit 90e874f

Browse files
NPA-4599: Block resources rather than specify only valid resources
1 parent 87e0cb8 commit 90e874f

File tree

3 files changed

+18
-22
lines changed

3 files changed

+18
-22
lines changed

proxies/live/apiproxy/resources/py/check-app-enabled-endpoint.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
requested_endpoint = (path_suffix, request_verb)
55

66

7-
auth_permitted = requested_endpoint in [("/FHIR/R4/Consent", "GET")]
7+
auth_forbidden = requested_endpoint in [
8+
("/FHIR/R4/RelatedPerson", "GET"),
9+
("/FHIR/R4/Questionnaire", "GET"),
10+
("/FHIR/R4/QuestionnaireResponse", "POST"),
11+
("/FHIR/R4/QuestionnaireResponse", "GET"),
12+
("/FHIR/R4/Consent", "POST"),
13+
("/FHIR/R4/Consent", "PATCH"),
14+
]
815

9-
flow.setVariable("app_auth_permitted", auth_permitted)
16+
flow.setVariable("app_auth_forbidden", auth_forbidden)

proxies/live/apiproxy/resources/py/user-enabled-endpoint.py

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,15 @@
22
path_suffix = flow.getVariable("proxy.pathsuffix")
33
request_verb = flow.getVariable("request.verb")
44

5-
requested_endpoint = (path_suffix, request_verb)
5+
requested_resource = (path_suffix, request_verb)
66

77
if auth_level == "p9":
8-
auth_permitted = requested_endpoint in [
9-
("/FHIR/R4/RelatedPerson", "GET"),
10-
("/FHIR/R4/QuestionnaireResponse", "POST"),
11-
("/FHIR/R4/QuestionnaireResponse", "GET"),
12-
("/FHIR/R4/Consent", "GET"),
13-
("/FHIR/R4/Consent", "PATCH"),
14-
]
8+
blocked_resources = [("/FHIR/R4/Questionnaire", "GET"), ("/FHIR/R4/Consent", "POST")]
159
elif auth_level == "all3":
16-
auth_permitted = requested_endpoint in [
17-
("/FHIR/R4/RelatedPerson", "GET"),
18-
("/FHIR/R4/Questionnaire", "GET"),
19-
("/FHIR/R4/QuestionnaireResponse", "GET"),
20-
("/FHIR/R4/Consent", "GET"),
21-
("/FHIR/R4/Consent", "POST"),
22-
("/FHIR/R4/Consent", "PATCH"),
23-
]
10+
blocked_resources = [("/FHIR/R4/QuestionnaireResponse", "GET")]
2411
else:
25-
auth_permitted = False
12+
blocked_resources = []
2613

27-
flow.setVariable("user_auth_permitted", auth_permitted)
14+
auth_forbidden = requested_resource in blocked_resources
15+
16+
flow.setVariable("user_auth_forbidden", auth_forbidden)

proxies/live/apiproxy/targets/target.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</Step>
3232
<Step>
3333
<Name>RaiseFault.403Forbidden</Name>
34-
<Condition>app_auth_permitted != true</Condition>
34+
<Condition>app_auth_forbidden = true</Condition>
3535
</Step>
3636
<Step>
3737
<Name>AddUserAuthHeaders</Name>
@@ -46,7 +46,7 @@
4646
</Step>
4747
<Step>
4848
<Name>RaiseFault.403Forbidden</Name>
49-
<Condition>user_auth_permitted != true</Condition>
49+
<Condition>user_auth_forbidden = true</Condition>
5050
</Step>
5151
<Step>
5252
<Name>DecodeAccessTokenJWT</Name>

0 commit comments

Comments
 (0)