Skip to content

Commit

Permalink
Eksponerer prod mot gcp, fjernet public routes = krever saksbehandler…
Browse files Browse the repository at this point in the history
… token for alle endpoints (#1102)

* nais config

* typo

* Fjernet publicroutes, krever token for alle endepunkter, fikset tester

---------

Co-authored-by: albrektsson <[email protected]>
  • Loading branch information
vebnor and albrektsson authored Feb 19, 2024
1 parent 7dea8f2 commit 875a202
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ COPY docker-init-scripts/import-serviceuser-credentials.sh /init-scripts/21-impo
COPY docker-init-scripts/import-appdynamics-settings.sh /init-scripts/22-import-appdynamics-settings.sh


COPY target/*.jar app.jar
COPY target/*.jar app.jar
4 changes: 4 additions & 0 deletions nais/prod-fss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ spec:
rules:
- application: k9-punsj-oidc-auth-proxy
- application: k9-sak
- application: k9-punsj-frontend
namespace: k9saksbehandling
cluster: prod-gcp
liveness:
path: /internal/actuator/info
initialDelay: 20
Expand All @@ -38,6 +41,7 @@ spec:
ingresses:
- https://k9-punsj.nais.adeo.no
- https://k9-punsj.intern.nav.no
- https://k9-punsj.prod-fss-pub.nais.io
replicas:
min: 1
max: 1
Expand Down
4 changes: 0 additions & 4 deletions src/main/kotlin/no/nav/k9punsj/CoroutineRequestContext.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ internal fun SaksbehandlerRoutes(
setOf("azurev2")
) { true }

internal fun PublicRoutes(
routes: CoRouterFunctionDsl.() -> Unit
) = Routes(null, routes, null, null)

private fun Routes(
authenticationHandler: AuthenticationHandler?,
routes: CoRouterFunctionDsl.() -> Unit,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package no.nav.k9punsj.integrasjoner.arbeidsgivere

import no.nav.k9punsj.PublicRoutes
import no.nav.k9punsj.RequestContext
import no.nav.k9punsj.SaksbehandlerRoutes
import no.nav.k9punsj.tilgangskontroll.AuthenticationHandler
Expand Down Expand Up @@ -97,7 +96,7 @@ internal class ArbeidsgiverRoutes(
}

@Bean
fun hentArbeidsgiverInfoRoute() = PublicRoutes {
fun hentArbeidsgiverInfoRoute() = SaksbehandlerRoutes(authenticationHandler) {
GET("/api/arbeidsgiver") { request ->
RequestContext(coroutineContext, request) {
when (val navn = arbeidsgiverService.hentOrganisasjonsnavn(request.organisasjonsnummer())) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package no.nav.k9punsj.integrasjoner.gosys

import kotlinx.coroutines.reactive.awaitFirst
import no.nav.k9punsj.PublicRoutes
import no.nav.k9punsj.RequestContext
import no.nav.k9punsj.SaksbehandlerRoutes
import no.nav.k9punsj.felles.IkkeTilgang
Expand Down Expand Up @@ -29,7 +28,7 @@ internal class GosysRoutes(
}

@Bean
fun PublicGosysRoutes() = PublicRoutes {
fun PublicGosysRoutes() = SaksbehandlerRoutes(authenticationHandler) {
GET("/api${Urls.Gjelder}") {
return@GET ServerResponse
.status(HttpStatus.OK)
Expand Down
8 changes: 5 additions & 3 deletions src/test/kotlin/no/nav/k9punsj/fordel/LokalHendelseRoutes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package no.nav.k9punsj.fordel

import kotlinx.coroutines.reactive.awaitFirst
import no.nav.k9punsj.LokalProfil
import no.nav.k9punsj.PublicRoutes
import no.nav.k9punsj.RequestContext
import no.nav.k9punsj.SaksbehandlerRoutes
import no.nav.k9punsj.tilgangskontroll.AuthenticationHandler
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.http.HttpStatus
Expand All @@ -17,15 +18,16 @@ import kotlin.coroutines.coroutineContext
@Configuration
@LokalProfil
class LokalHendelseRoutes(
private val hendelseMottaker: HendelseMottaker
private val hendelseMottaker: HendelseMottaker,
private val authenticationHandler: AuthenticationHandler
) {

internal object Urls {
internal const val ProsesserHendelse = "/prosesserHendelse/"
}

@Bean
fun prosesserHendelseRoute() = PublicRoutes {
fun prosesserHendelseRoute() = SaksbehandlerRoutes(authenticationHandler) {
POST("/api${Urls.ProsesserHendelse}", contentType(MediaType.APPLICATION_JSON)) { request ->
RequestContext(coroutineContext, request) {
val fordelPunsjEventDto = request.request()
Expand Down
1 change: 1 addition & 0 deletions src/test/kotlin/no/nav/k9punsj/gosys/GosysRoutesTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ internal class GosysRoutesTest: AbstractContainerBaseTest() {
fun `hente gyldige verdier for gjelder`() {
webTestClient.get()
.uri{ it.path("/api/gosys/gjelder").build() }
.header(HttpHeaders.AUTHORIZATION, saksbehandlerAuthorizationHeader)
.exchange()
.expectStatus().isOk
.expectBody().json(Gjelder.JSON)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ internal class ArbeidsgivereRoutesTest : AbstractContainerBaseTest() {
fun `hente navn på arbeidsgiver som finnes`() {
webTestClient.get()
.uri { it.path("/api/arbeidsgiver").queryParam("organisasjonsnummer", "979312059").build() }
.header(HttpHeaders.AUTHORIZATION, saksbehandlerAuthorizationHeader)
.exchange()
.expectStatus().isOk
.expectBody().json("""{"navn":"NAV AS"}""")
Expand All @@ -61,6 +62,7 @@ internal class ArbeidsgivereRoutesTest : AbstractContainerBaseTest() {
fun `hente navn på arbeidsgiver som ikke finnes`() {
webTestClient.get()
.uri { it.path("/api/arbeidsgiver").queryParam("organisasjonsnummer", "993110469").build() }
.header(HttpHeaders.AUTHORIZATION, saksbehandlerAuthorizationHeader)
.exchange()
.expectStatus().isNotFound
}
Expand Down

0 comments on commit 875a202

Please sign in to comment.