Skip to content

Commit

Permalink
EY-2660 Fjernet ubrukte endepunkter for aareg og inntekskomponenten
Browse files Browse the repository at this point in the history
- Disse brukes ikke, og kan også integreres med uten bruk av vår proxy
- La til konfigurasjon for tilbakekreving i nais-filene
  • Loading branch information
henrikg committed Sep 26, 2023
1 parent f9ff0e4 commit 0a7a50f
Show file tree
Hide file tree
Showing 15 changed files with 90 additions and 280 deletions.
14 changes: 5 additions & 9 deletions apps/etterlatte-proxy/.nais/dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,20 @@ spec:
azure:
application:
enabled: true
tokenx:
enabled: true
webproxy: true
env:
- name: STS_REST_URL
value: http://security-token-service.default.svc.nais.local/rest/v1/sts/token
- name: STS_SOAP_URL
value: https://sts-q1.preprod.local/SecurityTokenServiceProvider/
- name: INNTEKTSKOMPONENTEN_URL
value: https://app-q2.adeo.no/inntektskomponenten-ws/rs/api/v1/hentinntektliste
- name: AAREG_URL
value: https://aareg-services.dev.intern.nav.no/api/v2
- name: REGOPPSLAG_URL
value: https://regoppslag.dev.intern.nav.no/rest
- name: INSTITUSJONSOPPHOLD_URL
value: https://inst2-q2.dev.intern.nav.no
- name: INSTITUSJONSOPPHOLD_AZURE_SCOPE
value: api://dev-fss.team-rocket.inst2-q2/.default
- name: TILBAKEKREVING_URL
value: https://cics-q1.adeo.no/oppdrag/K231CW80
prometheus:
enabled: true
path: /internal/prometheus
Expand All @@ -74,12 +70,12 @@ spec:
- application: sjekk-adressebeskyttelse
namespace: etterlatte
cluster: dev-gcp
- application: etterlatte-pdltjenester
namespace: etterlatte
cluster: dev-gcp
- application: etterlatte-brev-api
namespace: etterlatte
cluster: dev-gcp
- application: etterlatte-institusjonsopphold
namespace: etterlatte
cluster: dev-gcp
- application: etterlatte-tilbakekreving
namespace: etterlatte
cluster: dev-gcp
9 changes: 5 additions & 4 deletions apps/etterlatte-proxy/.nais/prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,8 @@ spec:
azure:
application:
enabled: true
tokenx:
enabled: true
webproxy: true
env:
- name: AAREG_URL
value: https://aareg-services.intern.nav.no/api/v2
- name: REGOPPSLAG_URL
value: https://regoppslag.intern.nav.no/rest
- name: STS_REST_URL
Expand All @@ -57,6 +53,8 @@ spec:
value: https://inst2.intern.nav.no
- name: INSTITUSJONSOPPHOLD_AZURE_SCOPE
value: api://prod-fss.team-rocket.inst2/.default
- name: TILBAKEKREVING_URL
value: https://cics.adeo.no/oppdrag/K231CW80
prometheus:
enabled: true
path: /internal/prometheus
Expand All @@ -76,5 +74,8 @@ spec:
namespace: etterlatte
cluster: prod-gcp
- application: etterlatte-institusjonsopphold
namespace: etterlatte
cluster: prod-gcp
- application: etterlatte-tilbakekreving
namespace: etterlatte
cluster: prod-gcp
16 changes: 5 additions & 11 deletions apps/etterlatte-proxy/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import java.net.URI

plugins {
id("etterlatte.common")
}
Expand Down Expand Up @@ -30,17 +28,13 @@ dependencies {
implementation(Ktor.OkHttp)
implementation(NavFelles.NavFellesTokenClientCore)
implementation(NavFelles.TjenestespesifikasjonerTilbakekreving)
implementation(Cxf.cxfLogging)
implementation(Cxf.cxfJaxWs)
implementation(Cxf.cxfTransportsHttp)
implementation(Cxf.cxfWsSecurity)

implementation(Cxf.CxfLogging)
implementation(Cxf.CxfJaxWs)
implementation(Cxf.CxfTransportsHttp)
implementation(Cxf.CxfWsSecurity)
implementation(Micrometer.Prometheus)
implementation(Jackson.jacksonDatatypejsr310)

testImplementation(NavFelles.MockOauth2Server)

testImplementation(Ktor.ServerTests)

implementation(Micrometer.Prometheus)
implementation("org.json:json:20180813")
}
7 changes: 1 addition & 6 deletions apps/etterlatte-proxy/src/main/kotlin/Application.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import no.nav.etterlatte.auth.installAuthentication
import no.nav.etterlatte.auth.sts.StsRestClient
import no.nav.etterlatte.config.TilbakekrevingConfig
import no.nav.etterlatte.config.load
import no.nav.etterlatte.routes.aaregRoute
import no.nav.etterlatte.routes.inntektskomponentenRoute
import no.nav.etterlatte.routes.institusjonsoppholdRoute
import no.nav.etterlatte.routes.internalRoute
import no.nav.etterlatte.routes.regoppslagRoute
Expand All @@ -28,12 +26,11 @@ import java.util.*

fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)

@Suppress("unused") // Referenced in application.conf
fun Application.module() {
val config = runBlocking { environment.config.load() }
val stsClient = StsRestClient(config.sts)

installAuthentication(config.aad, config.tokenX)
installAuthentication(config.aad)
install(ContentNegotiation) { jackson() }
install(IgnoreTrailingSlash)
install(CallLogging) {
Expand All @@ -52,8 +49,6 @@ fun Application.module() {

authenticate("aad") {
route("/aad") {
inntektskomponentenRoute(config, stsClient)
aaregRoute(config, stsClient)
regoppslagRoute(config, stsClient)
institusjonsoppholdRoute(config)
tilbakekrevingRoute(TilbakekrevingConfig(config).createTilbakekrevingService())
Expand Down
25 changes: 1 addition & 24 deletions apps/etterlatte-proxy/src/main/kotlin/auth/Authentication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,7 @@ import no.nav.etterlatte.config.Config
import java.net.URL
import java.util.concurrent.TimeUnit

fun Application.installAuthentication(configAad: Config.AAD, configTokeX: Config.TokenX) {
val jwkProvider = JwkProviderBuilder(URL(configTokeX.metadata.jwksUri))
// cache up to 10 JWKs for 24 hours
.cached(10, 24, TimeUnit.HOURS)
// if not cached, only allow max 10 different keys per minute to be fetched from external provider
.rateLimited(10, 1, TimeUnit.MINUTES)
.build()

fun Application.installAuthentication(configAad: Config.AAD) {
val jwkProviderAad = JwkProviderBuilder(URL(configAad.metadata.jwksUri))
// cache up to 10 JWKs for 24 hours
.cached(10, 24, TimeUnit.HOURS)
Expand All @@ -26,22 +19,6 @@ fun Application.installAuthentication(configAad: Config.AAD, configTokeX: Config
.build()

install(Authentication) {
jwt("tokenX") {
verifier(jwkProvider, configTokeX.metadata.issuer)
validate { credentials ->
try {
requireNotNull(credentials.payload.audience) {
"Auth: Missing audience in token"
}
require(credentials.payload.audience.contains(configTokeX.clientId)) {
"Auth: Valid audience not found in claims"
}
JWTPrincipal(credentials.payload)
} catch (e: Throwable) {
null
}
}
}
jwt("aad") {
verifier(jwkProviderAad, configAad.metadata.issuer)
validate { credentials ->
Expand Down
20 changes: 0 additions & 20 deletions apps/etterlatte-proxy/src/main/kotlin/config/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@ import io.ktor.client.call.body
import io.ktor.client.request.get
import io.ktor.server.config.ApplicationConfig
import no.nav.etterlatte.routes.httpClientWithProxy
import no.nav.etterlatte.routes.jsonClient

data class Config(
val sts: Sts,
val aad: AAD,
val tokenX: TokenX,
val inntektskomponentenUrl: String,
val aaregUrl: String,
val regoppslagUrl: String,
val institusjonsoppholdUrl: String,
val tilbakekrevingUrl: String
Expand All @@ -33,16 +29,6 @@ data class Config(
}
}

data class TokenX(
val metadata: Metadata,
val clientId: String,
) {
data class Metadata(
@JsonProperty("issuer") val issuer: String,
@JsonProperty("jwks_uri") val jwksUri: String,
)
}

data class AAD(
val metadata: Metadata,
val clientId: String,
Expand All @@ -55,9 +41,7 @@ data class Config(
}

suspend fun ApplicationConfig.load() = Config(
inntektskomponentenUrl = property("inntektskomponenten.url").getString(),
institusjonsoppholdUrl = property("institusjonsopphold.url").getString(),
aaregUrl = property("aareg.url").getString(),
regoppslagUrl = property("regoppslag.url").getString(),
tilbakekrevingUrl = property("tilbakekreving.url").getString(),
sts = Config.Sts(
Expand All @@ -71,9 +55,5 @@ suspend fun ApplicationConfig.load() = Config(
aad = Config.AAD(
metadata = httpClientWithProxy().use { it.get(property("aad.wellKnownUrl").getString()).body() },
clientId = property("aad.clientId").getString()
),
tokenX = Config.TokenX(
metadata = jsonClient().use { it.get(property("tokenx.wellKnownUrl").getString()).body() },
clientId = property("tokenx.clientId").getString()
)
)
65 changes: 0 additions & 65 deletions apps/etterlatte-proxy/src/main/kotlin/config/HttpClient.kt

This file was deleted.

49 changes: 0 additions & 49 deletions apps/etterlatte-proxy/src/main/kotlin/routes/AaregRoute.kt

This file was deleted.

5 changes: 0 additions & 5 deletions apps/etterlatte-proxy/src/main/kotlin/routes/Http.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ import io.ktor.utils.io.copyAndClose
import org.apache.http.impl.conn.SystemDefaultRoutePlanner
import java.net.ProxySelector

fun jsonClient() = HttpClient(Apache) {
install(ContentNegotiation) {
jackson { configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) }
}
}

fun httpClient() = HttpClient(Apache){
install(Logging) {
Expand Down
Loading

0 comments on commit 0a7a50f

Please sign in to comment.