Skip to content

Commit ff82265

Browse files
feat(frd-kpi): PPABV-98 add authorizer check for fdr kpi (#2675)
* feat(frd-kpi): add authorizer check for fdr kpi * feat: add new psps id as query param * chore: check for brokerId * chore: brokerFiscalCode as query param * fix: update broker as query param * fix: typo * chore: check brokerFiscalCode as first
1 parent d9a2026 commit ff82265

File tree

2 files changed

+39
-31
lines changed

2 files changed

+39
-31
lines changed

src/domains/qi-app/api/qi-fdr-kpi-api/v1/_base_policy.xml.tpl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
<policies>
22
<inbound>
33
<base />
4+
<!-- Calling Authorizer's fragment START -->
5+
<set-variable name="application_domain" value="qi" />
6+
<set-variable name="authCheck"
7+
value="@((string)context.Request.Url.Query.GetValueOrDefault("brokerFiscalCode", "") != ""
8+
? context.Request.Url.Query.GetValueOrDefault("brokerFiscalCode", "")
9+
: context.Request.Url.Query.GetValueOrDefault("pspId", ""))"/>
10+
11+
<choose>
12+
<!-- Making sure that will excludes all APIs that does not includes CI fiscal code -->
13+
<when condition="@(context.Variables.GetValueOrDefault("authCheck","") != "")">
14+
<set-variable name="authorization_entity" value="@(context.Variables.GetValueOrDefault("authCheck",""))" />
15+
<include-fragment fragment-id="authorizer" />
16+
</when>
17+
<otherwise>
18+
<return-response>
19+
<set-status code="403" reason="Unauthorized" />
20+
</return-response>
21+
</otherwise>
22+
</choose>
23+
<!-- Calling Authorizer's fragment END -->
424
<set-backend-service base-url="https://${hostname}/pagopa-qi-fdr-kpi-service" />
525
</inbound>
626
<outbound>

src/domains/qi-app/api/qi-fdr-kpi-api/v1/_openapi.json.tpl

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
}
1818
],
1919
"paths": {
20-
"/fdr-kpi/{kpiType}/{period}": {
20+
"/fdr-kpi/{kpiType}": {
2121
"get": {
2222
"tags": [
2323
"qiFdr"
@@ -39,9 +39,18 @@
3939
},
4040
"description": "The type of KPI to calculate\n"
4141
},
42+
{
43+
"name": "brokerFiscalCode",
44+
"in": "query",
45+
"required": false,
46+
"schema": {
47+
"type": "string"
48+
},
49+
"description": "Broker fiscal code \n"
50+
},
4251
{
4352
"name": "period",
44-
"in": "path",
53+
"in": "query",
4554
"required": true,
4655
"schema": {
4756
"type": "string",
@@ -62,6 +71,14 @@
6271
"example": "2024-09"
6372
},
6473
"description": "For daily KPIs: Specify the full date (YYYY-MM-DD). Must be at least 10 days before current date.\nFor monthly KPIs: Specify year and month (YYYY-MM).\n"
74+
},
75+
{
76+
"name": "pspId",
77+
"in": "query",
78+
"required": false,
79+
"schema": {
80+
"type": "string"
81+
}
6582
}
6683
],
6784
"responses": {
@@ -177,35 +194,6 @@
177194
}
178195
]
179196
},
180-
"PSPIdentifier": {
181-
"type": "object",
182-
"required": [
183-
"idPsp"
184-
],
185-
"properties": {
186-
"idPsp": {
187-
"type": "string",
188-
"example": "CIPBITMM"
189-
}
190-
}
191-
},
192-
"BrokerIdentifier": {
193-
"type": "object",
194-
"required": [
195-
"idBrokerPsp",
196-
"idPsp"
197-
],
198-
"properties": {
199-
"idBrokerPsp": {
200-
"type": "string",
201-
"example": "02654890025"
202-
},
203-
"idPsp": {
204-
"type": "string",
205-
"example": "CIPBITMM"
206-
}
207-
}
208-
},
209197
"DailyKPIBase": {
210198
"type": "object",
211199
"required": [

0 commit comments

Comments
 (0)