Skip to content

Commit e984961

Browse files
committed
Add permission check and audit logging
1 parent 9027d41 commit e984961

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

frontend/src/lib-common/generated/action.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export type Global =
8383
| 'SEARCH_EMPLOYEES'
8484
| 'SEARCH_FEE_DECISIONS'
8585
| 'SEARCH_INVOICES'
86+
| 'SEARCH_PAYMENTS'
8687
| 'SEARCH_PEOPLE'
8788
| 'SEARCH_PEOPLE_UNRESTRICTED'
8889
| 'SEARCH_VOUCHER_VALUE_DECISIONS'

service/src/main/kotlin/fi/espoo/evaka/Audit.kt

+1
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ enum class Audit(
406406
PartnerShipsUpdate,
407407
PartnersInDifferentAddressReportRead,
408408
PatuReportSend,
409+
PaymentsSearch,
409410
PaymentsConfirmDrafts,
410411
PaymentsCreate,
411412
PaymentsDeleteDrafts,

service/src/main/kotlin/fi/espoo/evaka/invoicing/controller/PaymentController.kt

+13-1
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,21 @@ class PaymentController(
3333
fun searchPayments(
3434
db: Database,
3535
user: AuthenticatedUser.Employee,
36+
clock: EvakaClock,
3637
@RequestBody params: SearchPaymentsRequest,
3738
): PagedPayments {
38-
return db.connect { dbc -> dbc.read { tx -> tx.searchPayments(params) } }
39+
return db.connect { dbc ->
40+
dbc.read { tx ->
41+
accessControl.requirePermissionFor(
42+
tx,
43+
user,
44+
clock,
45+
Action.Global.SEARCH_PAYMENTS,
46+
)
47+
tx.searchPayments(params)
48+
}
49+
}
50+
.also { Audit.PaymentsSearch.log(meta = mapOf("total" to it.total)) }
3951
}
4052

4153
@PostMapping("/employee/payments/create-drafts")

service/src/main/kotlin/fi/espoo/evaka/shared/security/Action.kt

+1
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ sealed interface Action {
205205
),
206206
SEARCH_INVOICES(HasGlobalRole(ADMIN, FINANCE_ADMIN, FINANCE_STAFF)),
207207
CREATE_DRAFT_INVOICES(HasGlobalRole(ADMIN, FINANCE_ADMIN)),
208+
SEARCH_PAYMENTS(HasGlobalRole(ADMIN, FINANCE_ADMIN)),
208209
CREATE_DRAFT_PAYMENTS(HasGlobalRole(ADMIN, FINANCE_ADMIN)),
209210
READ_ASSISTANCE_ACTION_OPTIONS(
210211
HasGlobalRole(

0 commit comments

Comments
 (0)