Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oppdaterer sikkerhetskonfigurasjonen #394

Merged
merged 3 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ val mockkVersion = "1.13.8"
val wireMockVersion = "2.19.0"
val filformatVersion = "1.2019.06.26-14.50-746e7610cb12"
val micrometerRegistryVersion = "1.1.2"
val tokenSupportVersion = "2.1.7"
val tokenValidationVersion = "2.1.7"
tnarland marked this conversation as resolved.
Show resolved Hide resolved
val jacksonVersion = "2.9.9"
val springdocVersion = "1.6.15"
val navFoedselsnummerVersion = "1.0-SNAPSHOT.6"
val skattKontraktVersjon = "2.0_20230214104704_706e9c0"
val fellesVersjon = "1.20230116145510_2afcc20"
val kontrakterVersjon = "2.0_20230313140330_0086324"
val coroutinesVersion = "1.6.4"
val okhttp3Version = "4.9.3"

val mainClass = "no.nav.familie.ba.infotrygd.Main"

Expand Down Expand Up @@ -76,8 +77,12 @@ dependencies {
implementation("io.micrometer:micrometer-registry-prometheus")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("net.ttddyy:datasource-proxy:1.8.1")
implementation("no.nav.security:token-validation-spring:$tokenSupportVersion")
testImplementation("no.nav.security:token-validation-test-support:2.0.5")
implementation("no.nav.security:token-validation-spring:$tokenValidationVersion")
testImplementation("no.nav.security:token-validation-spring-test:$tokenValidationVersion") {
exclude(group = "com.squareup.okhttp3", module = "mockwebserver")
}
testImplementation("com.squareup.okhttp3:mockwebserver:$okhttp3Version")
testImplementation("com.squareup.okhttp3:okhttp:$okhttp3Version")
implementation("javax.inject:javax.inject:1")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
Expand Down
5 changes: 3 additions & 2 deletions nais/dev-fss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ spec:
groups:
- id: c62e908a-cf20-4ad0-b7b3-3ff6ca4bf38b # teamfamilie-forvaltning
- id: 928636f4-fd0d-4149-978e-a6fb68bb19de # 0000-GA-STDAPPS - tilgang til prosessering
- id: 93a26831-9866-4410-927b-74ff51a9107c # VEILEDER_ROLLE
- id: d21e00a4-969d-4b28-8782-dc818abfae65 # SAKSBEHANDLER_ROLLE
- id: 9449c153-5a1e-44a7-84c6-7cc7a8867233 # BESLUTTER_ROLLE
tenant: trygdeetaten.no
replyURLs:
- "https://familie-ba-infotrygd.dev.intern.nav.no/swagger-ui/oauth2-redirect.html"
Expand All @@ -100,8 +103,6 @@ spec:
value: none
- name: APP_AZURE_PROXY_URL
value: https://webproxy-nais.nav.no:8088
- name: APP_CLIENT_WHITELIST
value: azure/146ccc69-7cd0-4b8e-86a5-144534e53a00,azure/288f2ef5-23fa-4fc5-af6b-6001adaf9e50,azure/e50c7d59-7183-4978-8d8c-8af7f9a7e6a9,azure/1ded84b0-21b7-4042-9c84-820c939021a6,azure/dc2b8dca-9de9-42f7-9103-f52a9169428e,azure/a38ae9cf-f55a-480a-b830-cc68d53f8445,azure/b5b51c6e-aa53-4ab8-ae68-f7aed5ae4b1d
- name: APP_DATASOURCE_USERNAME_PATH
value: /var/run/secrets/oracle/creds/username
- name: APP_DATASOURCE_PASSWORD_PATH
Expand Down
5 changes: 3 additions & 2 deletions nais/prod-fss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ spec:
groups:
- id: 3d718ae5-f25e-47a4-b4b3-084a97604c1d # teamfamilie-forvaltning
- id: 87190cf3-b278-457d-8ab7-1a5c55a9edd7 # Group_87190cf3-b278-457d-8ab7-1a5c55a9edd7 tilgang til prosessering
- id: 199c2b39-e535-4ae8-ac59-8ccbee7991ae # veileder
- id: 847e3d72-9dc1-41c3-80ff-f5d4acdd5d46 # saksbehandler
- id: 7a271f87-39fb-468b-a9ee-6cf3c070f548 # beslutter
replyURLs:
- "https://familie-ba-infotrygd.intern.nav.no/swagger-ui/oauth2-redirect.html"
singlePageApplication: true
Expand All @@ -98,8 +101,6 @@ spec:
value: none
- name: APP_AZURE_PROXY_URL
value: https://webproxy-nais.nav.no:8088
- name: APP_CLIENT_WHITELIST
value: azure/0412f3eb-b22a-4d3f-99aa-319321eb340f,azure/984d4731-b95d-4f87-8154-d8f153f0ebee,azure/a1e0a7ad-7838-41c4-bf64-84b689d569e9,azure/f1fe85a0-704b-42e9-bd1e-5793be962010,azure/bc8e9286-2696-416d-b658-522301569562,azure/e8228369-577e-474e-b426-a76c275fd2fa
- name: APP_DATASOURCE_USERNAME_PATH
value: /var/run/secrets/oracle/creds/username
- name: APP_DATASOURCE_PASSWORD_PATH
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package no.nav.familie.ba.infotrygd.config

import no.nav.familie.ba.infotrygd.Profiles
import no.nav.security.token.support.spring.api.EnableJwtTokenValidation
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Profile

@EnableJwtTokenValidation(ignore = ["org.springframework", "springfox", "org.springdoc"])
@Profile("!${Profiles.NOAUTH}")
@Configuration
class SecurityConfiguration
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
class SwaggerConfig(@Value("\${AUTHORIZATION_URL}")
val authorizationUrl: String,
@Value("\${AZURE_OPENID_CONFIG_TOKEN_ENDPOINT}")
val tokenUrl: String,
@Value("\${API_SCOPE}")
val apiScope: String) {
class SwaggerConfig(
@Value("\${AUTHORIZATION_URL}")
val authorizationUrl: String,
@Value("\${TOKEN_URL}")
val tokenUrl: String,
@Value("\${API_SCOPE}")
val apiScope: String
) {

@Bean
fun openApi(): OpenAPI {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import no.nav.familie.ba.infotrygd.model.dl1.Hendelse
import no.nav.familie.ba.infotrygd.rest.api.InfotrygdLøpendeBarnetrygdResponse
import no.nav.familie.ba.infotrygd.rest.api.InfotrygdÅpenSakResponse
import no.nav.familie.ba.infotrygd.service.BarnetrygdService
import no.nav.familie.ba.infotrygd.service.ClientValidator
import no.nav.familie.ba.infotrygd.service.TilgangskontrollService
import no.nav.familie.kontrakter.ba.infotrygd.InfotrygdSøkRequest
import no.nav.familie.kontrakter.ba.infotrygd.InfotrygdSøkResponse
import no.nav.security.token.support.core.api.Protected
import no.nav.security.token.support.core.api.ProtectedWithClaims
import org.slf4j.LoggerFactory
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.GetMapping
Expand All @@ -27,21 +27,21 @@ import no.nav.familie.kontrakter.ba.infotrygd.Sak as SakDto
import no.nav.familie.kontrakter.ba.infotrygd.Stønad as StønadDto


@Protected
@RestController
@ProtectedWithClaims(issuer = "azuread")
@Timed(value = "infotrygd_historikk_barnetrygd_controller", percentiles = [0.5, 0.95])
@RequestMapping("/infotrygd/barnetrygd")
class BarnetrygdController(
private val barnetrygdService: BarnetrygdService,
private val clientValidator: ClientValidator
private val tilgangskontrollService: TilgangskontrollService
) {
private val logger = LoggerFactory.getLogger(javaClass)

@Operation(summary = "Avgjør hvorvidt det finnes løpende barnetrygd på søker eller barn i Infotrygd.")
@PostMapping(path = ["lopende-barnetrygd"], consumes = ["application/json"])
@ApiRequestBody(content = [Content(examples = [ExampleObject(value = INFOTRYGD_SØK_EKSEMPEL)])])
fun harLopendeBarnetrygd(@RequestBody request: InfotrygdSøkRequest): ResponseEntity<InfotrygdLøpendeBarnetrygdResponse> {
clientValidator.authorizeClient()
tilgangskontrollService.sjekkTilgang()

val harLøpendeBarnetrygd = hentStønaderPåBrukereOgBarn(request.brukere, request.barn, false).let {
it.first.isNotEmpty() || it.second.isNotEmpty()
Expand All @@ -53,7 +53,7 @@ class BarnetrygdController(
@PostMapping(path = ["aapen-sak"], consumes = ["application/json"])
@ApiRequestBody(content = [Content(examples = [ExampleObject(value = INFOTRYGD_SØK_EKSEMPEL)])])
fun harÅpenSak(@RequestBody request: InfotrygdSøkRequest): ResponseEntity<InfotrygdÅpenSakResponse> {
clientValidator.authorizeClient()
tilgangskontrollService.sjekkTilgang()

return barnetrygdService.tellAntallÅpneSaker(request.brukere, request.barn).let {
ResponseEntity.ok(InfotrygdÅpenSakResponse(it > 0))
Expand All @@ -67,7 +67,7 @@ class BarnetrygdController(
@RequestBody request: InfotrygdSøkRequest,
@RequestParam(required = false) historikk: Boolean?
): ResponseEntity<InfotrygdSøkResponse<StønadDto>> {
clientValidator.authorizeClient()
tilgangskontrollService.sjekkTilgang()

return hentStønaderPåBrukereOgBarn(request.brukere, request.barn, historikk).let {
ResponseEntity.ok(InfotrygdSøkResponse(bruker = it.first, barn = it.second))
Expand All @@ -78,7 +78,7 @@ class BarnetrygdController(
@PostMapping(path = ["saker"], consumes = ["application/json"])
@ApiRequestBody(content = [Content(examples = [ExampleObject(value = INFOTRYGD_SØK_EKSEMPEL)])])
fun saker(@RequestBody request: InfotrygdSøkRequest): ResponseEntity<InfotrygdSøkResponse<SakDto>> {
clientValidator.authorizeClient()
tilgangskontrollService.sjekkTilgang()

val brukere = request.brukere.map { FoedselsNr(it) }
val barn = request.barn?.takeUnless { it.isEmpty() }?.map { FoedselsNr(it) }
Expand All @@ -90,7 +90,7 @@ class BarnetrygdController(
@Operation(summary = "Teller antall migreringer igjen fra side i input")
@PostMapping(path = ["migrering/antall"])
fun tellKlarTilMigrering(@RequestBody request: MigreringRequest): ResponseEntity<Long> {
clientValidator.authorizeClient()
tilgangskontrollService.sjekkTilgang()

val result = barnetrygdService.finnPersonerKlarForMigrering(
request.page,
Expand Down Expand Up @@ -118,7 +118,7 @@ class BarnetrygdController(
@Operation(summary = "Uttrekk personer med ytelse. F.eks OS OS for barnetrygd, UT EF for småbarnstillegg")
@PostMapping(path = ["migrering/v2"])
fun migreringV2(@RequestBody request: MigreringRequest): ResponseEntity<MigreringResponse> {
clientValidator.authorizeClient()
tilgangskontrollService.sjekkTilgang()

return ResponseEntity.ok(
barnetrygdService.finnPersonerKlarForMigrering(
Expand All @@ -135,7 +135,7 @@ class BarnetrygdController(
@GetMapping(path = ["stonad/{id}"])
@Deprecated(message="Erstattes av findStønad som henter basert på B01_PERSONKEY, B20_IVERFOM_SEQ, B20_VIRKFOM_SEQ og REGION")
fun findStønadById(@PathVariable id: Long): ResponseEntity<StønadDto> {
clientValidator.authorizeClient()
tilgangskontrollService.sjekkTilgang()

try {
return ResponseEntity.ok(
Expand All @@ -151,7 +151,7 @@ class BarnetrygdController(
@Operation(summary = "Finn stønad basert på personKey, iverksattFom, virkningFom og region")
@PostMapping(path = ["stonad/sok"])
fun findStønad(@RequestBody stønadRequest: StønadRequest): ResponseEntity<StønadDto> {
clientValidator.authorizeClient()
tilgangskontrollService.sjekkTilgang()

try {
return ResponseEntity.ok(
Expand All @@ -172,7 +172,7 @@ class BarnetrygdController(
@Operation(summary = "Finn om brev med brevkode er sendt for en person i forrige måned")
@PostMapping(path = ["/brev"])
fun harSendtBrevForrigeMåned(@RequestBody sendtBrevRequest: SendtBrevRequest): ResponseEntity<SendtBrevResponse> {
clientValidator.authorizeClient()
tilgangskontrollService.sjekkTilgang()

val listeMedBrevhendelser = barnetrygdService.harSendtBrevForrigeMåned(
sendtBrevRequest.personidenter.map { FoedselsNr(it)},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import io.swagger.v3.oas.annotations.media.ExampleObject
import io.swagger.v3.oas.annotations.media.Schema
import no.nav.commons.foedselsnummer.FoedselsNr
import no.nav.familie.ba.infotrygd.service.BarnetrygdService
import no.nav.familie.ba.infotrygd.service.ClientValidator
import no.nav.security.token.support.core.api.Protected
import no.nav.familie.ba.infotrygd.service.TilgangskontrollService
import no.nav.security.token.support.core.api.ProtectedWithClaims
import org.slf4j.LoggerFactory
import org.springframework.http.HttpStatus
import org.springframework.web.bind.annotation.PostMapping
Expand All @@ -21,21 +21,21 @@ import java.time.YearMonth
import io.swagger.v3.oas.annotations.parameters.RequestBody as ApiRequestBody


@Protected
@ProtectedWithClaims(issuer = "azuread")
@RestController
@Timed(value = "infotrygd_historikk_bisys_controller", percentiles = [0.5, 0.95])
@RequestMapping("/infotrygd/barnetrygd")
class BisysController(
private val barnetrygdService: BarnetrygdService,
private val clientValidator: ClientValidator
private val tilgangskontrollService: TilgangskontrollService
) {
private val logger = LoggerFactory.getLogger(javaClass)

@Operation(summary = "Uttrekk utvidet barnetrygd/småbarnstillegg utbetaling på en person fra en bestemet måned. Maks 5 år tilbake i tid")
@PostMapping(path = ["utvidet"], consumes = ["application/json"])
@ApiRequestBody(content = [Content(examples = [ExampleObject(value = """{"personIdent": "12345678910", "fraDato": "2020-05"}""")])])
fun utvidet(@RequestBody request: InfotrygdUtvidetBarnetrygdRequest): InfotrygdUtvidetBarnetrygdResponse {
clientValidator.authorizeClient()
tilgangskontrollService.sjekkTilgang()

if (request.fraDato.isBefore(YearMonth.now().minusYears(5)))
throw ResponseStatusException(HttpStatus.BAD_REQUEST, "fraDato kan ikke være lenger enn 5 år tilbake i tid")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import io.swagger.v3.oas.annotations.media.ExampleObject
import io.swagger.v3.oas.annotations.media.Schema
import no.nav.commons.foedselsnummer.FoedselsNr
import no.nav.familie.ba.infotrygd.service.BarnetrygdService
import no.nav.familie.ba.infotrygd.service.ClientValidator
import no.nav.familie.ba.infotrygd.service.TilgangskontrollService
import no.nav.security.token.support.core.api.Protected
import no.nav.security.token.support.core.api.ProtectedWithClaims
import org.springframework.http.HttpStatus
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
Expand All @@ -23,20 +24,20 @@ import java.time.LocalDate
import java.time.YearMonth
import io.swagger.v3.oas.annotations.parameters.RequestBody as ApiRequestBody

@Protected
@ProtectedWithClaims(issuer = "azuread")
@RestController
@Timed(value = "infotrygd_historikk_pensjon_controller", percentiles = [0.5, 0.95])
@RequestMapping("/infotrygd/barnetrygd")
class PensjonController(
private val barnetrygdService: BarnetrygdService,
private val clientValidator: ClientValidator,
private val tilgangskontrollService: TilgangskontrollService,
) {

@Operation(summary = "Uttrekk barnetrygdperioder på en person fra en bestemet måned. Maks 2 år tilbake i tid")
@PostMapping(path = ["pensjon"], consumes = ["application/json"])
@ApiRequestBody(content = [Content(examples = [ExampleObject(value = """{"ident": "12345678910", "fraDato": "2022-12-01"}""")])])
fun hentBarnetrygd(@RequestBody request: BarnetrygdTilPensjonRequest): BarnetrygdTilPensjonResponse {
clientValidator.authorizeClient()
tilgangskontrollService.sjekkTilgang()

val fraDato = YearMonth.of(request.fraDato.year, request.fraDato.month)

Expand All @@ -54,7 +55,7 @@ class PensjonController(
@Operation(summary = "Finner alle personer med barnetrygd innenfor et bestemt år på vegne av Psys")
@GetMapping(path = ["pensjon"])
fun personerMedBarnetrygd(@Parameter(name = "aar") @RequestParam("aar") år: String): List<FoedselsNr> {
clientValidator.authorizeClient()
tilgangskontrollService.sjekkTilgang()
return barnetrygdService.finnPersonerBarnetrygdPensjon(år)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import io.swagger.v3.oas.annotations.media.ExampleObject
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import no.nav.familie.ba.infotrygd.service.BarnetrygdService
import no.nav.familie.ba.infotrygd.service.ClientValidator
import no.nav.familie.ba.infotrygd.service.TilgangskontrollService
import no.nav.familie.eksterne.kontrakter.skatteetaten.SkatteetatenPeriode
import no.nav.familie.eksterne.kontrakter.skatteetaten.SkatteetatenPerioderRequest
import no.nav.familie.eksterne.kontrakter.skatteetaten.SkatteetatenPerioderResponse
import no.nav.familie.eksterne.kontrakter.skatteetaten.SkatteetatenPersonerResponse
import no.nav.familie.log.mdc.MDCConstants
import no.nav.security.token.support.core.api.Protected
import no.nav.security.token.support.core.api.ProtectedWithClaims
import org.slf4j.LoggerFactory
import org.slf4j.MDC
import org.springframework.web.bind.annotation.GetMapping
Expand All @@ -27,13 +27,13 @@ import java.util.UUID
import io.swagger.v3.oas.annotations.parameters.RequestBody as ApiRequestBody


@Protected
@ProtectedWithClaims(issuer = "azuread")
@RestController
@Timed(value = "infotrygd_historikk_skatt_controller", percentiles = [0.5, 0.95])
@RequestMapping("/infotrygd/barnetrygd")
class SkatteetatenController(
private val barnetrygdService: BarnetrygdService,
private val clientValidator: ClientValidator
private val tilgangskontrollService: TilgangskontrollService
) {

private val logger = LoggerFactory.getLogger(javaClass)
Expand All @@ -47,7 +47,7 @@ class SkatteetatenController(
@RequestBody
request: SkatteetatenPerioderRequest
): List<SkatteetatenPerioderResponse> {
clientValidator.authorizeClient()
tilgangskontrollService.sjekkTilgang()

return request.identer.map {
barnetrygdService.finnPerioderUtvidetBarnetrygdSkatt(it, request.aar.toInt())
Expand All @@ -57,14 +57,14 @@ class SkatteetatenController(
@Operation(summary = "Finner alle personer med utvidet barnetrygd innenfor et bestemt år")
@GetMapping(path = ["utvidet"])
fun personerMedUtvidet(@Parameter(name = "aar") @RequestParam("aar") år: String): SkatteetatenPersonerResponse {
clientValidator.authorizeClient()
tilgangskontrollService.sjekkTilgang()
return SkatteetatenPersonerResponse(brukere = barnetrygdService.finnPersonerUtvidetBarnetrygdSkatt(år))
}

@Operation(summary = "Finner alle personer med utvidet barnetrygd innenfor et bestemt år")
@GetMapping(path = ["delingsprosent"])
fun identifiserAntallUsikkerDelingsprosent(@Parameter(name = "aar") @RequestParam("aar") år: String): String {
clientValidator.authorizeClient()
tilgangskontrollService.sjekkTilgang()


val allePersoner = personerMedUtvidet(år).brukere
Expand Down
Loading