Skip to content

Commit 396ed45

Browse files
authored
Merge pull request #347 from nl-portal/feature/implement-filter-machtingdienst
Feature/implement filter machtingsdienst
2 parents 1fd6d6e + 4e81cd5 commit 396ed45

File tree

37 files changed

+599
-33
lines changed

37 files changed

+599
-33
lines changed

app/src/main/resources/config/application.yml

+2
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ nl-portal:
170170
allowedMethods: "*"
171171
endpoints:
172172
unsecured: /api/public/**
173+
machtingsdienst:
174+
#resource-url: classpath:machtigingsdiensten.json
173175
product:
174176
product-type-url: http://host.docker.internal:8011/api/v1/objecttypes/972e92ce-b964-4ca8-ad4d-ddc43dd7b244
175177
product-instantie-type-url: http://host.docker.internal:8011/api/v1/objecttypes/3e852115-277a-4570-873a-9a64be3aeb34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[
2+
{
3+
"uuid":"dd95bdee-c493-4757-bae3-fe0a5b5063f8",
4+
"naam":"Uitvoeren WMO-dienstverlening",
5+
"zaakTypes": [
6+
"dd95bdee-c493-4757-bae3-fe0a5b5063f8"
7+
],
8+
"taakTypes": [
9+
"RMWA"
10+
]
11+
}
12+
]

build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ plugins {
4646

4747
id("org.jetbrains.dokka")
4848

49-
id("org.owasp.dependencycheck") version "11.1.1"
49+
id("org.owasp.dependencycheck") version "12.0.0"
5050

5151
`maven-publish`
5252
`signing`

payment/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ dependencies {
2323
api(project(":graphql"))
2424
api(project(":zgw:taak"))
2525

26-
api("commons-codec", "commons-codec", "1.17.1")
26+
api("commons-codec", "commons-codec", "1.17.2")
2727
testImplementation(project(":zgw:common-ground-authentication-test"))
2828
testImplementation("org.springframework.boot", "spring-boot-starter-test")
2929
testImplementation("org.assertj", "assertj-core")

product/src/main/kotlin/nl/nlportal/product/autoconfiguration/ProductAutoConfiguration.kt

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package nl.nlportal.product.autoconfiguration
1717

18+
import nl.nlportal.commonground.authentication.AuthenticationMachtigingsDienstService
1819
import nl.nlportal.core.ssl.ClientSslContextResolver
1920
import nl.nlportal.product.client.DmnClient
2021
import nl.nlportal.product.client.DmnConfig
@@ -58,6 +59,7 @@ class ProductAutoConfiguration {
5859
taakObjectConfig: TaakObjectConfig,
5960
objectsApiTaskConfig: TaakObjectConfig,
6061
dmnClient: DmnClient,
62+
authenticationMachtigingsDienstService: AuthenticationMachtigingsDienstService,
6163
): ProductService {
6264
return ProductService(
6365
productConfig,
@@ -66,6 +68,7 @@ class ProductAutoConfiguration {
6668
taakObjectConfig,
6769
objectsApiTaskConfig,
6870
dmnClient,
71+
authenticationMachtigingsDienstService,
6972
)
7073
}
7174

product/src/main/kotlin/nl/nlportal/product/graphql/ProductQuery.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class ProductQuery(
8686
dfe: DataFetchingEnvironment,
8787
productTypeId: UUID? = null,
8888
productName: String,
89-
pageSize: Int? = 20,
89+
pageSize: Int? = null,
9090
isOpen: Boolean? = null,
9191
): List<Zaak> {
9292
return productService.getProductZaken(

product/src/main/kotlin/nl/nlportal/product/service/ProductService.kt

+21-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package nl.nlportal.product.service
1717

1818
import com.fasterxml.jackson.databind.node.ObjectNode
1919
import mu.KotlinLogging
20+
import nl.nlportal.commonground.authentication.AuthenticationMachtigingsDienstService
2021
import nl.nlportal.commonground.authentication.CommonGroundAuthentication
2122
import nl.nlportal.core.util.Mapper
2223
import nl.nlportal.product.client.DmnClient
@@ -50,6 +51,7 @@ class ProductService(
5051
val taakObjectConfig: TaakObjectConfig,
5152
val objectsApiTaskConfig: TaakObjectConfig,
5253
val dmnClient: DmnClient,
54+
val authenticationMachtigingsDienstService: AuthenticationMachtigingsDienstService,
5355
) {
5456
suspend fun getProduct(
5557
authentication: CommonGroundAuthentication,
@@ -154,17 +156,30 @@ class ProductService(
154156
return emptyList()
155157
}
156158

159+
// val zaakTypes = mutableSetOf<UUID>()
160+
val zaakTypes = productType.zaaktypen
157161
val request =
158162
zakenApiClient.zoeken()
159163
.search()
160164
.page(pageNumber)
161165
.withAuthentication(authentication)
162-
.ofZaakTypes(productType.zaaktypen.map { it })
163166
pageSize?.let { request.pageSize(it) }
164167
isOpen?.let {
165168
request.isOpen(isOpen)
166169
}
167170

171+
/*authenticationMachtigingsDienstService.zaakTypes(authentication)?.let {
172+
zaakTypes.addAll(it)
173+
}*/
174+
175+
if (!authenticationMachtigingsDienstService.isAllowedZaakTypes(authentication, zaakTypes)) {
176+
return emptyList()
177+
}
178+
179+
if (zaakTypes.isNotEmpty()) {
180+
request.ofZaakTypes(zaakTypes.toList())
181+
}
182+
168183
authentication.getVestigingsNummer()?.let {
169184
request.ofVestigingsNummer(it)
170185
}
@@ -346,12 +361,16 @@ class ProductService(
346361
pageSize: Int,
347362
): List<TaakV2> {
348363
val objectSearchParameters =
349-
listOf(
364+
mutableListOf(
350365
ObjectSearchParameter("identificatie__type", Comparator.EQUAL_TO, authentication.userType),
351366
ObjectSearchParameter("identificatie__value", Comparator.EQUAL_TO, authentication.userId),
352367
ObjectSearchParameter("status", Comparator.EQUAL_TO, "open"),
353368
)
354369

370+
authenticationMachtigingsDienstService.taakTypes(authentication)?.let {
371+
objectSearchParameters.add(ObjectSearchParameter("eigenaar", Comparator.IN_LIST, it.joinToString("|")))
372+
}
373+
355374
return getObjectsApiObjectResultPage<TaakObjectV2>(
356375
objectsApiTaskConfig.typeUrlV2,
357376
objectSearchParameters,

product/src/test/kotlin/nl/nlportal/product/graphql/ProductQueryIT.kt

+39
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package nl.nlportal.product.graphql
1717

18+
import nl.nlportal.commonground.authentication.WithBedrijfUser
1819
import nl.nlportal.commonground.authentication.WithBurgerUser
1920
import nl.nlportal.product.TestHelper
2021
import nl.nlportal.product.TestHelper.verifyOnlyDataExists
@@ -197,6 +198,24 @@ internal class ProductQueryIT(
197198
.jsonPath("$basePath[0].omschrijving").isEqualTo("Lopende zaak")
198199
}
199200

201+
@Test
202+
@WithBedrijfUser(
203+
kvkNummer = "569312863",
204+
machtigingsDienst = "dd95bdee-c493-4757-bae3-fe0a5b5063f8",
205+
)
206+
fun getProductZakenTestBedrijf() {
207+
val basePath = "$.data.getProductZaken"
208+
209+
testClient.post()
210+
.uri("/graphql")
211+
.accept(MediaType.APPLICATION_JSON)
212+
.contentType(MediaType("application", "graphql"))
213+
.bodyValue(graphqlGetProductZaken)
214+
.exchange()
215+
.verifyOnlyDataExists(basePath)
216+
.jsonPath("$basePath[0].omschrijving").isEqualTo("Lopende zaak")
217+
}
218+
200219
@Test
201220
@WithBurgerUser("569312863")
202221
fun getProductZakenTestBurgerNoZaakTypes() {
@@ -293,6 +312,26 @@ internal class ProductQueryIT(
293312
.jsonPath("$basePath[0].titel").isEqualTo("Taak linked to Zaak")
294313
}
295314

315+
@Test
316+
@WithBedrijfUser(
317+
kvkNummer = "569312863",
318+
machtigingsDienst = "dd95bdee-c493-4757-bae3-fe0a5b5063f8",
319+
)
320+
fun getProductTakenTestBedrijf() {
321+
val basePath = "$.data.getProductTaken"
322+
323+
testClient.post()
324+
.uri("/graphql")
325+
.accept(MediaType.APPLICATION_JSON)
326+
.contentType(MediaType("application", "graphql"))
327+
.bodyValue(graphqlGetProductTaken)
328+
.exchange()
329+
.verifyOnlyDataExists(basePath)
330+
.jsonPath("$basePath.size()").isEqualTo(2)
331+
.jsonPath("$basePath[0].id").isEqualTo("2d725c07-2f26-4705-8637-438a42b5ac2d")
332+
.jsonPath("$basePath[0].titel").isEqualTo("Taak linked to Zaak")
333+
}
334+
296335
@Test
297336
@WithBurgerUser("569312864")
298337
fun getProductTakenTestBurgerNoTaken() {

product/src/test/resources/config/application.yml

+4
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ nl-portal:
6161
prefill:
6262
type-url: http://host.docker.internal:8011/api/v1/objecttypes/3e852115-277a-4570-873a-9a64be3aeb37
6363
remove-objects: true
64+
security:
65+
machtingsdienst:
66+
resource-url: classpath:machtigingsdiensten.json
67+
6468

6569
spring:
6670
security:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[
2+
{
3+
"uuid":"dd95bdee-c493-4757-bae3-fe0a5b5063f8",
4+
"naam":"Uitvoeren WMO-dienstverlening",
5+
"zaakTypes": [
6+
"dd95bdee-c493-4757-bae3-fe0a5b5063f8",
7+
"7d9cd6c2-8147-46f2-9ae9-c67e8213c300"
8+
],
9+
"taakTypes": [
10+
"RMWA",
11+
"WMO"
12+
]
13+
}
14+
]

zgw/common-ground-authentication-test/src/main/kotlin/nl/nlportal/commonground/authentication/JwtBuilder.kt

+6
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ class JwtBuilder {
9595
return this
9696
}
9797

98+
fun machtingDienstKvk(machtingDienst: String): JwtBuilder {
99+
jwtBuilder.claim(MACHTIGINGSDIENST_KEY, machtingDienst)
100+
101+
return this
102+
}
103+
98104
fun buildJwt(): Jwt {
99105
if (this.aanvragerBsn == null && this.aanvragerKvk == null && this.aanvragerUid == null) {
100106
throw IllegalStateException("aanvrager needs to be set with either bsn or kvk")

zgw/common-ground-authentication-test/src/main/kotlin/nl/nlportal/commonground/authentication/WithBedrijfUser.kt

+1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ annotation class WithBedrijfUser(
2727
val gemachtigdeBsn: String = "",
2828
val gemachtigdeKvk: String = "",
2929
val vestigingsNummer: String = "",
30+
val machtigingsDienst: String = "",
3031
)

zgw/common-ground-authentication-test/src/main/kotlin/nl/nlportal/commonground/authentication/WithBedrijfUserSecurityContextFactory.kt

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ class WithBedrijfUserSecurityContextFactory : WithSecurityContextFactory<WithBed
3333
if (!bedrijf.vestigingsNummer.isEmpty()) {
3434
builder.vestigingsNummerKvk(bedrijf.vestigingsNummer)
3535
}
36+
if (!bedrijf.machtigingsDienst.isEmpty()) {
37+
builder.machtingDienstKvk(bedrijf.machtigingsDienst)
38+
}
3639
context.authentication = builder.buildBedrijfAuthentication()
3740

3841
return context

zgw/common-ground-authentication/src/main/kotlin/nl/nlportal/commonground/authentication/AuthenticationConfiguration.kt

+12-1
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,22 @@ import org.springframework.boot.autoconfigure.AutoConfiguration
2020
import org.springframework.boot.context.properties.EnableConfigurationProperties
2121
import org.springframework.context.annotation.Bean
2222
import org.springframework.core.annotation.Order
23+
import org.springframework.core.io.ResourceLoader
2324
import org.springframework.security.oauth2.jwt.ReactiveJwtDecoder
2425

25-
@EnableConfigurationProperties(KeycloakConfig::class)
26+
@EnableConfigurationProperties(KeycloakConfig::class, AuthenticationMachtigingsDienstConfig::class)
2627
@AutoConfiguration
2728
class AuthenticationConfiguration {
29+
@Bean
30+
fun authenticationMachtigingsDienstService(
31+
authenticationMachtigingsDienstConfig: AuthenticationMachtigingsDienstConfig,
32+
resourceLoader: ResourceLoader,
33+
): AuthenticationMachtigingsDienstService =
34+
AuthenticationMachtigingsDienstService(
35+
authenticationMachtigingsDienstConfig,
36+
resourceLoader,
37+
)
38+
2839
@Order(value = 0)
2940
@Bean
3041
fun commonGroundAuthenticationConverter(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright 2015-2023 Ritense BV, the Netherlands.
3+
*
4+
* Licensed under EUPL, Version 1.2 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" basis,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package nl.nlportal.commonground.authentication
17+
18+
import java.util.UUID
19+
20+
data class AuthenticationMachtigingsDienst(
21+
val uuid: UUID,
22+
val naam: String,
23+
val zaakTypes: List<UUID> = listOf(),
24+
val taakTypes: List<String> = listOf(),
25+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2015-2023 Ritense BV, the Netherlands.
3+
*
4+
* Licensed under EUPL, Version 1.2 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" basis,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package nl.nlportal.commonground.authentication
17+
18+
import org.springframework.boot.context.properties.ConfigurationProperties
19+
20+
@ConfigurationProperties(prefix = "nl-portal.security.machtingsdienst")
21+
data class AuthenticationMachtigingsDienstConfig(
22+
val resourceUrl: String? = null,
23+
)

0 commit comments

Comments
 (0)