From c84ce8fad89e3b24440d44eeb0480c7bd28c4156 Mon Sep 17 00:00:00 2001 From: Henrik Kolberg Date: Tue, 20 Aug 2024 08:37:00 +0200 Subject: [PATCH 1/4] Token for kall mot kodeverk --- pom.xml | 25 ++++++++++++++++--- .../client/yrkeskoder/YrkeskodeverkClient.kt | 6 ++++- src/main/resources/application.yaml | 4 +++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 8a0aaa47..8e74d083 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ 17 - 1.8.21 + 2.0.10 1.6.4 3.1.0 @@ -190,12 +190,28 @@ org.springframework.boot spring-boot-starter-actuator + + org.jetbrains.kotlin + kotlin-test + ${kotlin.version} + test + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + ${kotlin.version} + - ${project.basedir}/src/main/kotlin/ - ${project.basedir}/src/test/kotlin/ + src/main/kotlin + src/test/kotlin org.springframework.boot @@ -217,16 +233,19 @@ spring + 1.8 compile + compile compile test-compile + test-compile test-compile diff --git a/src/main/kotlin/no/nav/tag/innsynAareg/client/yrkeskoder/YrkeskodeverkClient.kt b/src/main/kotlin/no/nav/tag/innsynAareg/client/yrkeskoder/YrkeskodeverkClient.kt index 2017961d..6b91615e 100644 --- a/src/main/kotlin/no/nav/tag/innsynAareg/client/yrkeskoder/YrkeskodeverkClient.kt +++ b/src/main/kotlin/no/nav/tag/innsynAareg/client/yrkeskoder/YrkeskodeverkClient.kt @@ -1,5 +1,6 @@ package no.nav.tag.innsynAareg.client.yrkeskoder +import no.nav.tag.innsynAareg.client.azure.AzureClient import no.nav.tag.innsynAareg.client.yrkeskoder.YrkeskodeverkCacheConfig.Companion.YRKESKODE_CACHE import no.nav.tag.innsynAareg.client.yrkeskoder.dto.Yrkeskoderespons import no.nav.tag.innsynAareg.models.Yrkeskoder @@ -15,7 +16,9 @@ import java.util.* @Service class YrkeskodeverkClient @Autowired constructor( private val restTemplate: RestTemplate, - @Value("\${yrkeskodeverk.yrkeskodeUrl}") val yrkeskodeUrl: String + @Value("\${yrkeskodeverk.yrkeskodeUrl}") val yrkeskodeUrl: String, + private val azureClient: AzureClient, + @Value("\${yrkeskodeverk.yrkeskodeScope}") private val yrkeskodeScope: String ) { private val logger = LoggerFactory.getLogger(YrkeskodeverkClient::class.java)!! @@ -32,6 +35,7 @@ class YrkeskodeverkClient @Autowired constructor( headers.contentType = MediaType.APPLICATION_FORM_URLENCODED headers["Nav-Call-Id"] = UUID.randomUUID().toString() headers["Nav-Consumer-Id"] = "srvAG-Arbforhold" + headers.setBearerAuth(azureClient.getToken(yrkeskodeScope)) restTemplate.exchange( yrkeskodeUrl, HttpMethod.GET, diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index a00f6b93..e4fd5278 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -55,6 +55,7 @@ aareg: yrkeskodeverk: yrkeskodeUrl: "http://localhost:${mock.port}/kodeverk/api/" + yrkeskodeScope: "scope" pdl: pdlUrl: "http://localhost:${mock.port}/graphql" @@ -103,6 +104,7 @@ aareg: yrkeskodeverk: yrkeskodeUrl: "http://localhost:${mock.port}/kodeverk/api/" + yrkeskodeScope: "scope" pdl: pdlUrl: "http://localhost:${mock.port}/graphql" @@ -136,6 +138,7 @@ no.nav.security.jwt.issuer.tokenx: yrkeskodeverk: yrkeskodeUrl: "https://kodeverk-api.nav.no/api/v1/kodeverk/Yrker/koder/betydninger?spraak=nb" + yrkeskodeScope: "api://dev-gcp.team-rocket.kodeverk-api/.default" sts: stsPass: ${STS_PASS} @@ -185,6 +188,7 @@ azure: yrkeskodeverk: yrkeskodeUrl: "https://kodeverk-api.nav.no/api/v1/kodeverk/Yrker/koder/betydninger?spraak=nb&spraak=nn" + yrkeskodeScope: "api://prod-gcp.team-rocket.kodeverk-api/.default" pdl: pdlUrl: "https://pdl-api.intern.nav.no/graphql" From c1d30e3f79a8949210e8dc209f805c327ae48f70 Mon Sep 17 00:00:00 2001 From: Henrik Kolberg Date: Tue, 20 Aug 2024 08:40:58 +0200 Subject: [PATCH 2/4] satt tilbake i pom --- pom.xml | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/pom.xml b/pom.xml index 8e74d083..6774bd0f 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ 17 - 2.0.10 + 1.8.21 1.6.4 3.1.0 @@ -190,28 +190,12 @@ org.springframework.boot spring-boot-starter-actuator - - org.jetbrains.kotlin - kotlin-test - ${kotlin.version} - test - - - org.jetbrains.kotlin - kotlin-stdlib-jdk8 - ${kotlin.version} - - - org.jetbrains.kotlin - kotlin-stdlib-jdk8 - ${kotlin.version} - - src/main/kotlin - src/test/kotlin + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/test/kotlin org.springframework.boot @@ -233,18 +217,15 @@ spring - 1.8 compile - compile compile - test-compile test-compile test-compile From 1bf36f8d254122e90aad56b9762d0c17ffe0b3fb Mon Sep 17 00:00:00 2001 From: Henrik Kolberg Date: Tue, 20 Aug 2024 08:43:14 +0200 Subject: [PATCH 3/4] satt tilbake i pom --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 6774bd0f..8a0aaa47 100644 --- a/pom.xml +++ b/pom.xml @@ -194,8 +194,8 @@ - ${project.basedir}/src/main/kotlin - ${project.basedir}/src/test/kotlin + ${project.basedir}/src/main/kotlin/ + ${project.basedir}/src/test/kotlin/ org.springframework.boot @@ -226,7 +226,7 @@ - test-compile + test-compile test-compile From 27af81b0716174fe46023c7ce2bd6a8e39ec340b Mon Sep 17 00:00:00 2001 From: Henrik Kolberg Date: Tue, 20 Aug 2024 08:49:20 +0200 Subject: [PATCH 4/4] Lagt til outbound rule --- nais/dev-fss.yaml | 3 +++ nais/prod-fss.yaml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/nais/dev-fss.yaml b/nais/dev-fss.yaml index f448a432..4a6f4f00 100644 --- a/nais/dev-fss.yaml +++ b/nais/dev-fss.yaml @@ -69,3 +69,6 @@ spec: - application: pdl-api namespace: pdl cluster: dev-fss + - application: kodeverk-api + namespace: team-rocket + cluster: dev-fss \ No newline at end of file diff --git a/nais/prod-fss.yaml b/nais/prod-fss.yaml index e99d0bd7..90020118 100644 --- a/nais/prod-fss.yaml +++ b/nais/prod-fss.yaml @@ -75,4 +75,7 @@ spec: cluster: prod-gcp - application: pdl-api namespace: pdl + cluster: prod-fss + - application: kodeverk-api + namespace: team-rocket cluster: prod-fss \ No newline at end of file