diff --git a/.github/workflows/app.organisasjon-tilgang-service.yml b/.github/workflows/app.organisasjon-tilgang-service.yml deleted file mode 100644 index 229fcbb1fcd..00000000000 --- a/.github/workflows/app.organisasjon-tilgang-service.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: organisasjon-tilgang-service - -on: - push: - paths: - - "plugins/**" - - "libs/reactive-core/**" - - "libs/reactive-security/**" - - "apps/organisasjon-tilgang-service/**" - - ".github/workflows/app.organisasjon-tilgang-service.yml" - -jobs: - workflow: - uses: ./.github/workflows/common.workflow.backend.yml - with: - working-directory: "apps/organisasjon-tilgang-service" - deploy-tag: "#deploy-organisasjon-tilgang-service" - permissions: - contents: read - id-token: write - secrets: inherit diff --git a/.github/workflows/app.person-organisasjon-tilgang-service.yml b/.github/workflows/app.person-organisasjon-tilgang-service.yml deleted file mode 100644 index 6136dd68925..00000000000 --- a/.github/workflows/app.person-organisasjon-tilgang-service.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: person-organisasjon-tilgang-service - -on: - push: - paths: - - "plugins/**" - - "libs/integration-test/**" - - "libs/reactive-core/**" - - "libs/reactive-security/**" - - "libs/security-core/**" - - "apps/person-organisasjon-tilgang-service/**" - - ".github/workflows/app.person-organisasjon-tilgang-service.yml" - -jobs: - workflow: - uses: ./.github/workflows/common.workflow.backend.yml - with: - working-directory: "apps/person-organisasjon-tilgang-service" - deploy-tag: "#deploy-person-organisasjon-tilgang-service" - permissions: - contents: read - id-token: write - secrets: inherit diff --git a/.github/workflows/maskinporten.yml b/.github/workflows/maskinporten.yml deleted file mode 100644 index 9d1b7007cc8..00000000000 --- a/.github/workflows/maskinporten.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Deploy maskinporten - -on: - push: - branches: - - master - paths: - - '.nais/maskinporten.yml' - -jobs: - deploy-maskinporten: - name: Deploy maskinporten - runs-on: ubuntu-latest - permissions: - contents: read - id-token: write - steps: - - uses: actions/checkout@v4 - - uses: nais/deploy/actions/deploy@v2 - env: - CLUSTER: prod-gcp - RESOURCE: ".nais/maskinporten.yml" diff --git a/.nais/idporten.yml b/.nais/idporten.yml index 7b6520ff70e..0d009e1781a 100644 --- a/.nais/idporten.yml +++ b/.nais/idporten.yml @@ -15,3 +15,4 @@ spec: - https://dolly.ekstern.dev.nav.no/login/oauth2/code/idporten - https://dolly-idporten.ekstern.dev.nav.no/login/oauth2/code/idporten secretName: idporten-dolly-prod # deployes til prod. secret kopieres manuelt til dev. + ssoDisabled: true diff --git a/.nais/maskinporten.yml b/.nais/maskinporten.yml deleted file mode 100644 index ae6508f5809..00000000000 --- a/.nais/maskinporten.yml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: nais.io/v1 -kind: MaskinportenClient -metadata: - name: dolly - namespace: dolly - labels: - team: dolly -spec: - scopes: - consumes: - - name: altinn:serviceowner - secretName: maskinporten-dolly-prod # deployes til prod. secret kopieres manuelt til dev. diff --git a/apps/adresse-service/src/main/resources/application.yml b/apps/adresse-service/src/main/resources/application.yml index 5b96088b72e..5b3bf750fca 100644 --- a/apps/adresse-service/src/main/resources/application.yml +++ b/apps/adresse-service/src/main/resources/application.yml @@ -34,12 +34,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/altinn3-tilgang-service/config.dev.yml b/apps/altinn3-tilgang-service/config.dev.yml index 2c820f19977..6b66adf5c44 100644 --- a/apps/altinn3-tilgang-service/config.dev.yml +++ b/apps/altinn3-tilgang-service/config.dev.yml @@ -32,6 +32,7 @@ spec: - application: team-dolly-lokal-app - application: testnav-oversikt-frontend - application: testnav-bruker-service-dev + - application: testnorge-profil-api-dev outbound: external: - host: platform.tt02.altinn.no diff --git a/apps/altinn3-tilgang-service/src/main/resources/application.yml b/apps/altinn3-tilgang-service/src/main/resources/application.yml index 16f513682d3..654d076c3a4 100644 --- a/apps/altinn3-tilgang-service/src/main/resources/application.yml +++ b/apps/altinn3-tilgang-service/src/main/resources/application.yml @@ -37,12 +37,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/amelding-service/src/main/resources/application.yml b/apps/amelding-service/src/main/resources/application.yml index e90182fd21e..404bec3cc25 100644 --- a/apps/amelding-service/src/main/resources/application.yml +++ b/apps/amelding-service/src/main/resources/application.yml @@ -30,12 +30,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/app-tilgang-analyse-service/src/main/resources/application.yml b/apps/app-tilgang-analyse-service/src/main/resources/application.yml index ebf58a884c3..829bfd78a09 100644 --- a/apps/app-tilgang-analyse-service/src/main/resources/application.yml +++ b/apps/app-tilgang-analyse-service/src/main/resources/application.yml @@ -32,12 +32,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/arbeidsforhold-service/src/main/resources/application.yml b/apps/arbeidsforhold-service/src/main/resources/application.yml index 9e816896986..f15c64ba7ef 100644 --- a/apps/arbeidsforhold-service/src/main/resources/application.yml +++ b/apps/arbeidsforhold-service/src/main/resources/application.yml @@ -33,12 +33,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/batch-bestilling-service/src/main/resources/application.yml b/apps/batch-bestilling-service/src/main/resources/application.yml index 5e056d09e77..0a85377386b 100644 --- a/apps/batch-bestilling-service/src/main/resources/application.yml +++ b/apps/batch-bestilling-service/src/main/resources/application.yml @@ -28,12 +28,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/brreg-stub/src/main/resources/application.yml b/apps/brreg-stub/src/main/resources/application.yml index de4ff173f11..0667df0b3ea 100644 --- a/apps/brreg-stub/src/main/resources/application.yml +++ b/apps/brreg-stub/src/main/resources/application.yml @@ -12,12 +12,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/bruker-service/src/main/java/no/nav/testnav/apps/brukerservice/consumer/PersonOrganisasjonTilgangConsumer.java b/apps/bruker-service/src/main/java/no/nav/testnav/apps/brukerservice/consumer/AltinnTilgangServiceConsumer.java similarity index 95% rename from apps/bruker-service/src/main/java/no/nav/testnav/apps/brukerservice/consumer/PersonOrganisasjonTilgangConsumer.java rename to apps/bruker-service/src/main/java/no/nav/testnav/apps/brukerservice/consumer/AltinnTilgangServiceConsumer.java index b29097a6057..986de3c3939 100644 --- a/apps/bruker-service/src/main/java/no/nav/testnav/apps/brukerservice/consumer/PersonOrganisasjonTilgangConsumer.java +++ b/apps/bruker-service/src/main/java/no/nav/testnav/apps/brukerservice/consumer/AltinnTilgangServiceConsumer.java @@ -11,14 +11,14 @@ import reactor.core.publisher.Mono; @Component -public class PersonOrganisasjonTilgangConsumer { +public class AltinnTilgangServiceConsumer { private final WebClient webClient; private final ServerProperties serverProperties; private final TokenExchange tokenExchange; private final GetAuthenticatedUserId getAuthenticatedUserId; - public PersonOrganisasjonTilgangConsumer( + public AltinnTilgangServiceConsumer( Consumers consumers, TokenExchange tokenExchange, WebClient.Builder webClientBuilder, diff --git a/apps/bruker-service/src/main/java/no/nav/testnav/apps/brukerservice/service/ValidateService.java b/apps/bruker-service/src/main/java/no/nav/testnav/apps/brukerservice/service/ValidateService.java index 1ada4106bb8..4f39d4eb895 100644 --- a/apps/bruker-service/src/main/java/no/nav/testnav/apps/brukerservice/service/ValidateService.java +++ b/apps/bruker-service/src/main/java/no/nav/testnav/apps/brukerservice/service/ValidateService.java @@ -1,7 +1,7 @@ package no.nav.testnav.apps.brukerservice.service; import lombok.RequiredArgsConstructor; -import no.nav.testnav.apps.brukerservice.consumer.PersonOrganisasjonTilgangConsumer; +import no.nav.testnav.apps.brukerservice.consumer.AltinnTilgangServiceConsumer; import no.nav.testnav.apps.brukerservice.exception.UserHasNoAccessToOrgnisasjonException; import org.springframework.stereotype.Service; import reactor.core.publisher.Mono; @@ -9,10 +9,11 @@ @Service @RequiredArgsConstructor public class ValidateService { - private final PersonOrganisasjonTilgangConsumer client; + + private final AltinnTilgangServiceConsumer altinnTilgangServiceConsumer; public Mono validateOrganiasjonsnummerAccess(String organisasjonsnummer) { - return client + return altinnTilgangServiceConsumer .getOrganisasjon(organisasjonsnummer) .doOnNext(organisasjon -> { if (!organisasjon.getOrganisasjonsnummer().equals(organisasjonsnummer)) { diff --git a/apps/bruker-service/src/main/resources/application-virtual.yml b/apps/bruker-service/src/main/resources/application-virtual.yml index b45d934be91..0de519e330b 100644 --- a/apps/bruker-service/src/main/resources/application-virtual.yml +++ b/apps/bruker-service/src/main/resources/application-virtual.yml @@ -23,11 +23,11 @@ spring: password: compose-postgres consumers: - testnav-person-organisasjon-tilgang-service: - url: http://testnav-person-organisasjon-tilgang-service:8080 + testnav-altinn3-tilgang-service: + url: http://testnav-altinn3-tilgang-service:8080 cluster: dev-gcp namespace: dolly - name: testnav-person-organisasjon-tilgang-service + name: testnav-altinn3-tilgang-service TOKEN_X_WELL_KNOWN_URL: http://tokendings:8080/.well-known/oauth-authorization-server TOKEN_X_CLIENT_ID: dev-gcp:dolly:testnav-bruker-service diff --git a/apps/bruker-service/src/main/resources/application.yml b/apps/bruker-service/src/main/resources/application.yml index 3cb53ea7f47..c08c085bc98 100644 --- a/apps/bruker-service/src/main/resources/application.yml +++ b/apps/bruker-service/src/main/resources/application.yml @@ -33,12 +33,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/bruker-service/src/test/resources/application-test.yml b/apps/bruker-service/src/test/resources/application-test.yml index 5ac5d4b6204..9f9350113ba 100644 --- a/apps/bruker-service/src/test/resources/application-test.yml +++ b/apps/bruker-service/src/test/resources/application-test.yml @@ -20,5 +20,5 @@ spring: jwk-set-uri: ${wiremockBaseUrl}/jwks consumers: - testnav-person-organisasjon-tilgang-service: + testnav-altinn3-tilgang-service: url: ${wiremockBaseUrl} \ No newline at end of file diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/DollyBackendApplicationStarter.java b/apps/dolly-backend/src/main/java/no/nav/dolly/DollyBackendApplicationStarter.java index f0ef428e58d..6af8668f777 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/DollyBackendApplicationStarter.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/DollyBackendApplicationStarter.java @@ -10,4 +10,4 @@ public static void main(String[] args) { SpringApplication.run(DollyBackendApplicationStarter.class, args); } -} +} \ No newline at end of file diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/dokarkiv/DokarkivClient.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/dokarkiv/DokarkivClient.java index db73b7fd72e..a7697a1e2f2 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/dokarkiv/DokarkivClient.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/dokarkiv/DokarkivClient.java @@ -20,6 +20,7 @@ import no.nav.dolly.domain.resultset.dokarkiv.RsDokarkiv; import no.nav.dolly.domain.resultset.dolly.DollyPerson; import no.nav.dolly.errorhandling.ErrorStatusDecoder; +import no.nav.dolly.service.DokumentService; import no.nav.dolly.service.TransaksjonMappingService; import no.nav.dolly.util.TransactionHelperService; import no.nav.testnav.libs.reactivecore.utils.WebClientFilter; @@ -47,6 +48,7 @@ public class DokarkivClient implements ClientRegister { private final ApplicationConfig applicationConfig; private final DokarkivConsumer dokarkivConsumer; + private final DokumentService dokumentService; private final ErrorStatusDecoder errorStatusDecoder; private final MapperFacade mapperFacade; private final ObjectMapper objectMapper; @@ -63,7 +65,7 @@ public Flux gjenopprett(RsDollyUtvidetBestilling bestilling, Dolly .flatMap(dokarkiv -> Flux.from(getPersonData(dollyPerson.getIdent()) .flatMap(person -> getFilteredMiljoer(bestilling.getEnvironments()) .flatMapMany(miljoer -> Flux.fromIterable(miljoer) - .flatMap(env -> buildRequest(dokarkiv, person) + .flatMap(env -> buildRequest(dokarkiv, person, progress.getBestilling().getId()) .flatMap(request -> !transaksjonMappingService.existAlready(DOKARKIV, dollyPerson.getIdent(), env, bestilling.getId()) || isOpprettEndre ? @@ -142,10 +144,11 @@ private Flux getPersonData(String ident) { .filter(personBolk -> nonNull(personBolk.getPerson())); } - private Mono buildRequest(RsDokarkiv rsDokarkiv, PdlPersonBolk.PersonBolk personBolk) { + private Mono buildRequest(RsDokarkiv rsDokarkiv, PdlPersonBolk.PersonBolk personBolk, Long bestillingId) { var context = new MappingContext.Factory().getContext(); context.setProperty("personBolk", personBolk); + context.setProperty("dokumenter", dokumentService.getDokumenterByBestilling(bestillingId)); return Mono.just(mapperFacade.map(rsDokarkiv, DokarkivRequest.class, context)); } diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/dokarkiv/domain/DokarkivRequest.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/dokarkiv/domain/DokarkivRequest.java index 2a8ca23aeee..333aaf6c5d2 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/dokarkiv/domain/DokarkivRequest.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/dokarkiv/domain/DokarkivRequest.java @@ -1,5 +1,6 @@ package no.nav.dolly.bestilling.dokarkiv.domain; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import lombok.AllArgsConstructor; import lombok.Builder; @@ -100,6 +101,8 @@ public static class DokumentVariant { private String filtype; private String fysiskDokument; private String variantformat; + @JsonIgnore + private Long dokumentReferanse; @Override public String toString() { diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/dokarkiv/domain/DokarkivResponse.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/dokarkiv/domain/DokarkivResponse.java index af22301fc25..a79fc2a97b2 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/dokarkiv/domain/DokarkivResponse.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/dokarkiv/domain/DokarkivResponse.java @@ -37,7 +37,5 @@ public List getDokumenter() { public static class DokumentInfo { private String dokumentInfoId; - private String brevkode; - private String tittel; } } diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/dokarkiv/mapper/DokarkivMappingStrategy.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/dokarkiv/mapper/DokarkivMappingStrategy.java index 1cded101134..a791abbf702 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/dokarkiv/mapper/DokarkivMappingStrategy.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/dokarkiv/mapper/DokarkivMappingStrategy.java @@ -7,11 +7,13 @@ import no.nav.dolly.bestilling.dokarkiv.domain.DokarkivRequest; import no.nav.dolly.domain.PdlPerson; import no.nav.dolly.domain.PdlPersonBolk; +import no.nav.dolly.domain.jpa.Dokument; import no.nav.dolly.domain.resultset.dokarkiv.RsDokarkiv; import no.nav.dolly.mapper.MappingStrategy; import org.springframework.stereotype.Component; import java.util.Arrays; +import java.util.List; import java.util.UUID; import static java.util.Objects.isNull; @@ -37,6 +39,7 @@ public void register(MapperFactory factory) { @Override public void mapAtoB(RsDokarkiv rsDokarkiv, DokarkivRequest dokarkivRequest, MappingContext context) { + var dokumenter = (List) context.getProperty("dokumenter"); dokarkivRequest.setEksternReferanseId(UUID.randomUUID().toString()); dokarkivRequest.setTittel(rsDokarkiv.getTittel()); @@ -72,7 +75,7 @@ public void mapAtoB(RsDokarkiv rsDokarkiv, DokarkivRequest dokarkivRequest, Mapp dokarkivRequest.getDokumenter() .addAll(mapperFacade.mapAsList(rsDokarkiv.getDokumenter(), DokarkivRequest.Dokument.class)); - fyllDokarkivDokument(dokarkivRequest); + fyllDokarkivDokument(dokarkivRequest, dokumenter); dokarkivRequest.setFerdigstill(rsDokarkiv.getFerdigstill()); } @@ -86,7 +89,7 @@ private String getNavn(PdlPersonBolk.PersonBolk personBolk) { .register(); } - private void fyllDokarkivDokument(DokarkivRequest dokarkivRequest) { + private void fyllDokarkivDokument(DokarkivRequest dokarkivRequest, List dokumenter) { if (dokarkivRequest.getDokumenter().isEmpty()) { dokarkivRequest.getDokumenter().add(new DokarkivRequest.Dokument()); @@ -100,8 +103,12 @@ private void fyllDokarkivDokument(DokarkivRequest dokarkivRequest) { if (isBlank(dokarkivRequest.getDokumenter().getFirst().getDokumentvarianter().getFirst().getVariantformat())) { dokarkivRequest.getDokumenter().getFirst().getDokumentvarianter().getFirst().setVariantformat(ARKIV); } - if (isBlank(dokarkivRequest.getDokumenter().getFirst().getDokumentvarianter().getFirst().getFysiskDokument())) { - dokarkivRequest.getDokumenter().getFirst().getDokumentvarianter().getFirst().setFysiskDokument(PDF_VEDLEGG); - } + dokarkivRequest.getDokumenter() + .forEach(dokument -> dokument.getDokumentvarianter() + .forEach(dokumentVariant -> + dokumentVariant.setFysiskDokument(dokumenter.stream() + .filter(doku -> doku.getId().equals(dokumentVariant.getDokumentReferanse())) + .map(Dokument::getContents) + .findFirst().orElse(PDF_VEDLEGG)))); } } \ No newline at end of file diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/histark/HistarkClient.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/histark/HistarkClient.java index 2db66e5830b..3ed99a0e717 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/histark/HistarkClient.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/histark/HistarkClient.java @@ -17,6 +17,7 @@ import no.nav.dolly.domain.resultset.dolly.DollyPerson; import no.nav.dolly.domain.resultset.histark.RsHistark; import no.nav.dolly.errorhandling.ErrorStatusDecoder; +import no.nav.dolly.service.DokumentService; import no.nav.dolly.service.TransaksjonMappingService; import no.nav.dolly.util.TransactionHelperService; import org.springframework.stereotype.Service; @@ -43,6 +44,7 @@ public class HistarkClient implements ClientRegister { private final ObjectMapper objectMapper; private final TransactionHelperService transactionHelperService; private final ErrorStatusDecoder errorStatusDecoder; + private final DokumentService dokumentService; @Override public Flux gjenopprett(RsDollyUtvidetBestilling bestilling, DollyPerson dollyPerson, BestillingProgress progress, boolean isOpprettEndre) { @@ -50,7 +52,7 @@ public Flux gjenopprett(RsDollyUtvidetBestilling bestilling, Dolly if (nonNull(bestilling.getHistark())) { return Flux.just(dollyPerson.getIdent()) - .map(person -> buildRequest(bestilling.getHistark(), person)) + .map(person -> buildRequest(bestilling.getHistark(), person, progress.getBestilling().getId())) .flatMap(request -> !transaksjonMappingService.existAlready(HISTARK, dollyPerson.getIdent(), "NA", bestilling.getId()) || isOpprettEndre ? @@ -100,10 +102,11 @@ private String getStatus(String ident, Long bestillingId, HistarkResponse respon } } - private HistarkRequest buildRequest(RsHistark rsHistark, String ident) { + private HistarkRequest buildRequest(RsHistark rsHistark, String ident, Long bestillingId) { var context = new MappingContext.Factory().getContext(); context.setProperty("personIdent", ident); + context.setProperty("dokumenter", dokumentService.getDokumenterByBestilling(bestillingId)); return mapperFacade.map(rsHistark, HistarkRequest.class, context); } diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/histark/HistarkConsumer.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/histark/HistarkConsumer.java index 0965c7236d5..5c683664571 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/histark/HistarkConsumer.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/histark/HistarkConsumer.java @@ -10,14 +10,12 @@ import no.nav.testnav.libs.securitycore.domain.ServerProperties; import no.nav.testnav.libs.standalone.servletsecurity.exchange.TokenExchange; import org.springframework.stereotype.Service; -import org.springframework.web.reactive.function.client.ExchangeFilterFunction; import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Flux; import java.util.UUID; import static java.lang.String.format; -import static java.util.Objects.nonNull; import static no.nav.dolly.domain.CommonKeysAndUtils.CONSUMER; import static no.nav.dolly.util.JacksonExchangeStrategyUtil.getJacksonStrategy; @@ -38,7 +36,6 @@ public HistarkConsumer( this.tokenService = tokenService; this.webClient = webClientBuilder .baseUrl(serverProperties.getUrl()) - .filters(exchangeFilterFunctions -> exchangeFilterFunctions.add(logRequest())) .exchangeStrategies(getJacksonStrategy(objectMapper)) .build(); } @@ -54,28 +51,6 @@ public Flux postHistark(HistarkRequest histarkRequest) { token.getTokenValue()).call()); } - private ExchangeFilterFunction logRequest() { - - return (clientRequest, next) -> { - var buffer = new StringBuilder(250) - .append("Request: ") - .append(clientRequest.method()) - .append(' ') - .append(clientRequest.url()) - .append(System.lineSeparator()); - - clientRequest.headers() - .forEach((name, values) -> values - .forEach(value -> buffer.append('\t') - .append(name) - .append('=') - .append(nonNull(value) && value.contains("Bearer ") ? "Bearer token" : value) - .append(System.lineSeparator()))); - log.trace(buffer.substring(0, buffer.length() - 1)); - return next.exchange(clientRequest); - }; - } - private static String getNavCallId() { return format("%s %s", CONSUMER, UUID.randomUUID()); } diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/histark/mapper/HistarkMappingStrategy.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/histark/mapper/HistarkMappingStrategy.java index 161ccfd1d9e..e7258fc5e0a 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/histark/mapper/HistarkMappingStrategy.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/histark/mapper/HistarkMappingStrategy.java @@ -5,6 +5,7 @@ import ma.glasnost.orika.MapperFactory; import ma.glasnost.orika.MappingContext; import no.nav.dolly.bestilling.histark.domain.HistarkRequest; +import no.nav.dolly.domain.jpa.Dokument; import no.nav.dolly.domain.resultset.histark.RsHistark; import no.nav.dolly.exceptions.DollyFunctionalException; import no.nav.dolly.mapper.MappingStrategy; @@ -16,9 +17,9 @@ import java.io.IOException; import java.io.InputStream; import java.time.format.DateTimeFormatter; +import java.util.List; import java.util.Optional; -import static io.micrometer.common.util.StringUtils.isBlank; import static no.nav.dolly.bestilling.dokarkiv.mapper.PdfVedlegg.PDF_VEDLEGG; @Slf4j @@ -36,11 +37,15 @@ public void register(MapperFactory factory) { @Override public void mapAtoB(RsHistark histark, HistarkRequest histarkRequest, MappingContext context) { + var dokumenter = (List) context.getProperty("dokumenter"); histark.getDokumenter().forEach(dokument -> { - - String fysiskDokument = isBlank(dokument.getFysiskDokument()) ? PDF_VEDLEGG : dokument.getFysiskDokument(); + var fysiskDokument = dokumenter.stream() + .filter(dok -> dokument.getDokumentReferanse().equals(dok.getId())) + .map(Dokument::getContents) + .findFirst() + .orElse(PDF_VEDLEGG); histarkRequest.getHistarkDokumenter().add(HistarkRequest.HistarkDokument.builder() .file(fysiskDokument) diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/pensjonforvalter/PensjonforvalterClient.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/pensjonforvalter/PensjonforvalterClient.java index 209f503eabb..933f1ebac3e 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/pensjonforvalter/PensjonforvalterClient.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/pensjonforvalter/PensjonforvalterClient.java @@ -74,8 +74,8 @@ public Flux gjenopprett(RsDollyUtvidetBestilling bestilling, Dolly .flatMapMany(utvidetPersondata -> Flux.concat( pensjonPersondataService.lagrePersondata(dollyPerson.getIdent(), utvidetPersondata.getT1(), tilgjengeligeMiljoer), - pensjonPensjonsdataService.lagrePensjonsdata(bestilling1, dollyPerson.getIdent(), tilgjengeligeMiljoer), - pensjonVedtakService.lagrePensjonVedtak(bestilling1, dollyPerson.getIdent(), utvidetPersondata, tilgjengeligeMiljoer) + pensjonPensjonsdataService.lagrePensjonsdata(bestilling1, dollyPerson.getIdent(), bestilteMiljoer.get()), + pensjonVedtakService.lagrePensjonVedtak(bestilling1, dollyPerson.getIdent(), utvidetPersondata, bestilteMiljoer.get()) ))) .timeout(Duration.ofSeconds(applicationConfig.getClientTimeout())) diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/config/MigrationConfig.java b/apps/dolly-backend/src/main/java/no/nav/dolly/config/MigrationConfig.java new file mode 100644 index 00000000000..84fad84fe93 --- /dev/null +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/config/MigrationConfig.java @@ -0,0 +1,29 @@ +package no.nav.dolly.config; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import no.nav.dolly.service.MigrateDokumentService; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; + +import javax.annotation.PostConstruct; + +@Slf4j +@Configuration +@Profile("!test") +@RequiredArgsConstructor +public class MigrationConfig { + + private final MigrateDokumentService migrateDokumentService; + + @PostConstruct + public void migrateDokumenter() { + + var time = System.currentTimeMillis(); + log.info("Starter migrering av dokumenter."); + + migrateDokumentService.migrateDokumenter(); + + log.info("Migrering av dokumenter ferdig, medgått tid: {} sekunder", (System.currentTimeMillis() - time) / 1000); + } +} diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/domain/jpa/Dokument.java b/apps/dolly-backend/src/main/java/no/nav/dolly/domain/jpa/Dokument.java new file mode 100644 index 00000000000..6352100b3ff --- /dev/null +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/domain/jpa/Dokument.java @@ -0,0 +1,91 @@ +package no.nav.dolly.domain.jpa; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import jakarta.persistence.Version; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.hibernate.annotations.UpdateTimestamp; + +import java.io.Serializable; +import java.time.LocalDateTime; + +@Entity +@Getter +@Setter +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Table(name = "DOKUMENT") +public class Dokument implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Version + @Column(name = "VERSJON") + private Long versjon; + + @Column(name = "BESTILLING_ID") + private Long bestillingId; + + @Column(name = "DOKUMENT_TYPE") + @Enumerated(value = EnumType.STRING) + private DokumentType dokumentType; + + @Column(name = "SIST_OPPDATERT") + @UpdateTimestamp + private LocalDateTime sistOppdatert; + + @Column(name = "CONTENTS") + private String contents; + + @Override + public boolean equals(Object o) { + if (this == o) return true; + + if (o == null || getClass() != o.getClass()) return false; + + Dokument dokument = (Dokument) o; + + return new EqualsBuilder() + .append(id, dokument.id) + .append(versjon, dokument.versjon) + .append(bestillingId, dokument.bestillingId) + .append(dokumentType, dokument.dokumentType) + .append(sistOppdatert, dokument.sistOppdatert) + .append(contents, dokument.contents) + .isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder(17, 37) + .append(id) + .append(versjon) + .append(bestillingId) + .append(dokumentType) + .append(sistOppdatert) + .append(contents) + .toHashCode(); + } + + public enum DokumentType { + BESTILLING_DOKARKIV, + BESTILLING_HISTARK, + MAL_BESTILLING_DOKARKIV, + MAL_BESTILLING_HISTARK + } +} \ No newline at end of file diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/domain/resultset/dokarkiv/RsDokarkiv.java b/apps/dolly-backend/src/main/java/no/nav/dolly/domain/resultset/dokarkiv/RsDokarkiv.java index 07a32ca3930..7bc2e0d688d 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/domain/resultset/dokarkiv/RsDokarkiv.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/domain/resultset/dokarkiv/RsDokarkiv.java @@ -135,6 +135,9 @@ public static class DokumentVariant { @Field(enabled = false) private String fysiskDokument; + @Schema(description = "Referanse til dokumentet") + private Long dokumentReferanse; + @Schema(description = """ ARKIV brukes for dokumentvarianter i menneskelesbart format (for eksempel PDFA). Gosys og nav.no henter arkivvariant og viser denne til bruker. diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/domain/resultset/histark/RsHistark.java b/apps/dolly-backend/src/main/java/no/nav/dolly/domain/resultset/histark/RsHistark.java index ab634393114..d3056c88b51 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/domain/resultset/histark/RsHistark.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/domain/resultset/histark/RsHistark.java @@ -82,5 +82,8 @@ public static class RsHistarkDokument { @Schema(description = "Selve PDF dokumentet. Ved fysisk dokument brukes bytearray.") @Field(enabled = false) private String fysiskDokument; + + @Schema(description = "Referanse til dokumentet") + private Long dokumentReferanse; } } diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/provider/api/DokumentController.java b/apps/dolly-backend/src/main/java/no/nav/dolly/provider/api/DokumentController.java new file mode 100644 index 00000000000..fde8ecc4e3e --- /dev/null +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/provider/api/DokumentController.java @@ -0,0 +1,45 @@ +package no.nav.dolly.provider.api; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import lombok.RequiredArgsConstructor; +import no.nav.dolly.domain.jpa.Dokument; +import no.nav.dolly.service.DokumentService; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/v1/dokument") +public class DokumentController { + + private final DokumentService dokumentService; + + @Operation(description = "Henter dokumenter basert på bestillingId") + @GetMapping("/bestilling/{bestillingId}") + public List getDokumenterRelatertTilBestilling(@Parameter(description = "bestillingId fra bestilling") + @PathVariable("bestillingId") Long bestilllingId) { + + return dokumentService.getDokumenterByBestilling(bestilllingId); + } + + @Operation(description = "Henter dokumenter basert på mal-Id") + @GetMapping("/mal/{malId}") + public List getDokumenterRelatertTilMal(@Parameter(description = "mal-Id fra mal") + @PathVariable("malId") Long malId) { + + return dokumentService.getDokumenterByMal(malId); + } + + @Operation(description = "Henter dokumenter basert på liste av dokumentId") + @GetMapping("/dokument/{dokumentId}") + public List getDokumenter(@Parameter(description = "Liste av dokumentId") + @PathVariable("dokumentId") List dokumentIdListe) { + + return dokumentService.getDokumenter(dokumentIdListe); + } +} \ No newline at end of file diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/repository/BestillingMalRepository.java b/apps/dolly-backend/src/main/java/no/nav/dolly/repository/BestillingMalRepository.java index a34581c3bd1..a42c06ee7c2 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/repository/BestillingMalRepository.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/repository/BestillingMalRepository.java @@ -18,4 +18,19 @@ public interface BestillingMalRepository extends CrudRepository findByBruker(Bruker bruker); + @Query(value = """ + from BestillingMal b + where b.bestKriterier like '%dokarkiv%' + and length(b.bestKriterier) > 10000 + order by b.id + """) + Iterable findAllByDokumentArkiv(); + + @Query(value = """ + from BestillingMal b + where b.bestKriterier like '%histark%' + and length(b.bestKriterier) > 10000 + order by b.id + """) + Iterable findAllByHistArk(); } diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/repository/BestillingRepository.java b/apps/dolly-backend/src/main/java/no/nav/dolly/repository/BestillingRepository.java index 939f470c0e8..940676c24f4 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/repository/BestillingRepository.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/repository/BestillingRepository.java @@ -85,11 +85,26 @@ public interface BestillingRepository extends CrudRepository { @Modifying @Query(""" - update Bestilling b - set b.ferdig = true, - b.stoppet = true - where b.ferdig = false -""") + update Bestilling b + set b.ferdig = true, + b.stoppet = true + where b.ferdig = false + """) int stopAllUnfinished(); + @Query(value = """ + from Bestilling b + where b.bestKriterier like '%dokarkiv%' + and length(b.bestKriterier) > 10000 + order by b.id + """) + Iterable findAllByDokumentArkiv(); + + @Query(value = """ + from Bestilling b + where b.bestKriterier like '%histark%' + and length(b.bestKriterier) > 10000 + order by b.id + """) + Iterable findAllByHistArk(); } diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/repository/DokumentRepository.java b/apps/dolly-backend/src/main/java/no/nav/dolly/repository/DokumentRepository.java new file mode 100644 index 00000000000..c5969e98e80 --- /dev/null +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/repository/DokumentRepository.java @@ -0,0 +1,14 @@ +package no.nav.dolly.repository; + +import no.nav.dolly.domain.jpa.Dokument; +import org.springframework.data.repository.CrudRepository; + +import java.util.Collection; +import java.util.List; + +public interface DokumentRepository extends CrudRepository { + + List getDokumentsByBestillingId(Long bestillingId); + + List getDokumentsByIdIsIn(Collection dokumentIdListe); +} \ No newline at end of file diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/service/BestillingService.java b/apps/dolly-backend/src/main/java/no/nav/dolly/service/BestillingService.java index 9ff4f121a0f..e85e38b5d78 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/service/BestillingService.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/service/BestillingService.java @@ -10,6 +10,8 @@ import no.nav.dolly.domain.jpa.BestillingKontroll; import no.nav.dolly.domain.jpa.BestillingProgress; import no.nav.dolly.domain.jpa.Bruker; +import no.nav.dolly.domain.jpa.Dokument; +import no.nav.dolly.domain.jpa.Dokument.DokumentType; import no.nav.dolly.domain.jpa.Testgruppe; import no.nav.dolly.domain.resultset.BestilteKriterier; import no.nav.dolly.domain.resultset.RsDollyBestilling; @@ -26,6 +28,7 @@ import no.nav.dolly.repository.BestillingKontrollRepository; import no.nav.dolly.repository.BestillingProgressRepository; import no.nav.dolly.repository.BestillingRepository; +import no.nav.dolly.repository.DokumentRepository; import no.nav.dolly.repository.IdentRepository; import no.nav.dolly.repository.TestgruppeRepository; import no.nav.testnav.libs.servletsecurity.action.GetUserInfo; @@ -78,6 +81,7 @@ public class BestillingService { private final GetUserInfo getUserInfo; private final BestillingElasticRepository elasticRepository; private final MiljoerConsumer miljoerConsumer; + private final DokumentRepository dokumentRepository; public Bestilling fetchBestillingById(Long bestillingId) { return bestillingRepository.findById(bestillingId) @@ -181,7 +185,8 @@ public Consumer cleanBestilling() { .getMethod("set" + metode.getName().substring(3), String.class); oppdaterMetode.invoke(progress, DEFAULT_VALUE); } - } catch (NoSuchMethodException | IllegalAccessException | + } catch (NoSuchMethodException | + IllegalAccessException | InvocationTargetException e) { log.error("Oppdatering av bestilling {} feilet ved stopp-kommando {}", bestilling.getId(), e.getMessage(), e); @@ -197,44 +202,50 @@ public Bestilling saveBestilling(RsDollyUpdateRequest request, String ident) { var bruker = fetchOrCreateBruker(); fixAaregAbstractClassProblem(request.getAareg()); - var bestilling = Bestilling.builder() + var bestilling = saveBestillingToDB(Bestilling.builder() .gruppe(testident.getTestgruppe()) .ident(ident) .antallIdenter(1) .navSyntetiskIdent(request.getNavSyntetiskIdent()) .sistOppdatert(now()) .miljoer(filterAvailable(request.getEnvironments())) - .bestKriterier(getBestKriterier(request)) .bruker(bruker) - .build(); + .build()); + + request.setId(bestilling.getId()); + bestilling.setBestKriterier(getBestKriterier(request)); if (isNotBlank(request.getMalBestillingNavn())) { malBestillingService.saveBestillingMal(bestilling, request.getMalBestillingNavn(), bruker); } - return saveBestillingToDB(bestilling); + return bestilling; } @Transactional public Bestilling saveBestilling(Long gruppeId, RsDollyBestilling request, Integer antall, List opprettFraIdenter, Boolean navSyntetiskIdent, String beskrivelse) { - Testgruppe gruppe = testgruppeRepository.findById(gruppeId).orElseThrow(() -> new NotFoundException(NOT_FOUND + gruppeId)); + var gruppe = testgruppeRepository.findById(gruppeId).orElseThrow(() -> new NotFoundException(NOT_FOUND + gruppeId)); + fixAaregAbstractClassProblem(request.getAareg()); + var bruker = fetchOrCreateBruker(); - Bestilling bestilling = Bestilling.builder() + var bestilling = saveBestillingToDB(Bestilling.builder() .gruppe(gruppe) .antallIdenter(antall) .navSyntetiskIdent(navSyntetiskIdent) .sistOppdatert(now()) .miljoer(filterAvailable(request.getEnvironments())) - .bestKriterier(getBestKriterier(request)) .opprettFraIdenter(nonNull(opprettFraIdenter) ? join(",", opprettFraIdenter) : null) .bruker(bruker) .beskrivelse(beskrivelse) - .build(); - fixAaregAbstractClassProblem(request.getAareg()); + .build()); + + request.setId(bestilling.getId()); + bestilling.setBestKriterier(getBestKriterier(request)); + if (isNotBlank(request.getMalBestillingNavn())) { malBestillingService.saveBestillingMal(bestilling, request.getMalBestillingNavn(), bruker); } - return saveBestillingToDB(bestilling); + return bestilling; } @Transactional @@ -302,24 +313,27 @@ public Bestilling createBestillingForGjenopprettFraGruppe(Long gruppeId, String @Transactional public Bestilling saveBestilling(Long gruppeId, RsDollyImportFraPdlRequest request) { - Testgruppe gruppe = testgruppeRepository.findById(gruppeId).orElseThrow(() -> new NotFoundException(NOT_FOUND + gruppeId)); + var gruppe = testgruppeRepository.findById(gruppeId).orElseThrow(() -> new NotFoundException(NOT_FOUND + gruppeId)); var bruker = fetchOrCreateBruker(); - Bestilling bestilling = Bestilling.builder() + fixAaregAbstractClassProblem(request.getAareg()); + + var bestilling = saveBestillingToDB(Bestilling.builder() .gruppe(gruppe) .kildeMiljoe("PDL") .miljoer(filterAvailable(request.getEnvironments())) .sistOppdatert(now()) .bruker(bruker) .antallIdenter(request.getIdenter().size()) - .bestKriterier(getBestKriterier(request)) .pdlImport(join(",", request.getIdenter())) - .build(); + .build()); + + request.setId(bestilling.getId()); + bestilling.setBestKriterier(getBestKriterier(request)); - fixAaregAbstractClassProblem(request.getAareg()); if (isNotBlank(request.getMalBestillingNavn())) { malBestillingService.saveBestillingMal(bestilling, request.getMalBestillingNavn(), bruker); } - return saveBestillingToDB(bestilling); + return bestilling; } @Transactional @@ -329,7 +343,8 @@ public Bestilling saveBestilling(Long gruppeId, RsDollyBestillingLeggTilPaaGrupp var size = identRepository.countByTestgruppe(gruppeId); log.info("Antall testidenter {} i gruppe {} ", size, gruppeId); fixAaregAbstractClassProblem(request.getAareg()); - return saveBestillingToDB( + + var bestilling = saveBestillingToDB( Bestilling.builder() .gruppe(gruppe) .miljoer(filterAvailable(request.getEnvironments())) @@ -337,8 +352,12 @@ public Bestilling saveBestilling(Long gruppeId, RsDollyBestillingLeggTilPaaGrupp .bruker(fetchOrCreateBruker()) .antallIdenter(size) .navSyntetiskIdent(request.getNavSyntetiskIdent()) - .bestKriterier(getBestKriterier(request)) .build()); + + request.setId(bestilling.getId()); + bestilling.setBestKriterier(getBestKriterier(request)); + + return bestilling; } public void slettBestillingerByGruppeId(Long gruppeId) { @@ -387,6 +406,8 @@ public void swapIdent(String oldIdent, String newIdent) { } public String getBestKriterier(RsDollyBestilling request) { + + lagreDokumenter(request); return toJson(BestilteKriterier.builder() .aareg(request.getAareg()) .krrstub(request.getKrrstub()) @@ -414,6 +435,40 @@ public String getBestKriterier(RsDollyBestilling request) { .build()); } + private void lagreDokumenter(RsDollyBestilling request) { + + if (nonNull(request.getDokarkiv())) { + request.getDokarkiv().getDokumenter().forEach(dokument -> + dokument.getDokumentvarianter().forEach(dokumentVariant -> { + if (isNotBlank(dokumentVariant.getFysiskDokument())) { + dokumentVariant.setDokumentReferanse(lagreDokument(dokumentVariant.getFysiskDokument(), request.getId(), DokumentType.BESTILLING_DOKARKIV)); + dokumentVariant.setFysiskDokument(null); + } + })); + } + + if (nonNull(request.getHistark())) { + request.getHistark().getDokumenter().forEach(dokument -> { + if (isNotBlank(dokument.getFysiskDokument())) { + dokument.setDokumentReferanse(lagreDokument(dokument.getFysiskDokument(), request.getId(), DokumentType.BESTILLING_HISTARK)); + dokument.setFysiskDokument(null); + } + }); + } + } + + private Long lagreDokument(String dokument, Long bestillingId, DokumentType dokumentType) { + + return dokumentRepository + .save(Dokument.builder() + .contents(dokument) + .bestillingId(bestillingId) + .dokumentType(dokumentType) + .build()) + .getId(); + } + + public List getProgressByBestillingId(Long bestillingId) { return bestillingProgressRepository.findByBestilling_Id(bestillingId); diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/service/DokumentService.java b/apps/dolly-backend/src/main/java/no/nav/dolly/service/DokumentService.java new file mode 100644 index 00000000000..52e1542e0ff --- /dev/null +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/service/DokumentService.java @@ -0,0 +1,77 @@ +package no.nav.dolly.service; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.RequiredArgsConstructor; +import no.nav.dolly.domain.jpa.Dokument; +import no.nav.dolly.domain.resultset.RsDollyUtvidetBestilling; +import no.nav.dolly.domain.resultset.dokarkiv.RsDokarkiv; +import no.nav.dolly.domain.resultset.histark.RsHistark; +import no.nav.dolly.repository.BestillingMalRepository; +import no.nav.dolly.repository.DokumentRepository; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.server.ResponseStatusException; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +@Service +@RequiredArgsConstructor +public class DokumentService { + + private final DokumentRepository dokumentRepository; + private final BestillingMalRepository bestillingMalRepository; + private final ObjectMapper objectMapper; + + @Transactional(readOnly = true) + public List getDokumenterByBestilling(Long bestillingId) { + + return dokumentRepository.getDokumentsByBestillingId(bestillingId); + } + + @Transactional(readOnly = true) + public List getDokumenterByMal(Long malId) { + + return bestillingMalRepository.findById(malId) + .map(malBestilling -> fromJson(malBestilling.getBestKriterier())) + .map(kriterier -> Stream.concat( + Optional.ofNullable(kriterier.getDokarkiv()) + .map(RsDokarkiv::getDokumenter) + .stream() + .flatMap(Collection::stream) + .map(RsDokarkiv.Dokument::getDokumentvarianter) + .flatMap(Collection::stream) + .map(RsDokarkiv.Dokument.DokumentVariant::getDokumentReferanse), + Optional.ofNullable(kriterier.getHistark()) + .map(RsHistark::getDokumenter) + .stream() + .flatMap(Collection::stream) + .map(RsHistark.RsHistarkDokument::getDokumentReferanse) + ) + .collect(Collectors.toSet()) + ) + .map(dokumentRepository::getDokumentsByIdIsIn) + .orElse(Collections.emptyList()); + } + + @Transactional(readOnly = true) + public List getDokumenter(List dokumentIdListe) { + + return dokumentRepository.getDokumentsByIdIsIn(dokumentIdListe); + } + + private RsDollyUtvidetBestilling fromJson(String json) { + + try { + return objectMapper.readValue(json, RsDollyUtvidetBestilling.class); + } catch (JsonProcessingException e) { + throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage(), e); + } + } +} diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/service/MalBestillingService.java b/apps/dolly-backend/src/main/java/no/nav/dolly/service/MalBestillingService.java index 3e122762ffa..d4cf6a529f9 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/service/MalBestillingService.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/service/MalBestillingService.java @@ -24,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.server.ResponseStatusException; +import java.time.LocalDateTime; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -139,6 +140,7 @@ public void saveBestillingMal(Bestilling bestilling, String malNavn, Bruker bruk .bruker(bruker) .malNavn(malNavn) .miljoer(bestilling.getMiljoer()) + .sistOppdatert(LocalDateTime.now()) .build()); } else { @@ -166,6 +168,7 @@ public RsMalBestilling saveBestillingMalFromBestillingId(Long bestillingId, Stri .bruker(bruker) .malNavn(malNavn) .miljoer(bestilling.getMiljoer()) + .sistOppdatert(LocalDateTime.now()) .build()); } else { malbestilling = maler.getFirst(); diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/service/MigrateDokumentService.java b/apps/dolly-backend/src/main/java/no/nav/dolly/service/MigrateDokumentService.java new file mode 100644 index 00000000000..c2633363c11 --- /dev/null +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/service/MigrateDokumentService.java @@ -0,0 +1,151 @@ +package no.nav.dolly.service; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import no.nav.dolly.domain.jpa.Bestilling; +import no.nav.dolly.domain.jpa.BestillingMal; +import no.nav.dolly.domain.jpa.Dokument; +import no.nav.dolly.domain.jpa.Dokument.DokumentType; +import no.nav.dolly.domain.resultset.RsDollyUtvidetBestilling; +import no.nav.dolly.repository.BestillingMalRepository; +import no.nav.dolly.repository.BestillingRepository; +import no.nav.dolly.repository.DokumentRepository; +import org.springframework.stereotype.Service; + +import java.util.Spliterator; +import java.util.Spliterators; +import java.util.stream.StreamSupport; + +import static java.util.Objects.nonNull; +import static no.nav.dolly.domain.jpa.Dokument.DokumentType.BESTILLING_DOKARKIV; +import static no.nav.dolly.domain.jpa.Dokument.DokumentType.BESTILLING_HISTARK; +import static no.nav.dolly.domain.jpa.Dokument.DokumentType.MAL_BESTILLING_DOKARKIV; +import static no.nav.dolly.domain.jpa.Dokument.DokumentType.MAL_BESTILLING_HISTARK; +import static org.apache.commons.lang3.StringUtils.isNotBlank; + +@Slf4j +@Service +@RequiredArgsConstructor +public class MigrateDokumentService { + + private final BestillingRepository bestillingRepository; + private final BestillingMalRepository bestillingMalRepository; + private final DokumentRepository dokumentRepository; + private final ObjectMapper objectMapper; + + public void migrateDokumenter() { + + migrateBestillinger(bestillingRepository.findAllByDokumentArkiv(), lagreDokarkiv(), BESTILLING_DOKARKIV); + migrateBestillinger(bestillingRepository.findAllByHistArk(), lagreHistark(), BESTILLING_HISTARK); + migrateMalBestillinger(bestillingMalRepository.findAllByDokumentArkiv(), lagreDokarkiv(), MAL_BESTILLING_DOKARKIV); + migrateMalBestillinger(bestillingMalRepository.findAllByHistArk(), lagreHistark(), MAL_BESTILLING_HISTARK); + } + + private void migrateMalBestillinger(Iterable query, TriConsumer lagreDokument, DokumentType dokumentType) { + + StreamSupport.stream(Spliterators.spliteratorUnknownSize( + query.iterator(), Spliterator.ORDERED), false) + .forEach(malBestilling -> { + try { + storeMalDokument(lagreDokument, dokumentType, malBestilling); + } catch (RuntimeException e) { + log.error("Lagring av malbestilling {} feilet: {} ", malBestilling.getId(), e.getMessage(), e); + } + }); + } + + public void storeMalDokument(TriConsumer lagreDokument, DokumentType dokumentType, BestillingMal malBestilling) { + + log.info("Migrerer malbestilling for id {} ... ", malBestilling.getId()); + var utvidetBestilling = fromJson(malBestilling.getBestKriterier(), malBestilling.getId()); + if (nonNull(utvidetBestilling)) { + lagreDokument.apply(utvidetBestilling, malBestilling.getId(), dokumentType); + var oppdatertBestilling = toJson(utvidetBestilling, malBestilling.getId()); + malBestilling.setBestKriterier(isNotBlank(oppdatertBestilling) ? oppdatertBestilling : malBestilling.getBestKriterier()); + } + log.info("Malbestilling med id {} ferdig!", malBestilling.getId()); + } + + private void migrateBestillinger(Iterable query, TriConsumer lagreDokument, DokumentType dokumentType) { + + StreamSupport.stream(Spliterators.spliteratorUnknownSize( + query.iterator(), Spliterator.ORDERED), false) + .forEach(bestilling -> { + try { + storeDokument(lagreDokument, dokumentType, bestilling); + } catch (RuntimeException e) { + log.error("Lagring av bestilling {} feilet: {} ", bestilling.getId(), e.getMessage(), e); + } + }); + } + + public void storeDokument(TriConsumer lagreDokument, DokumentType dokumentType, Bestilling bestilling) { + + log.info("Migrerer bestilling for id {} ... ", bestilling.getId()); + var utvidetBestilling = fromJson(bestilling.getBestKriterier(), bestilling.getId()); + if (nonNull(utvidetBestilling)) { + lagreDokument.apply(utvidetBestilling, bestilling.getId(), dokumentType); + var oppdatertBestilling = toJson(utvidetBestilling, bestilling.getId()); + bestilling.setBestKriterier(isNotBlank(oppdatertBestilling) ? oppdatertBestilling : bestilling.getBestKriterier()); + } + log.info("Bestilling med id {} ferdig!", bestilling.getId()); + } + + private TriConsumer lagreDokarkiv() { + + return (utvidetBestilling, bestillingId, dokumentType) -> + utvidetBestilling.getDokarkiv().getDokumenter().forEach(dokument -> + dokument.getDokumentvarianter().forEach(dokumentVariant -> { + if (nonNull(dokumentVariant.getFysiskDokument())) { + dokumentVariant.setDokumentReferanse( + storeMalDokument(dokumentVariant.getFysiskDokument(), bestillingId, dokumentType)); + dokumentVariant.setFysiskDokument(null); + } + })); + } + + private TriConsumer lagreHistark() { + + return (utvidetBestilling, bestillingId, dokumentType) -> + utvidetBestilling.getHistark().getDokumenter().forEach(dokument -> { + if (nonNull(dokument.getFysiskDokument())) { + dokument.setDokumentReferanse( + storeMalDokument(dokument.getFysiskDokument(), bestillingId, dokumentType)); + dokument.setFysiskDokument(null); + } + }); + } + + private Long storeMalDokument(String fysiskDokument, Long bestillingId, DokumentType dokumentType) { + + return dokumentRepository.save(Dokument.builder() + .contents(fysiskDokument) + .dokumentType(dokumentType) + .bestillingId(bestillingId) + .build()).getId(); + } + + private RsDollyUtvidetBestilling fromJson(String kriterier, Long bestillingId) { + + try { + return objectMapper.readValue(kriterier, RsDollyUtvidetBestilling.class); + + } catch (JsonProcessingException e) { + log.error("Konvertering fra JSON av bestilling {} feilet: {} ", bestillingId, e.getMessage(), e); + return null; + } + } + + private String toJson(RsDollyUtvidetBestilling dollyUtvidetBestilling, Long bestillingId) { + + try { + return objectMapper.writeValueAsString(dollyUtvidetBestilling); + + } catch (JsonProcessingException e) { + log.error("Konvertering til JSON av bestilling {} feilet, {} ", bestillingId, e.getMessage(), e); + return null; + } + } +} diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/service/TriConsumer.java b/apps/dolly-backend/src/main/java/no/nav/dolly/service/TriConsumer.java new file mode 100644 index 00000000000..dcd41ba9890 --- /dev/null +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/service/TriConsumer.java @@ -0,0 +1,6 @@ +package no.nav.dolly.service; + +@FunctionalInterface +public interface TriConsumer { + void apply(S var1, T var2, U var3); +} diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/util/TransactionHelperService.java b/apps/dolly-backend/src/main/java/no/nav/dolly/util/TransactionHelperService.java index 570a83ed04d..efdabb4c008 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/util/TransactionHelperService.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/util/TransactionHelperService.java @@ -198,6 +198,7 @@ public Bestilling persister(Long bestillingId, RsDollyBestilling bestilling) { var akkumulert = new AtomicReference(null); bestillingRepository.findByIdAndLock(bestillingId) .ifPresent(best -> { + bestilling.setId(bestillingId); best.setBestKriterier(bestillingService.getBestKriterier(bestilling)); akkumulert.set(bestillingRepository.save(best)); }); diff --git a/apps/dolly-backend/src/main/resources/application-local.yml b/apps/dolly-backend/src/main/resources/application-local.yml index ac07258e578..e2aa7e2a7e7 100644 --- a/apps/dolly-backend/src/main/resources/application-local.yml +++ b/apps/dolly-backend/src/main/resources/application-local.yml @@ -27,6 +27,12 @@ management: elasticsearch: enabled: false +azure: + app: + client: + id: ${sm://azure-app-client-id} + secret: ${sm://azure-app-client-secret} + open: search: uri: http://localhost:9200 diff --git a/apps/dolly-backend/src/main/resources/application.yml b/apps/dolly-backend/src/main/resources/application.yml index 6caad4f8bde..7187259ca47 100644 --- a/apps/dolly-backend/src/main/resources/application.yml +++ b/apps/dolly-backend/src/main/resources/application.yml @@ -64,15 +64,14 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: health: show-components: always show-details: always - heapdump: - enabled: true prometheus: enabled: true prometheus: diff --git a/apps/dolly-backend/src/main/resources/db/migration/V1.8.0__CreateTableDokumenter.sql b/apps/dolly-backend/src/main/resources/db/migration/V1.8.0__CreateTableDokumenter.sql new file mode 100644 index 00000000000..92a1c04328e --- /dev/null +++ b/apps/dolly-backend/src/main/resources/db/migration/V1.8.0__CreateTableDokumenter.sql @@ -0,0 +1,13 @@ +------------------------------- +-- C R E A T E T A B L E S -- +------------------------------- + +CREATE TABLE IF NOT EXISTS dokument +( + id SERIAL PRIMARY KEY, + bestilling_id BIGINT NOT NULL, + dokument_type VARCHAR(30) NOT NULL, + sist_oppdatert TIMESTAMP NOT NULL, + versjon SMALLINT NOT NULL, + contents TEXT NOT NULL +) \ No newline at end of file diff --git a/apps/dolly-backend/src/test/java/no/nav/dolly/service/BestillingServiceTest.java b/apps/dolly-backend/src/test/java/no/nav/dolly/service/BestillingServiceTest.java index 93483d7a6ce..1b58f5a39c6 100644 --- a/apps/dolly-backend/src/test/java/no/nav/dolly/service/BestillingServiceTest.java +++ b/apps/dolly-backend/src/test/java/no/nav/dolly/service/BestillingServiceTest.java @@ -104,6 +104,7 @@ void saveBestillingByGruppeIdAndAntallIdenterInkludererAlleMiljoerOgIdenterIBest when(testgruppeRepository.findById(gruppeId)).thenReturn(Optional.of(gruppe)); when(miljoerConsumer.getMiljoer()).thenReturn(Mono.just(new ArrayList<>(miljoer))); + when(bestillingRepository.save(any(Bestilling.class))).thenReturn(Bestilling.builder().id(1L).build()); bestillingService.saveBestilling(gruppeId, RsDollyBestilling.builder().environments(miljoer).build(), antallIdenter, null, null, null); diff --git a/apps/dolly-frontend/src/main/js/src/components/bestillingsveileder/stegVelger/steg/steg1/paneler/Pensjon.tsx b/apps/dolly-frontend/src/main/js/src/components/bestillingsveileder/stegVelger/steg/steg1/paneler/Pensjon.tsx index eb151e04e83..ef84c34e5c6 100644 --- a/apps/dolly-frontend/src/main/js/src/components/bestillingsveileder/stegVelger/steg/steg1/paneler/Pensjon.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/bestillingsveileder/stegVelger/steg/steg1/paneler/Pensjon.tsx @@ -1,4 +1,4 @@ -import React from 'react' +import React, { useContext } from 'react' import Panel from '@/components/ui/panel/Panel' import { Attributt, AttributtKategori } from '../Attributt' import { @@ -17,20 +17,48 @@ import { initialAfpOffentlig } from '@/components/fagsystem/afpOffentlig/initial import { avtalePath } from '@/components/fagsystem/pensjonsavtale/form/Form' import { afpOffentligPath } from '@/components/fagsystem/afpOffentlig/form/Form' import { initialPensjonInntekt } from '@/components/fagsystem/pensjon/form/initialValues' +import { BestillingsveilederContext } from '@/components/bestillingsveileder/BestillingsveilederContext' export const PensjonPanel = ({ stateModifier, formValues }: any) => { const sm = stateModifier(PensjonPanel.initialValues) + const opts: any = useContext(BestillingsveilederContext) + + const harGyldigApBestilling = opts?.tidligereBestillinger?.some((bestilling) => + bestilling.status?.some( + (status) => status.id === 'PEN_AP' && status.statuser?.some((item) => item?.melding === 'OK'), + ), + ) + + const harGyldigUforetrygdBestilling = opts?.tidligereBestillinger?.some((bestilling) => + bestilling.status?.some( + (status) => status.id === 'PEN_UT' && status.statuser?.some((item) => item.melding === 'OK'), + ), + ) + const infoTekst = 'Pensjon: \nPensjonsgivende inntekt: \nInntektene blir lagt til i POPP-register. \n\n' + 'Tjenestepensjon: \nTjenestepensjonsforhold lagt til i TP. \n\n' + 'Alderspensjon: \nAlderspensjonssak med vedtak blir lagt til i PEN.' + const getIgnoreKeys = () => { + const ignoreKeys = [] + if (harGyldigApBestilling) { + ignoreKeys.push('alderspensjon') + } + if (harGyldigUforetrygdBestilling) { + ignoreKeys.push('uforetrygd') + } + return ignoreKeys + } + return ( { + sm.batchAdd(getIgnoreKeys()) + }} uncheckAttributeArray={sm.batchRemove} iconType="pensjon" startOpen={harValgtAttributt(formValues, [ @@ -52,10 +80,18 @@ export const PensjonPanel = ({ stateModifier, formValues }: any) => { - + - + diff --git a/apps/dolly-frontend/src/main/js/src/components/bestillingsveileder/stegVelger/steg/steg1/paneler/Udi.tsx b/apps/dolly-frontend/src/main/js/src/components/bestillingsveileder/stegVelger/steg/steg1/paneler/Udi.tsx index 103c1205d90..e5bf7641501 100644 --- a/apps/dolly-frontend/src/main/js/src/components/bestillingsveileder/stegVelger/steg/steg1/paneler/Udi.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/bestillingsveileder/stegVelger/steg/steg1/paneler/Udi.tsx @@ -58,7 +58,8 @@ UdiPanel.initialValues = ({ set, setMulti, del, has }) => ({ checked: has('udistub.oppholdStatus'), add: () => setMulti(['udistub.oppholdStatus', {}], ['pdldata.person.opphold', [initialOpphold]]), - remove: () => del(['udistub.oppholdStatus', 'pdldata.person.opphold']), + remove: () => + del(['udistub.oppholdStatus', 'udistub.harOppholdsTillatelse', 'pdldata.person.opphold']), }, arbeidsadgang: { label: 'Arbeidsadgang', diff --git a/apps/dolly-frontend/src/main/js/src/components/fagsystem/arbeidsplassen/form/CvForm.less b/apps/dolly-frontend/src/main/js/src/components/fagsystem/arbeidsplassen/form/CvForm.less index 25fce522bf0..62a52b900a2 100644 --- a/apps/dolly-frontend/src/main/js/src/components/fagsystem/arbeidsplassen/form/CvForm.less +++ b/apps/dolly-frontend/src/main/js/src/components/fagsystem/arbeidsplassen/form/CvForm.less @@ -6,13 +6,7 @@ position: relative; } - .navds-date .rdp-button { position: unset; } - - && .navds-button { - position: unset; - } - } \ No newline at end of file diff --git a/apps/dolly-frontend/src/main/js/src/components/fagsystem/arbeidsplassen/form/initialValues.tsx b/apps/dolly-frontend/src/main/js/src/components/fagsystem/arbeidsplassen/form/initialValues.tsx index 2832c8475cc..f375510601c 100644 --- a/apps/dolly-frontend/src/main/js/src/components/fagsystem/arbeidsplassen/form/initialValues.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/fagsystem/arbeidsplassen/form/initialValues.tsx @@ -48,21 +48,6 @@ export const initialJobboenskerVerdier = { workScheduleTypes: ['DAGTID', 'UKEDAGER', 'KVELD'], } -export const initialCV = { - jobboensker: initialJobboensker, - utdanning: [], - fagbrev: [], - arbeidserfaring: [], - annenErfaring: [], - kompetanser: [], - offentligeGodkjenninger: [], - andreGodkjenninger: [], - spraak: [], - foererkort: [], - kurs: [], - sammendrag: '', -} - export const initialArbeidserfaring = { employer: '', jobTitle: '', @@ -128,7 +113,7 @@ export const initialAnnenErfaring = { export const initialAnnenErfaringVerdier = { description: 'Mange års erfaring med trening av sau til utstillinger.', role: 'Sauetrener', - fromDate: '2010-05-01T00:00:00+02:00', + fromDate: '2010-05-01T00:00:00', toDate: null, ongoing: true, } diff --git a/apps/dolly-frontend/src/main/js/src/components/fagsystem/dokarkiv/visning/DokarkivVisning.tsx b/apps/dolly-frontend/src/main/js/src/components/fagsystem/dokarkiv/visning/DokarkivVisning.tsx index 41d63a28216..591bf302d52 100644 --- a/apps/dolly-frontend/src/main/js/src/components/fagsystem/dokarkiv/visning/DokarkivVisning.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/fagsystem/dokarkiv/visning/DokarkivVisning.tsx @@ -28,7 +28,10 @@ export default ({ journalpost, miljoe }: Props) => { bestillingIdListe: Array loading: boolean + tilgjengeligMiljoe?: string } type MiljoDataListe = { diff --git a/apps/dolly-frontend/src/main/js/src/components/fagsystem/histark/visning/Visning.tsx b/apps/dolly-frontend/src/main/js/src/components/fagsystem/histark/visning/Visning.tsx index 7ee5d2e01a2..f00ef0e95e4 100644 --- a/apps/dolly-frontend/src/main/js/src/components/fagsystem/histark/visning/Visning.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/fagsystem/histark/visning/Visning.tsx @@ -5,7 +5,6 @@ import { Journalpost } from '@/service/services/JoarkDokumentService' interface Form { data?: Array - bestillingIdListe: Array loading: boolean } diff --git a/apps/dolly-frontend/src/main/js/src/components/fagsystem/inntektsmelding/form/partials/orgnrToogle.tsx b/apps/dolly-frontend/src/main/js/src/components/fagsystem/inntektsmelding/form/partials/orgnrToogle.tsx index 6da3a2b81bd..46471bf2e24 100644 --- a/apps/dolly-frontend/src/main/js/src/components/fagsystem/inntektsmelding/form/partials/orgnrToogle.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/fagsystem/inntektsmelding/form/partials/orgnrToogle.tsx @@ -48,10 +48,14 @@ export const OrgnrToggle = ({ const handleToggleChange = (value: string) => { setInputType(value) formMethods.setValue(virksomhetPath, '') + formMethods.clearErrors(`manual.${virksomhetPath}`) + formMethods.clearErrors(virksomhetPath) } const handleChangeEgne = (value: { orgnr: string }) => { formMethods.setValue(virksomhetPath, value.orgnr) + formMethods.clearErrors(`manual.${virksomhetPath}`) + formMethods.clearErrors(virksomhetPath) } if (fasteOrganisasjonerLoading || brukerOrganisasjonerLoading) { diff --git a/apps/dolly-frontend/src/main/js/src/components/fagsystem/pdl/visning/PdlVisning.tsx b/apps/dolly-frontend/src/main/js/src/components/fagsystem/pdl/visning/PdlVisning.tsx index 7948cbdc1fb..f5389419052 100644 --- a/apps/dolly-frontend/src/main/js/src/components/fagsystem/pdl/visning/PdlVisning.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/fagsystem/pdl/visning/PdlVisning.tsx @@ -76,6 +76,8 @@ export const PdlVisning = ({ (id) => !id.historisk && id.gruppe === 'FOLKEREGISTERIDENT', ) + const erDoed = doedsfall?.find((d) => d.doedsdato) + return (
@@ -129,7 +131,7 @@ export const PdlVisning = ({ erPdlVisning={miljoeVisning} /> - + {!erDoed && } d.doedsdato) + return (
@@ -196,7 +198,7 @@ export const PdlfVisning = ({ fagsystemData, loading, tmpPersoner, erRedigerbar ident={ident} erRedigerbar={erRedigerbar} /> - + {!erDoed && } { setTypeArbeidsgiver(value) formMethods.clearErrors(path) + formMethods.clearErrors(`manual.${path}`) if (value === ArbeidsgiverTyper.privat) { formMethods.setValue(personPath, '') formMethods.setValue(organisasjonPath, undefined) @@ -95,6 +96,8 @@ export const ArbeidsgiverToggle = ({ formMethods, path }: ArbeidsgiverToggleProp const handleOrgChange = (value: { orgnr: string }) => { formMethods.setValue(organisasjonPath, value.orgnr) + formMethods.clearErrors(path) + formMethods.clearErrors(`manual.${path}`) formMethods.trigger(organisasjonPath) } diff --git a/apps/dolly-frontend/src/main/js/src/pages/gruppe/PersonVisning/PersonVisning.tsx b/apps/dolly-frontend/src/main/js/src/pages/gruppe/PersonVisning/PersonVisning.tsx index 22dc526611b..ab5be89ed17 100644 --- a/apps/dolly-frontend/src/main/js/src/pages/gruppe/PersonVisning/PersonVisning.tsx +++ b/apps/dolly-frontend/src/main/js/src/pages/gruppe/PersonVisning/PersonVisning.tsx @@ -105,8 +105,8 @@ import { ArenaVisning } from '@/components/fagsystem/arena/visning/ArenaVisning' import { KrrVisning } from '@/components/fagsystem/krrstub/visning/KrrVisning' import { UdiVisning } from '@/components/fagsystem/udistub/visning/UdiVisning' -import DokarkivVisning from '@/components/fagsystem/dokarkiv/visning/DokarkivVisning' -import HistarkVisning from '@/components/fagsystem/histark/visning/HistarkVisning' +import DokarkivVisning from '@/components/fagsystem/dokarkiv/visning/Visning' +import HistarkVisning from '@/components/fagsystem/histark/visning/Visning' const getIdenttype = (ident) => { if (parseInt(ident.charAt(0)) > 3) { diff --git a/apps/dolly-frontend/src/main/js/src/pages/tenorSoek/resultatVisning/TabsVisning.tsx b/apps/dolly-frontend/src/main/js/src/pages/tenorSoek/resultatVisning/TabsVisning.tsx index 3724e2ed864..16545afd3df 100644 --- a/apps/dolly-frontend/src/main/js/src/pages/tenorSoek/resultatVisning/TabsVisning.tsx +++ b/apps/dolly-frontend/src/main/js/src/pages/tenorSoek/resultatVisning/TabsVisning.tsx @@ -1,7 +1,8 @@ import { Tabs } from '@navikt/ds-react' -import React, { lazy } from 'react' +import React, { lazy, Suspense } from 'react' import styled from 'styled-components' import { FileCodeIcon, KeyVerticalIcon } from '@navikt/aksel-icons' +import Loading from '@/components/ui/loading/Loading' const TabsVisningFormatter = styled.div` width: 100%; @@ -56,7 +57,9 @@ export const TabsVisning = ({ children, kildedata }: any) => { marginBottom: '15px', }} > - + }> + + diff --git a/apps/dolly-frontend/src/main/resources/application.yml b/apps/dolly-frontend/src/main/resources/application.yml index 1731e1a42b7..d448be506fd 100644 --- a/apps/dolly-frontend/src/main/resources/application.yml +++ b/apps/dolly-frontend/src/main/resources/application.yml @@ -246,12 +246,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/dollystatus/src/main/resources/application.yml b/apps/dollystatus/src/main/resources/application.yml index 069adad970b..02b34f3f5a6 100644 --- a/apps/dollystatus/src/main/resources/application.yml +++ b/apps/dollystatus/src/main/resources/application.yml @@ -3,12 +3,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/endringsmelding-frontend/src/main/resources/application.yml b/apps/endringsmelding-frontend/src/main/resources/application.yml index 38f3e2e9a89..0437a6213d6 100644 --- a/apps/endringsmelding-frontend/src/main/resources/application.yml +++ b/apps/endringsmelding-frontend/src/main/resources/application.yml @@ -44,12 +44,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/endringsmelding-service/src/main/resources/application.yml b/apps/endringsmelding-service/src/main/resources/application.yml index d7cdb8c63fc..d552f471d1e 100644 --- a/apps/endringsmelding-service/src/main/resources/application.yml +++ b/apps/endringsmelding-service/src/main/resources/application.yml @@ -45,12 +45,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true health: elasticsearch: enabled: false diff --git a/apps/faste-data-frontend/src/main/resources/application.yml b/apps/faste-data-frontend/src/main/resources/application.yml index 47faf21eb99..6d226e085c8 100644 --- a/apps/faste-data-frontend/src/main/resources/application.yml +++ b/apps/faste-data-frontend/src/main/resources/application.yml @@ -62,12 +62,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/generer-arbeidsforhold-populasjon-service/src/main/resources/application.yml b/apps/generer-arbeidsforhold-populasjon-service/src/main/resources/application.yml index 3c4d2f1263e..716b962f019 100644 --- a/apps/generer-arbeidsforhold-populasjon-service/src/main/resources/application.yml +++ b/apps/generer-arbeidsforhold-populasjon-service/src/main/resources/application.yml @@ -48,12 +48,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/generer-navn-service/src/main/resources/application.yml b/apps/generer-navn-service/src/main/resources/application.yml index 5777e19d691..f470d5ceed7 100644 --- a/apps/generer-navn-service/src/main/resources/application.yml +++ b/apps/generer-navn-service/src/main/resources/application.yml @@ -29,12 +29,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/generer-organisasjon-populasjon-service/src/main/resources/application.yml b/apps/generer-organisasjon-populasjon-service/src/main/resources/application.yml index 241b6cc21ef..c26902af9b9 100644 --- a/apps/generer-organisasjon-populasjon-service/src/main/resources/application.yml +++ b/apps/generer-organisasjon-populasjon-service/src/main/resources/application.yml @@ -41,12 +41,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/generer-synt-amelding-service/src/main/resources/application.yml b/apps/generer-synt-amelding-service/src/main/resources/application.yml index e50b841c107..df0c280972e 100644 --- a/apps/generer-synt-amelding-service/src/main/resources/application.yml +++ b/apps/generer-synt-amelding-service/src/main/resources/application.yml @@ -38,12 +38,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/helsepersonell-service/src/main/resources/application.yml b/apps/helsepersonell-service/src/main/resources/application.yml index 43f90ed6aca..da7af8a8eee 100644 --- a/apps/helsepersonell-service/src/main/resources/application.yml +++ b/apps/helsepersonell-service/src/main/resources/application.yml @@ -29,12 +29,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/inntektsmelding-generator-service/src/main/resources/application.yml b/apps/inntektsmelding-generator-service/src/main/resources/application.yml index 593df4d3e10..edb4821e98f 100644 --- a/apps/inntektsmelding-generator-service/src/main/resources/application.yml +++ b/apps/inntektsmelding-generator-service/src/main/resources/application.yml @@ -24,12 +24,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/inntektsmelding-service/src/main/resources/application.yml b/apps/inntektsmelding-service/src/main/resources/application.yml index dc654d232cf..3e93ae1704b 100644 --- a/apps/inntektsmelding-service/src/main/resources/application.yml +++ b/apps/inntektsmelding-service/src/main/resources/application.yml @@ -40,12 +40,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/jenkins-batch-status-service/src/main/resources/application.yml b/apps/jenkins-batch-status-service/src/main/resources/application.yml index 12bda26837d..38b6be1140a 100644 --- a/apps/jenkins-batch-status-service/src/main/resources/application.yml +++ b/apps/jenkins-batch-status-service/src/main/resources/application.yml @@ -41,12 +41,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/joark-dokument-service/src/main/resources/application.yml b/apps/joark-dokument-service/src/main/resources/application.yml index 50215c47d64..76d160784c6 100644 --- a/apps/joark-dokument-service/src/main/resources/application.yml +++ b/apps/joark-dokument-service/src/main/resources/application.yml @@ -34,12 +34,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/kodeverk-service/src/main/resources/application.yml b/apps/kodeverk-service/src/main/resources/application.yml index 824b314a535..7f880895661 100644 --- a/apps/kodeverk-service/src/main/resources/application.yml +++ b/apps/kodeverk-service/src/main/resources/application.yml @@ -22,12 +22,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/levende-arbeidsforhold-ansettelse/src/main/resources/application.yml b/apps/levende-arbeidsforhold-ansettelse/src/main/resources/application.yml index 29a6a0e10d4..9e676dc80e1 100644 --- a/apps/levende-arbeidsforhold-ansettelse/src/main/resources/application.yml +++ b/apps/levende-arbeidsforhold-ansettelse/src/main/resources/application.yml @@ -28,13 +28,15 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - health.show-details: always - heapdump.enabled: true - prometheus.enabled: true + health: + show-details: always + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/levende-arbeidsforhold-scheduler/src/main/resources/application.yml b/apps/levende-arbeidsforhold-scheduler/src/main/resources/application.yml index e1281b264c9..0ade711cee5 100644 --- a/apps/levende-arbeidsforhold-scheduler/src/main/resources/application.yml +++ b/apps/levende-arbeidsforhold-scheduler/src/main/resources/application.yml @@ -25,12 +25,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/levende-arbeidsforhold-service/src/main/resources/application.yml b/apps/levende-arbeidsforhold-service/src/main/resources/application.yml index bd6d7946969..9366022b2f8 100644 --- a/apps/levende-arbeidsforhold-service/src/main/resources/application.yml +++ b/apps/levende-arbeidsforhold-service/src/main/resources/application.yml @@ -28,12 +28,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/miljoer-service/src/main/resources/application.yml b/apps/miljoer-service/src/main/resources/application.yml index 41fae00bc00..47f1bcc1780 100644 --- a/apps/miljoer-service/src/main/resources/application.yml +++ b/apps/miljoer-service/src/main/resources/application.yml @@ -31,12 +31,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/oppsummeringsdokument-service/src/main/resources/application.yml b/apps/oppsummeringsdokument-service/src/main/resources/application.yml index a3800a156d5..780c6e746f0 100644 --- a/apps/oppsummeringsdokument-service/src/main/resources/application.yml +++ b/apps/oppsummeringsdokument-service/src/main/resources/application.yml @@ -30,12 +30,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/organisasjon-bestilling-service/src/main/resources/application.yml b/apps/organisasjon-bestilling-service/src/main/resources/application.yml index 5d10b138922..e8d0b3a450e 100644 --- a/apps/organisasjon-bestilling-service/src/main/resources/application.yml +++ b/apps/organisasjon-bestilling-service/src/main/resources/application.yml @@ -33,12 +33,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/organisasjon-faste-data-service/src/main/resources/application.yml b/apps/organisasjon-faste-data-service/src/main/resources/application.yml index b35c5e82706..f0e7149af43 100644 --- a/apps/organisasjon-faste-data-service/src/main/resources/application.yml +++ b/apps/organisasjon-faste-data-service/src/main/resources/application.yml @@ -38,12 +38,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/organisasjon-forvalter/src/main/resources/application.yml b/apps/organisasjon-forvalter/src/main/resources/application.yml index 095c0107efa..8e48224db96 100644 --- a/apps/organisasjon-forvalter/src/main/resources/application.yml +++ b/apps/organisasjon-forvalter/src/main/resources/application.yml @@ -63,12 +63,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/organisasjon-mottak-service/src/main/resources/application.yml b/apps/organisasjon-mottak-service/src/main/resources/application.yml index f5454299df6..77d033f0b1c 100644 --- a/apps/organisasjon-mottak-service/src/main/resources/application.yml +++ b/apps/organisasjon-mottak-service/src/main/resources/application.yml @@ -49,12 +49,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/organisasjon-service/src/main/resources/application.yml b/apps/organisasjon-service/src/main/resources/application.yml index 9f897c11c45..64de1fe9017 100644 --- a/apps/organisasjon-service/src/main/resources/application.yml +++ b/apps/organisasjon-service/src/main/resources/application.yml @@ -34,12 +34,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/organisasjon-tilgang-service/Dockerfile b/apps/organisasjon-tilgang-service/Dockerfile deleted file mode 100644 index 5adc5c61063..00000000000 --- a/apps/organisasjon-tilgang-service/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -FROM ghcr.io/navikt/baseimages/temurin:21 -LABEL maintainer="Team Dolly" - -ADD build/libs/app.jar /app/app.jar - -ENV JAVA_OPTS="--add-opens java.base/java.lang=ALL-UNNAMED" - -EXPOSE 8080 \ No newline at end of file diff --git a/apps/organisasjon-tilgang-service/README.md b/apps/organisasjon-tilgang-service/README.md deleted file mode 100644 index 7e9442ea085..00000000000 --- a/apps/organisasjon-tilgang-service/README.md +++ /dev/null @@ -1,6 +0,0 @@ -## organisajon-tilgang-service -Service som godkjenner tilganger for en spesifisert organisasjoner mot Dolly ved bruk av bankid. - -## Lokal kjøring -* [Generelt.](../../docs/local_general.md) -* [Secret Manager.](../../docs/local_secretmanager.md) diff --git a/apps/organisasjon-tilgang-service/build.gradle b/apps/organisasjon-tilgang-service/build.gradle deleted file mode 100644 index 7ec15dac6dc..00000000000 --- a/apps/organisasjon-tilgang-service/build.gradle +++ /dev/null @@ -1,32 +0,0 @@ -plugins { - id "dolly-apps" -} - -sonarqube { - properties { - property "sonar.projectKey", "testnav-organisasjon-tilgang-service" - property "sonar.projectName", "testnav-organisasjon-tilgang-service" - } -} - -dependencies { - implementation "no.nav.testnav.libs:reactive-core" - implementation "no.nav.testnav.libs:reactive-security" - - implementation "org.springframework.boot:spring-boot-starter-oauth2-resource-server" - - implementation "org.springframework.boot:spring-boot-starter-data-r2dbc" - runtimeOnly "org.postgresql:postgresql" - implementation "io.r2dbc:r2dbc-h2" - implementation "org.postgresql:r2dbc-postgresql" - implementation "org.flywaydb:flyway-core" - implementation "org.flywaydb:flyway-database-postgresql" - - implementation "ma.glasnost.orika:orika-core:$versions.orika" - - implementation "org.springdoc:springdoc-openapi-starter-webflux-ui:$versions.springdoc" - implementation "io.swagger.core.v3:swagger-annotations-jakarta:$versions.swagger" - - testImplementation "org.springframework.cloud:spring-cloud-contract-wiremock" -} - diff --git a/apps/organisasjon-tilgang-service/config.yml b/apps/organisasjon-tilgang-service/config.yml deleted file mode 100644 index 497d5fdc323..00000000000 --- a/apps/organisasjon-tilgang-service/config.yml +++ /dev/null @@ -1,79 +0,0 @@ -apiVersion: "nais.io/v1alpha1" -kind: "Application" -metadata: - name: testnav-organisasjon-tilgang-service - namespace: dolly - labels: - team: dolly -spec: - tokenx: - enabled: true - image: "{{image}}" - port: 8080 - webproxy: true - azure: - application: - enabled: true - tenant: nav.no - claims: - groups: - - id: 9c7efec1-1599-4216-a67e-6fd53a6a951c - accessPolicy: - inbound: - rules: - - application: dolly-frontend - - application: dolly-frontend-dev - - application: dolly-frontend-dev-unstable - - application: dolly-idporten - - application: team-dolly-lokal-app - - application: testnav-oversikt-frontend - outbound: - external: - - host: altinn.no - - host: maskinporten.no - liveness: - path: /internal/isAlive - initialDelay: 10 - periodSeconds: 5 - failureThreshold: 500 - observability: - logging: - destinations: - - id: elastic - autoInstrumentation: - enabled: true - runtime: java - readiness: - path: /internal/isReady - initialDelay: 10 - periodSeconds: 5 - failureThreshold: 500 - prometheus: - enabled: true - path: /internal/metrics - envFrom: - - secret: altinn-prod - - secret: google-sql-testnav-organisasjon-tilgang-service - - secret: maskinporten-dolly-prod - replicas: - min: 1 - max: 1 - resources: - requests: - cpu: 200m - memory: 1024Mi - limits: - memory: 2048Mi - ingresses: - - "https://testnav-organisasjon-tilgang-service.intern.dev.nav.no" - env: - - name: SPRING_PROFILES_ACTIVE - value: prod - gcp: - sqlInstances: - - type: POSTGRES_15 - tier: db-custom-1-3840 - name: testnav-organisasjon-tilganger - databases: - - name: testnav-organisasjon-tilganger - autoBackupHour: 2 \ No newline at end of file diff --git a/apps/organisasjon-tilgang-service/gradle/wrapper/gradle-wrapper.jar b/apps/organisasjon-tilgang-service/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 7454180f2ae..00000000000 Binary files a/apps/organisasjon-tilgang-service/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/apps/organisasjon-tilgang-service/gradle/wrapper/gradle-wrapper.properties b/apps/organisasjon-tilgang-service/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 48c0a02ca41..00000000000 --- a/apps/organisasjon-tilgang-service/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/apps/organisasjon-tilgang-service/gradlew b/apps/organisasjon-tilgang-service/gradlew deleted file mode 100755 index 3da45c161b0..00000000000 --- a/apps/organisasjon-tilgang-service/gradlew +++ /dev/null @@ -1,234 +0,0 @@ -#!/bin/sh - -# -# Copyright ? 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions ?$var?, ?${var}?, ?${var:-default}?, ?${var+SET}?, -# ?${var#prefix}?, ?${var%suffix}?, and ?$( cmd )?; -# * compound commands having a testable exit status, especially ?case?; -# * various built-in commands including ?command?, ?set?, and ?ulimit?. -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" -APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/apps/organisasjon-tilgang-service/gradlew.bat b/apps/organisasjon-tilgang-service/gradlew.bat deleted file mode 100644 index ac1b06f9382..00000000000 --- a/apps/organisasjon-tilgang-service/gradlew.bat +++ /dev/null @@ -1,89 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/apps/organisasjon-tilgang-service/gradlewUpdate.sh b/apps/organisasjon-tilgang-service/gradlewUpdate.sh deleted file mode 100755 index e5ee6361152..00000000000 --- a/apps/organisasjon-tilgang-service/gradlewUpdate.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -gradle wrapper \ No newline at end of file diff --git a/apps/organisasjon-tilgang-service/settings.gradle b/apps/organisasjon-tilgang-service/settings.gradle deleted file mode 100644 index 29ccda116b3..00000000000 --- a/apps/organisasjon-tilgang-service/settings.gradle +++ /dev/null @@ -1,17 +0,0 @@ -plugins { - id "com.gradle.develocity" version "3.17.4" -} - -rootProject.name = 'organisasjon-tilgang-service' - -includeBuild "../../plugins/java" - -includeBuild '../../libs/reactive-core' -includeBuild '../../libs/reactive-security' - -develocity { - buildScan { - termsOfUseUrl = "https://gradle.com/terms-of-service" - termsOfUseAgree = "yes" - } -} \ No newline at end of file diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/OrganisasjonTilgangServiceApplicationStarter.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/OrganisasjonTilgangServiceApplicationStarter.java deleted file mode 100644 index 5caffe6eb6f..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/OrganisasjonTilgangServiceApplicationStarter.java +++ /dev/null @@ -1,21 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice; - -import no.nav.testnav.libs.reactivecore.config.CoreConfig; -import no.nav.testnav.libs.reactivesecurity.config.SecureOAuth2ServerToServerConfiguration; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Import; -import org.springframework.web.reactive.config.EnableWebFlux; - -@Import({ - CoreConfig.class, - SecureOAuth2ServerToServerConfiguration.class -}) -@EnableWebFlux -@SpringBootApplication -public class OrganisasjonTilgangServiceApplicationStarter { - - public static void main(String[] args) { - SpringApplication.run(OrganisasjonTilgangServiceApplicationStarter.class, args); - } -} diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/config/AltinnConfig.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/config/AltinnConfig.java deleted file mode 100644 index 47ed78ed69c..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/config/AltinnConfig.java +++ /dev/null @@ -1,24 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.config; - -import lombok.Getter; -import lombok.NoArgsConstructor; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Configuration; - -@Getter -@Configuration -@NoArgsConstructor -public class AltinnConfig { - - @Value("${altinn.api.url}") - private String url; - - @Value("${altinn.api.key}") - private String apiKey; - - @Value("${altinn.service.code}") - private String code; - - @Value("${altinn.service.edition}") - private String edition; -} diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/config/JacksonConfig.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/config/JacksonConfig.java deleted file mode 100644 index 7f0f4f61882..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/config/JacksonConfig.java +++ /dev/null @@ -1,27 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.config; - -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.RequiredArgsConstructor; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.codec.ServerCodecConfigurer; -import org.springframework.http.codec.json.Jackson2JsonDecoder; -import org.springframework.http.codec.json.Jackson2JsonEncoder; -import org.springframework.web.reactive.config.WebFluxConfigurer; - -@Configuration -@RequiredArgsConstructor -public class JacksonConfig implements WebFluxConfigurer { - - private final ObjectMapper objectMapper; - - @Override - public void configureHttpMessageCodecs(ServerCodecConfigurer configurer) { - configurer.defaultCodecs().jackson2JsonEncoder( - new Jackson2JsonEncoder(objectMapper) - ); - - configurer.defaultCodecs().jackson2JsonDecoder( - new Jackson2JsonDecoder(objectMapper) - ); - } -} \ No newline at end of file diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/config/MaskinportenConfig.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/config/MaskinportenConfig.java deleted file mode 100644 index 3ac7906824b..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/config/MaskinportenConfig.java +++ /dev/null @@ -1,24 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.config; - -import lombok.Getter; -import lombok.NoArgsConstructor; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Configuration; - -@Getter -@Configuration -@NoArgsConstructor -public class MaskinportenConfig { - - @Value("${MASKINPORTEN_CLIENT_ID}") - private String clientId; - - @Value("${MASKINPORTEN_CLIENT_JWK}") - private String jwkPrivate; - - @Value("${MASKINPORTEN_SCOPES}") - private String scope; - - @Value("${MASKINPORTEN_WELL_KNOWN_URL}") - private String wellKnownUrl; -} diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/config/OpenApiConfig.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/config/OpenApiConfig.java deleted file mode 100644 index 9fbc6385f89..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/config/OpenApiConfig.java +++ /dev/null @@ -1,49 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.config; - -import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Contact; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.info.License; -import io.swagger.v3.oas.models.security.SecurityRequirement; -import io.swagger.v3.oas.models.security.SecurityScheme; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import java.util.Arrays; - -import no.nav.testnav.libs.reactivecore.config.ApplicationProperties; - - -@Configuration -public class OpenApiConfig { - - @Bean - public OpenAPI openApi(ApplicationProperties applicationProperties) { - return new OpenAPI() - .components(new Components().addSecuritySchemes("bearer-jwt", new SecurityScheme() - .type(SecurityScheme.Type.HTTP) - .scheme("bearer") - .bearerFormat("JWT") - .in(SecurityScheme.In.HEADER) - .name("Authorization") - )) - .addSecurityItem( - new SecurityRequirement().addList("bearer-jwt", Arrays.asList("read", "write"))) - .info(new Info() - .title(applicationProperties.getName()) - .version(applicationProperties.getVersion()) - .description(applicationProperties.getDescription()) - .termsOfService("https://nav.no") - .contact(new Contact() - .url("https://nav-it.slack.com/archives/CA3P9NGA2") - .email("dolly@nav.no") - .name("Team Dolly") - ) - .license(new License() - .name("MIT License") - .url("https://opensource.org/licenses/MIT") - ) - ); - } -} \ No newline at end of file diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/config/R2DBCConfiguration.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/config/R2DBCConfiguration.java deleted file mode 100644 index 39960225f15..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/config/R2DBCConfiguration.java +++ /dev/null @@ -1,39 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.config; - -import io.r2dbc.h2.H2ConnectionFactory; -import io.r2dbc.spi.ConnectionFactory; -import lombok.RequiredArgsConstructor; -import org.flywaydb.core.Flyway; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.core.env.Environment; -import org.springframework.data.r2dbc.config.AbstractR2dbcConfiguration; -import org.springframework.data.r2dbc.config.EnableR2dbcAuditing; -import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories; - -@Configuration -@EnableR2dbcAuditing -@EnableR2dbcRepositories -@RequiredArgsConstructor -class R2DBCConfiguration extends AbstractR2dbcConfiguration { - - private final Environment env; - - @Bean(initMethod = "migrate") - public Flyway flyway() { - return new Flyway(Flyway.configure() - .baselineOnMigrate(true) - .dataSource( - env.getRequiredProperty("spring.flyway.url"), - env.getRequiredProperty("spring.flyway.username"), - env.getRequiredProperty("spring.flyway.password")) - ); - } - - @Bean - @Profile("local") - public ConnectionFactory connectionFactory() { - return H2ConnectionFactory.inMemory("testdb"); - } -} \ No newline at end of file diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/config/SecurityConfig.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/config/SecurityConfig.java deleted file mode 100644 index 79595cbdc7f..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/config/SecurityConfig.java +++ /dev/null @@ -1,40 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.config; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import no.nav.testnav.libs.reactivesecurity.manager.JwtReactiveAuthenticationManager; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.method.configuration.EnableReactiveMethodSecurity; -import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity; -import org.springframework.security.config.web.server.ServerHttpSecurity; -import org.springframework.security.web.server.SecurityWebFilterChain; - - -@Slf4j -@Configuration -@EnableWebFluxSecurity -@EnableReactiveMethodSecurity -@RequiredArgsConstructor -public class SecurityConfig { - - private final JwtReactiveAuthenticationManager jwtReactiveAuthenticationManager; - - @Bean - public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity httpSecurity) { - return httpSecurity - .csrf(ServerHttpSecurity.CsrfSpec::disable) - .authorizeExchange(authorizeConfig -> authorizeConfig.pathMatchers( - "/internal/**", - "/webjars/**", - "/swagger-resources/**", - "/v3/api-docs/**", - "/swagger-ui/**", - "/swagger", - "/error", - "/swagger-ui.html" - ).permitAll().anyExchange().authenticated()) - .oauth2ResourceServer(oauth2RSConfig -> oauth2RSConfig.jwt(jwtSpec -> jwtSpec.authenticationManager(jwtReactiveAuthenticationManager))).build(); - } - -} diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/altinn/v1/AltinnConsumer.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/altinn/v1/AltinnConsumer.java deleted file mode 100644 index 7f80d72c961..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/altinn/v1/AltinnConsumer.java +++ /dev/null @@ -1,151 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.consumer.altinn.v1; - -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.extern.slf4j.Slf4j; -import no.nav.testnav.apps.organisasjontilgangservice.config.AltinnConfig; -import no.nav.testnav.apps.organisasjontilgangservice.consumer.altinn.v1.command.CreateOrganisasjonAccessCommand; -import no.nav.testnav.apps.organisasjontilgangservice.consumer.altinn.v1.command.DeleteOrganisasjonAccessCommand; -import no.nav.testnav.apps.organisasjontilgangservice.consumer.altinn.v1.command.GetOrganisasjonCommand; -import no.nav.testnav.apps.organisasjontilgangservice.consumer.altinn.v1.command.GetRightsCommand; -import no.nav.testnav.apps.organisasjontilgangservice.consumer.altinn.v1.dto.DeleteStatus; -import no.nav.testnav.apps.organisasjontilgangservice.consumer.altinn.v1.dto.RightDTO; -import no.nav.testnav.apps.organisasjontilgangservice.consumer.maskinporten.v1.MaskinportenConsumer; -import no.nav.testnav.apps.organisasjontilgangservice.domain.Organisasjon; -import org.springframework.http.codec.json.Jackson2JsonDecoder; -import org.springframework.http.codec.json.Jackson2JsonEncoder; -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.client.ExchangeFilterFunction; -import org.springframework.web.reactive.function.client.WebClient; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.time.LocalDateTime; - -@Slf4j -@Component -public class AltinnConsumer { - - private final WebClient webClient; - private final AltinnConfig altinnConfig; - private final MaskinportenConsumer maskinportenConsumer; - - public AltinnConsumer( - AltinnConfig altinnConfig, - MaskinportenConsumer maskinportenConsumer, - ObjectMapper objectMapper, - WebClient.Builder webClientBuilder) { - - this.altinnConfig = altinnConfig; - this.maskinportenConsumer = maskinportenConsumer; - this.webClient = webClientBuilder - .baseUrl(altinnConfig.getUrl()) - .codecs(clientDefaultCodecsConfigurer -> { - clientDefaultCodecsConfigurer - .defaultCodecs() - .jackson2JsonEncoder(new Jackson2JsonEncoder(objectMapper)); - clientDefaultCodecsConfigurer - .defaultCodecs() - .jackson2JsonDecoder(new Jackson2JsonDecoder(objectMapper)); - }) - .filters(exchangeFilterFunctions -> - exchangeFilterFunctions.add(logRequest())) - .build(); - } - - private ExchangeFilterFunction logRequest() { - - return (clientRequest, next) -> { - var buffer = new StringBuilder(250) - .append("Request: ") - .append(clientRequest.method()) - .append(' ') - .append(clientRequest.url()) - .append(System.lineSeparator()); - - clientRequest.headers() - .forEach((name, values) -> values - .forEach(value -> buffer.append('\t') - .append(name) - .append('=') - .append(value.contains("Bearer ") ? "Bearer token" : value) - .append(System.lineSeparator()))); - log.trace(buffer.substring(0, buffer.length() - 1)); - return next.exchange(clientRequest); - }; - } - - - public Flux delete(String organiasjonsnummer) { - return getRights() - .filter(value -> value.reportee().equals(organiasjonsnummer)) - .flatMap(value -> maskinportenConsumer - .getAccessToken() - .flatMap(accessToken -> new DeleteOrganisasjonAccessCommand( - webClient, - accessToken.value(), - altinnConfig.getApiKey(), - value.id() - ).call()) - ); - } - - public Mono create(String organiasjonsnummer, LocalDateTime gyldigTil) { - - var readRight = new RightDTO( - null, - organiasjonsnummer, - altinnConfig.getCode(), - altinnConfig.getEdition(), - "Read", - gyldigTil - ); - return maskinportenConsumer - .getAccessToken() - .flatMap(accessToken -> new CreateOrganisasjonAccessCommand( - webClient, - accessToken.value(), - altinnConfig.getApiKey(), - readRight - ).call() - ).flatMap(right -> maskinportenConsumer - .getAccessToken() - .flatMap(accessToken -> new GetOrganisasjonCommand( - webClient, - accessToken.value(), - right.reportee(), - altinnConfig.getApiKey() - ).call()) - .map(value -> new Organisasjon(value, right)) - ); - } - - public Flux getOrganisasjoner() { - - return getRights() - .map(right -> maskinportenConsumer - .getAccessToken() - .flatMap(accessToken -> new GetOrganisasjonCommand( - webClient, - accessToken.value(), - right.reportee(), - altinnConfig.getApiKey() - ).call()) - .map(value -> new Organisasjon(value, right)) - ).collectList() - .flatMapMany(Flux::concat); - } - - private Flux getRights() { - return maskinportenConsumer - .getAccessToken() - .flatMapMany(accessToken -> new GetRightsCommand( - webClient, - accessToken.value(), - altinnConfig.getCode(), - altinnConfig.getEdition(), - altinnConfig.getApiKey() - ).call() - ); - } - -} diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/altinn/v1/command/CreateOrganisasjonAccessCommand.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/altinn/v1/command/CreateOrganisasjonAccessCommand.java deleted file mode 100644 index fe0fdbb7318..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/altinn/v1/command/CreateOrganisasjonAccessCommand.java +++ /dev/null @@ -1,47 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.consumer.altinn.v1.command; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import no.nav.testnav.apps.organisasjontilgangservice.consumer.altinn.v1.dto.RightDTO; -import org.springframework.http.HttpHeaders; -import org.springframework.web.reactive.function.BodyInserters; -import org.springframework.web.reactive.function.client.WebClient; -import org.springframework.web.reactive.function.client.WebClientResponseException; -import reactor.core.publisher.Mono; - -import java.util.concurrent.Callable; - -@Slf4j -@RequiredArgsConstructor -public class CreateOrganisasjonAccessCommand implements Callable> { - private final WebClient webClient; - private final String token; - private final String apiKey; - private final RightDTO dto; - - - @Override - public Mono call() { - - return webClient - .post() - .uri(builder -> builder.path("/api/serviceowner/Srr") - .build() - ) - .body(BodyInserters.fromPublisher(Mono.just(new RightDTO[]{dto}), RightDTO[].class)) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + token) - .header("ApiKey", apiKey) - .header(HttpHeaders.CONTENT_TYPE, "application/hal+json") - .retrieve() - .bodyToMono(RightDTO[].class) - .map(list -> list[0]) - .doOnError( - WebClientResponseException.class::isInstance, - throwable -> log.error( - "Feil ved opprettelse av organisasjon tilgang i Altinn. {}", - ((WebClientResponseException) throwable).getResponseBodyAsString() - ) - ); - } - -} diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/altinn/v1/command/DeleteOrganisasjonAccessCommand.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/altinn/v1/command/DeleteOrganisasjonAccessCommand.java deleted file mode 100644 index 01085ca32b8..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/altinn/v1/command/DeleteOrganisasjonAccessCommand.java +++ /dev/null @@ -1,46 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.consumer.altinn.v1.command; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import no.nav.testnav.apps.organisasjontilgangservice.consumer.altinn.v1.dto.DeleteStatus; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; -import org.springframework.web.reactive.function.client.WebClient; -import org.springframework.web.reactive.function.client.WebClientResponseException; -import reactor.core.publisher.Mono; - -import java.util.concurrent.Callable; - -@Slf4j -@RequiredArgsConstructor -public class DeleteOrganisasjonAccessCommand implements Callable> { - private final WebClient webClient; - private final String token; - private final String apiKey; - private final Integer id; - - - @Override - public Mono call() { - - return webClient - .delete() - .uri(builder -> builder.path("/api/serviceowner/Srr/{id}") - .build(id) - ) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + token) - .header("ApiKey", apiKey) - .header(HttpHeaders.CONTENT_TYPE, "application/hal+json") - .retrieve() - .toBodilessEntity() - .map(resultat -> DeleteStatus.builder() - .status(HttpStatus.valueOf(resultat.getStatusCode().value())) - .build()) - .doOnSuccess(value -> log.info("Organiasjon tilgang {} slettet.", id)) - .doOnError( - WebClientResponseException.class::isInstance, - throwable -> log.error( - "Feil ved henting av rettigheter i Altinn. {}", - ((WebClientResponseException) throwable).getResponseBodyAsString())); - } -} diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/altinn/v1/command/GetOrganisasjonCommand.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/altinn/v1/command/GetOrganisasjonCommand.java deleted file mode 100644 index 5c131c8fd07..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/altinn/v1/command/GetOrganisasjonCommand.java +++ /dev/null @@ -1,38 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.consumer.altinn.v1.command; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import no.nav.testnav.apps.organisasjontilgangservice.consumer.altinn.v1.dto.OrganisasjonDTO; -import org.springframework.http.HttpHeaders; -import org.springframework.web.reactive.function.client.WebClient; -import org.springframework.web.reactive.function.client.WebClientResponseException; -import reactor.core.publisher.Mono; - -import java.util.concurrent.Callable; - -@Slf4j -@RequiredArgsConstructor -public class GetOrganisasjonCommand implements Callable> { - private final WebClient webClient; - private final String token; - private final String organisajonsnummer; - private final String apiKey; - - @Override - public Mono call() { - - return webClient - .get() - .uri(builder -> builder.path("api/serviceowner/organizations/{organisajonsnummer}").build(organisajonsnummer) - ) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + token) - .header("ApiKey", apiKey) - .retrieve() - .bodyToMono(OrganisasjonDTO.class) - .doOnError( - WebClientResponseException.class::isInstance, - throwable -> log.error( - "Feil ved henting av rettigheter i Altinn. {}", - ((WebClientResponseException) throwable).getResponseBodyAsString())); - } -} diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/altinn/v1/command/GetRightsCommand.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/altinn/v1/command/GetRightsCommand.java deleted file mode 100644 index 19911a178df..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/altinn/v1/command/GetRightsCommand.java +++ /dev/null @@ -1,43 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.consumer.altinn.v1.command; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import no.nav.testnav.apps.organisasjontilgangservice.consumer.altinn.v1.dto.RightDTO; -import org.springframework.http.HttpHeaders; -import org.springframework.web.reactive.function.client.WebClient; -import org.springframework.web.reactive.function.client.WebClientResponseException; -import reactor.core.publisher.Flux; - -import java.util.concurrent.Callable; - -@Slf4j -@RequiredArgsConstructor -public class GetRightsCommand implements Callable> { - private final WebClient webClient; - private final String token; - private final String serviceCode; - private final String serviceEdition; - private final String apiKey; - - @Override - public Flux call() { - - return webClient - .get() - .uri(builder -> builder.path("/api/serviceowner/Srr") - .queryParam("serviceCode", serviceCode) - .queryParam("serviceEditionCode", serviceEdition) - .build() - ) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + token) - .header("ApiKey", apiKey) - .retrieve() - .bodyToFlux(RightDTO.class) - .doOnError( - WebClientResponseException.class::isInstance, - throwable -> log.error( - "Feil ved henting av rettigheter i Altinn. {}", - ((WebClientResponseException) throwable).getResponseBodyAsString())) - ; - } -} \ No newline at end of file diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/altinn/v1/dto/DeleteStatus.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/altinn/v1/dto/DeleteStatus.java deleted file mode 100644 index 388453047e4..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/altinn/v1/dto/DeleteStatus.java +++ /dev/null @@ -1,16 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.consumer.altinn.v1.dto; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.springframework.http.HttpStatus; - -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class DeleteStatus { - - private HttpStatus status; -} diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/altinn/v1/dto/OrganisasjonDTO.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/altinn/v1/dto/OrganisasjonDTO.java deleted file mode 100644 index 09ce3a8aadb..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/altinn/v1/dto/OrganisasjonDTO.java +++ /dev/null @@ -1,8 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.consumer.altinn.v1.dto; - -public record OrganisasjonDTO( - String Name, - String Type, - String OrganizationNumber -) { -} \ No newline at end of file diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/altinn/v1/dto/RightDTO.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/altinn/v1/dto/RightDTO.java deleted file mode 100644 index 32c6889128e..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/altinn/v1/dto/RightDTO.java +++ /dev/null @@ -1,21 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.consumer.altinn.v1.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.time.LocalDateTime; - -public record RightDTO( - @JsonProperty("Id") - Integer id, - @JsonProperty("Reportee") - String reportee, - @JsonProperty("ServiceCode") - String serviceCode, - @JsonProperty("ServiceEditionCode") - String serviceEditionCode, - @JsonProperty("Right") - String right, - @JsonProperty("ValidTo") - LocalDateTime validTo -) { -} diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/maskinporten/v1/MaskinportenConsumer.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/maskinporten/v1/MaskinportenConsumer.java deleted file mode 100644 index 9e6c4ab55e4..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/maskinporten/v1/MaskinportenConsumer.java +++ /dev/null @@ -1,94 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.consumer.maskinporten.v1; - -import com.nimbusds.jose.JOSEException; -import com.nimbusds.jose.JOSEObjectType; -import com.nimbusds.jose.JWSAlgorithm; -import com.nimbusds.jose.JWSHeader; -import com.nimbusds.jose.JWSSigner; -import com.nimbusds.jose.crypto.RSASSASigner; -import com.nimbusds.jose.jwk.RSAKey; -import com.nimbusds.jwt.JWTClaimsSet; -import com.nimbusds.jwt.SignedJWT; -import lombok.SneakyThrows; -import lombok.extern.slf4j.Slf4j; -import no.nav.testnav.apps.organisasjontilgangservice.config.MaskinportenConfig; -import no.nav.testnav.apps.organisasjontilgangservice.consumer.maskinporten.v1.command.GetAccessTokenCommand; -import no.nav.testnav.apps.organisasjontilgangservice.consumer.maskinporten.v1.command.GetWellKnownCommand; -import no.nav.testnav.apps.organisasjontilgangservice.consumer.maskinporten.v1.dto.AccessToken; -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.client.WebClient; -import reactor.core.publisher.Mono; - -import java.time.Duration; -import java.time.Instant; -import java.util.Date; -import java.util.UUID; -import java.util.function.Function; - -@Slf4j -@Component -public class MaskinportenConsumer { - - private final WebClient webClient; - private final MaskinportenConfig maskinportenConfig; - private final Mono accessToken; - - public MaskinportenConsumer(MaskinportenConfig maskinportenConfig, WebClient.Builder webClientBuilder) { - - this.webClient = webClientBuilder - .build(); - - this.maskinportenConfig = maskinportenConfig; - var wellKnownMono = cache( - new GetWellKnownCommand(webClient, maskinportenConfig).call(), - value -> Duration.ofDays(1) - ); - this.accessToken = cache( - wellKnownMono.flatMap(wellKnown -> new GetAccessTokenCommand(webClient, wellKnown, createJwtClaims(wellKnown.issuer())).call()), - value -> Duration.ofSeconds(value.expiresIn() - 10L) - ); - } - - public Mono getAccessToken() { - return accessToken.map(no.nav.testnav.apps.organisasjontilgangservice.domain.AccessToken::new); - } - - @SneakyThrows - private String createJwtClaims(String audience) { - Instant now = Instant.now(); - var rsaKey = RSAKey.parse(maskinportenConfig.getJwkPrivate()); - return createSignedJWT(rsaKey, - new JWTClaimsSet.Builder() - .audience(audience) - .claim("scope", maskinportenConfig.getScope()) - .issuer(maskinportenConfig.getClientId()) - .issueTime(Date.from(now)) - .expirationTime(Date.from(now.plusSeconds(119))) - .jwtID(UUID.randomUUID().toString()) - .build()) - .serialize(); - } - - private SignedJWT createSignedJWT(RSAKey rsaJwk, JWTClaimsSet claimsSet) { - try { - JWSHeader.Builder header = new JWSHeader.Builder(JWSAlgorithm.RS256) - .keyID(rsaJwk.getKeyID()) - .type(JOSEObjectType.JWT); - SignedJWT signedJWT = new SignedJWT(header.build(), claimsSet); - JWSSigner signer = new RSASSASigner(rsaJwk.toPrivateKey()); - signedJWT.sign(signer); - return signedJWT; - } catch (JOSEException e) { - throw new RuntimeException(e); - } - } - - private static Mono cache(Mono value, Function ttlForValue) { - return value.cache( - ttlForValue, - throwable -> Duration.ZERO, - () -> Duration.ZERO - ); - } - -} diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/maskinporten/v1/command/GetAccessTokenCommand.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/maskinporten/v1/command/GetAccessTokenCommand.java deleted file mode 100644 index 7902064ab0f..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/maskinporten/v1/command/GetAccessTokenCommand.java +++ /dev/null @@ -1,40 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.consumer.maskinporten.v1.command; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import no.nav.testnav.apps.organisasjontilgangservice.consumer.maskinporten.v1.dto.AccessToken; -import no.nav.testnav.apps.organisasjontilgangservice.consumer.maskinporten.v1.dto.WellKnown; -import org.springframework.web.reactive.function.BodyInserters; -import org.springframework.web.reactive.function.client.WebClient; -import org.springframework.web.reactive.function.client.WebClientResponseException; -import reactor.core.publisher.Mono; - -import java.util.concurrent.Callable; - -@Slf4j -@RequiredArgsConstructor -public class GetAccessTokenCommand implements Callable> { - private final WebClient webClient; - private final WellKnown wellKnown; - private final String assertion; - - @Override - public Mono call() { - return webClient.post() - .uri(wellKnown.tokenEndpoint()) - .body(BodyInserters - .fromFormData("grant_type", wellKnown.grantTypesSupported().get(0)) - .with("assertion", assertion) - ) - .retrieve() - .bodyToMono(AccessToken.class) - .doOnSuccess(value -> log.info("AccessToken hentet fra maskinporten.")) - .doOnError( - WebClientResponseException.class::isInstance, - throwable -> log.error( - "Feil ved henting av AccessToken for maskinporten. \n{}", - ((WebClientResponseException) throwable).getResponseBodyAsString() - ) - ); - } -} diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/maskinporten/v1/command/GetWellKnownCommand.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/maskinporten/v1/command/GetWellKnownCommand.java deleted file mode 100644 index 6a59d75058d..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/maskinporten/v1/command/GetWellKnownCommand.java +++ /dev/null @@ -1,34 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.consumer.maskinporten.v1.command; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import no.nav.testnav.apps.organisasjontilgangservice.config.MaskinportenConfig; -import no.nav.testnav.apps.organisasjontilgangservice.consumer.maskinporten.v1.dto.WellKnown; -import org.springframework.web.reactive.function.client.WebClient; -import org.springframework.web.reactive.function.client.WebClientResponseException; -import reactor.core.publisher.Mono; - -import java.util.concurrent.Callable; - -@Slf4j -@RequiredArgsConstructor -public class GetWellKnownCommand implements Callable> { - private final WebClient webClient; - private final MaskinportenConfig maskinportenConfig; - - @Override - public Mono call() { - return webClient.get() - .uri(maskinportenConfig.getWellKnownUrl()) - .retrieve() - .bodyToMono(WellKnown.class) - .doOnSuccess(value -> log.info("WellKnown hentet for maskinporten.")) - .doOnError( - WebClientResponseException.class::isInstance, - throwable -> log.error( - "Feil ved henting av well known for maskinporten. \n{}", - ((WebClientResponseException) throwable).getResponseBodyAsString() - ) - ); - } -} diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/maskinporten/v1/dto/AccessToken.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/maskinporten/v1/dto/AccessToken.java deleted file mode 100644 index 46516d4d5d4..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/maskinporten/v1/dto/AccessToken.java +++ /dev/null @@ -1,16 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.consumer.maskinporten.v1.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public record AccessToken( - @JsonProperty("access_token") - String accessToken, - @JsonProperty("token_type") - String tokenType, - @JsonProperty("expires_in") - Integer expiresIn, - @JsonProperty("scope") - String scope -) { - -} diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/maskinporten/v1/dto/WellKnown.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/maskinporten/v1/dto/WellKnown.java deleted file mode 100644 index 7b051451225..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/consumer/maskinporten/v1/dto/WellKnown.java +++ /dev/null @@ -1,18 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.consumer.maskinporten.v1.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public record WellKnown( - String issuer, - @JsonProperty("token_endpoint") - String tokenEndpoint, - @JsonProperty("jwks_uri") - String jwksUri, - @JsonProperty("token_endpoint_auth_methods_supported") - List tokenEndpointAuthMethodsSupported, - @JsonProperty("grant_types_supported") - List grantTypesSupported -) { -} diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/controller/OrganisasjonMiljoeConsumer.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/controller/OrganisasjonMiljoeConsumer.java deleted file mode 100644 index 394cf881b8d..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/controller/OrganisasjonMiljoeConsumer.java +++ /dev/null @@ -1,41 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.controller; - -import javassist.NotFoundException; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import no.nav.testnav.apps.organisasjontilgangservice.database.entity.OrganisasjonTilgang; -import no.nav.testnav.apps.organisasjontilgangservice.service.MiljoerOversiktService; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; -import reactor.core.publisher.Mono; - -@Slf4j -@RestController -@RequestMapping("/api/v1/miljoer") -@RequiredArgsConstructor -public class OrganisasjonMiljoeConsumer { - - private final MiljoerOversiktService miljoerOversiktService; - - @GetMapping("/organisasjon/{orgnummer}") - public Mono getOrganisasjon(@RequestParam("orgnummer") String orgnummer) { - - return miljoerOversiktService.getMiljoe(orgnummer); - } - - @ExceptionHandler(NotFoundException.class) - @ResponseStatus(HttpStatus.NOT_FOUND) - public ResponseEntity handleNoSuchElementFoundException( - NotFoundException exception - ) { - return ResponseEntity - .status(HttpStatus.NOT_FOUND) - .body(exception.getMessage()); - } -} diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/controller/OrganisasjonTilgangConsumer.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/controller/OrganisasjonTilgangConsumer.java deleted file mode 100644 index 99d2a044bba..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/controller/OrganisasjonTilgangConsumer.java +++ /dev/null @@ -1,53 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.controller; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import no.nav.testnav.apps.organisasjontilgangservice.controller.request.OrganisasjonAccessRequest; -import no.nav.testnav.apps.organisasjontilgangservice.domain.OrganisasjonResponse; -import no.nav.testnav.apps.organisasjontilgangservice.service.OrganisasjonTilgangService; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -@Slf4j -@RestController -@RequestMapping("/api/v1/organisasjoner") -@RequiredArgsConstructor -public class OrganisasjonTilgangConsumer { - - private final OrganisasjonTilgangService organisasjonTilgangService; - - @GetMapping - public Flux getAll() { - - return organisasjonTilgangService.getAll(); - } - - @PostMapping - public Mono create(@RequestBody OrganisasjonAccessRequest request) { - - return organisasjonTilgangService - .create(request.organisasjonsnummer(), request.gyldigTil(), request.miljoe()); - } - - @DeleteMapping("/{organisasjonsnummer}") - public Flux delete(@PathVariable String organisasjonsnummer) { - - return organisasjonTilgangService.delete(organisasjonsnummer); - } - - @PutMapping - public Mono update(@RequestBody OrganisasjonAccessRequest request) { - - organisasjonTilgangService.delete(request.organisasjonsnummer()).blockFirst(); - return organisasjonTilgangService - .create(request.organisasjonsnummer(), request.gyldigTil(), request.miljoe()); - } -} diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/controller/request/OrganisasjonAccessRequest.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/controller/request/OrganisasjonAccessRequest.java deleted file mode 100644 index 9723304472a..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/controller/request/OrganisasjonAccessRequest.java +++ /dev/null @@ -1,11 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.controller.request; - -import java.time.LocalDateTime; - -public record OrganisasjonAccessRequest( - - String organisasjonsnummer, - LocalDateTime gyldigTil, - String miljoe -) { -} diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/database/entity/OrganisasjonTilgang.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/database/entity/OrganisasjonTilgang.java deleted file mode 100644 index 154d47ef35d..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/database/entity/OrganisasjonTilgang.java +++ /dev/null @@ -1,27 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.database.entity; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.springframework.data.annotation.Id; -import org.springframework.data.relational.core.mapping.Column; -import org.springframework.data.relational.core.mapping.Table; - -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -@Table(name = "ORGANISASJON_TILGANG") -public class OrganisasjonTilgang { - - @Id - @Column("ID") - private Long id; - - @Column("ORGANISAJON_NUMMER") - private String organisasjonNummer; - - @Column("miljoe") - private String miljoe; -} \ No newline at end of file diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/database/repository/OrganisasjonTilgangRepository.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/database/repository/OrganisasjonTilgangRepository.java deleted file mode 100644 index 67f0b1997d0..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/database/repository/OrganisasjonTilgangRepository.java +++ /dev/null @@ -1,16 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.database.repository; - -import no.nav.testnav.apps.organisasjontilgangservice.database.entity.OrganisasjonTilgang; -import org.springframework.data.repository.reactive.ReactiveCrudRepository; -import reactor.core.publisher.Mono; - -public interface OrganisasjonTilgangRepository extends ReactiveCrudRepository { - - Mono existsByOrganisasjonNummer(String orgnummer); - - Mono findByOrganisasjonNummer(String orgnummer); - - Mono save(OrganisasjonTilgang organisasjonTilgang); - - Mono deleteByOrganisasjonNummer(String orgnummer); -} \ No newline at end of file diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/domain/AccessToken.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/domain/AccessToken.java deleted file mode 100644 index 2c3d4fcc960..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/domain/AccessToken.java +++ /dev/null @@ -1,7 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.domain; - -public record AccessToken(String value) { - public AccessToken(no.nav.testnav.apps.organisasjontilgangservice.consumer.maskinporten.v1.dto.AccessToken accessToken) { - this(accessToken.accessToken()); - } -} diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/domain/Organisasjon.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/domain/Organisasjon.java deleted file mode 100644 index faa536716b8..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/domain/Organisasjon.java +++ /dev/null @@ -1,29 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.domain; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import no.nav.testnav.apps.organisasjontilgangservice.consumer.altinn.v1.dto.OrganisasjonDTO; -import no.nav.testnav.apps.organisasjontilgangservice.consumer.altinn.v1.dto.RightDTO; - -import java.time.LocalDateTime; - -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class Organisasjon { - - private String navn; - private String organisasjonsnummer; - private String organisasjonsform; - private LocalDateTime gyldigTil; - - public Organisasjon(OrganisasjonDTO dto, RightDTO rightDTO) { - this.navn = dto.Name(); - this.organisasjonsnummer = dto.OrganizationNumber(); - this.organisasjonsform = dto.Type(); - this.gyldigTil = rightDTO.validTo(); - } -} diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/domain/OrganisasjonResponse.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/domain/OrganisasjonResponse.java deleted file mode 100644 index 7b2d1be2ec9..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/domain/OrganisasjonResponse.java +++ /dev/null @@ -1,21 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.domain; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.time.LocalDateTime; - -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class OrganisasjonResponse { - - private String navn; - private String organisasjonsnummer; - private String organisasjonsform; - private LocalDateTime gyldigTil; - private String miljoe; -} diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/mapper/MapperFacadeConfig.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/mapper/MapperFacadeConfig.java deleted file mode 100644 index 37af6d8419f..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/mapper/MapperFacadeConfig.java +++ /dev/null @@ -1,35 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.mapper; - -import ma.glasnost.orika.CustomConverter; -import ma.glasnost.orika.MapperFacade; -import ma.glasnost.orika.impl.DefaultMapperFactory; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import java.util.List; - -import static java.util.Objects.nonNull; - -@Configuration -public class MapperFacadeConfig { - - @Bean - @SuppressWarnings("java:S3740") - MapperFacade mapperFacade(List mappingStrategies, List customConverters) { - DefaultMapperFactory mapperFactory = new DefaultMapperFactory.Builder().build(); - - if (nonNull(mappingStrategies)) { - for (MappingStrategy mapper : mappingStrategies) { - mapper.register(mapperFactory); - } - } - - if (nonNull(customConverters)) { - for (CustomConverter converter : customConverters) { - mapperFactory.getConverterFactory().registerConverter(converter); - } - } - - return mapperFactory.getMapperFacade(); - } -} diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/mapper/MappingStrategy.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/mapper/MappingStrategy.java deleted file mode 100644 index f099f95bdc8..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/mapper/MappingStrategy.java +++ /dev/null @@ -1,19 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.mapper; - -import ma.glasnost.orika.MapperFactory; - -@FunctionalInterface -public interface MappingStrategy { - - /** - * A callback for registering criteria on the provided {@link MapperFactory}. - *

- *

{@code
-     *
-     * @Override public void register(MapperFactory factory) {
-     * factory.registerMapper(arbeidsfordelingToRestArbeidsfordeling());
-     * }
-     * }
- */ - void register(MapperFactory factory); -} diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/mapper/OrganisajonTilgangMappingStrategy.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/mapper/OrganisajonTilgangMappingStrategy.java deleted file mode 100644 index 1429916dc6d..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/mapper/OrganisajonTilgangMappingStrategy.java +++ /dev/null @@ -1,33 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.mapper; - -import ma.glasnost.orika.CustomMapper; -import ma.glasnost.orika.MapperFactory; -import ma.glasnost.orika.MappingContext; -import no.nav.testnav.apps.organisasjontilgangservice.database.entity.OrganisasjonTilgang; -import no.nav.testnav.apps.organisasjontilgangservice.domain.Organisasjon; -import no.nav.testnav.apps.organisasjontilgangservice.domain.OrganisasjonResponse; -import org.springframework.stereotype.Component; - -import static java.util.Objects.nonNull; -import static org.apache.commons.lang3.StringUtils.isNotBlank; - -@Component -public class OrganisajonTilgangMappingStrategy implements MappingStrategy { - @Override - public void register(MapperFactory factory) { - - factory.classMap(Organisasjon.class, OrganisasjonResponse.class) - .customize(new CustomMapper<>() { - - @Override - public void mapAtoB(Organisasjon organisasjon, OrganisasjonResponse response, MappingContext context) { - - var organisasjonTilgang = (OrganisasjonTilgang) context.getProperty("organisasjonTilgang"); - response.setMiljoe(nonNull(organisasjonTilgang) && isNotBlank(organisasjonTilgang.getMiljoe()) ? - organisasjonTilgang.getMiljoe() : "q1"); - } - }) - .byDefault() - .register(); - } -} diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/service/MiljoerOversiktService.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/service/MiljoerOversiktService.java deleted file mode 100644 index 03410d82600..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/service/MiljoerOversiktService.java +++ /dev/null @@ -1,42 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.service; - -import javassist.NotFoundException; -import lombok.RequiredArgsConstructor; -import no.nav.testnav.apps.organisasjontilgangservice.consumer.altinn.v1.AltinnConsumer; -import no.nav.testnav.apps.organisasjontilgangservice.database.entity.OrganisasjonTilgang; -import no.nav.testnav.apps.organisasjontilgangservice.database.repository.OrganisasjonTilgangRepository; -import org.springframework.stereotype.Service; -import reactor.core.publisher.Mono; - -import static org.apache.commons.lang3.BooleanUtils.isTrue; - -@Service -@RequiredArgsConstructor -public class MiljoerOversiktService { - - private final AltinnConsumer altinnConsumer; - private final OrganisasjonTilgangRepository organisasjonTilgangRepository; - - public Mono getMiljoe(String orgnummer) { - - return altinnConsumer.getOrganisasjoner() - .collectList() - .flatMap(bedrifter -> { - - if (bedrifter.stream().anyMatch(bedrift -> - orgnummer.equals(bedrift.getOrganisasjonsnummer()))) { - - return organisasjonTilgangRepository.existsByOrganisasjonNummer(orgnummer) - .flatMap(miljoe -> isTrue(miljoe) ? - organisasjonTilgangRepository.findByOrganisasjonNummer(orgnummer) : - Mono.just(OrganisasjonTilgang.builder() - .organisasjonNummer(orgnummer) - .miljoe("q1") - .build())); - } else { - return Mono.error(new NotFoundException( - String.format("Organisasjonsnummer %s ble ikke funnet", orgnummer))); - } - }); - } -} diff --git a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/service/OrganisasjonTilgangService.java b/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/service/OrganisasjonTilgangService.java deleted file mode 100644 index 83eeaefd8a6..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/organisasjontilgangservice/service/OrganisasjonTilgangService.java +++ /dev/null @@ -1,69 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice.service; - -import lombok.RequiredArgsConstructor; -import ma.glasnost.orika.MapperFacade; -import ma.glasnost.orika.MappingContext; -import no.nav.testnav.apps.organisasjontilgangservice.consumer.altinn.v1.AltinnConsumer; -import no.nav.testnav.apps.organisasjontilgangservice.database.entity.OrganisasjonTilgang; -import no.nav.testnav.apps.organisasjontilgangservice.database.repository.OrganisasjonTilgangRepository; -import no.nav.testnav.apps.organisasjontilgangservice.domain.OrganisasjonResponse; -import org.springframework.stereotype.Service; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.time.LocalDateTime; - -import static org.apache.commons.lang3.BooleanUtils.isTrue; - -@Service -@RequiredArgsConstructor -public class OrganisasjonTilgangService { - - private final AltinnConsumer altinnConsumer; - private final OrganisasjonTilgangRepository organisasjonTilgangRepository; - private final MapperFacade mapperFacade; - - public Flux getAll() { - - return altinnConsumer.getOrganisasjoner() - .flatMap(organisasjon -> organisasjonTilgangRepository - .existsByOrganisasjonNummer(organisasjon.getOrganisasjonsnummer()) - .flatMap(exists -> isTrue(exists) ? - organisasjonTilgangRepository - .findByOrganisasjonNummer(organisasjon.getOrganisasjonsnummer()) : - Mono.just(new OrganisasjonTilgang())) - .map(organisasjonTilgang -> { - var context = new MappingContext.Factory().getContext(); - context.setProperty("organisasjonTilgang", organisasjonTilgang); - return mapperFacade.map(organisasjon, OrganisasjonResponse.class, context); - })); - } - - public Mono create(String organisasjonsnummer, LocalDateTime gyldigTil, String miljoe) { - - return organisasjonTilgangRepository.existsByOrganisasjonNummer(organisasjonsnummer) - .flatMap(exists -> isTrue(exists) ? - organisasjonTilgangRepository.findByOrganisasjonNummer(organisasjonsnummer) : - Mono.just(OrganisasjonTilgang.builder() - .organisasjonNummer(organisasjonsnummer) - .build())) - .flatMap(organisasjon -> { - organisasjon.setMiljoe(miljoe); - return organisasjonTilgangRepository.save(organisasjon); - }) - .flatMap(organisasjonTilgang -> altinnConsumer.create(organisasjonsnummer, gyldigTil) - .flatMap(organisasjon -> organisasjonTilgangRepository - .findByOrganisasjonNummer(organisasjon.getOrganisasjonsnummer()) - .map(tilgang -> { - var context = new MappingContext.Factory().getContext(); - context.setProperty("organisasjonTilgang", tilgang); - return mapperFacade.map(organisasjon, OrganisasjonResponse.class, context); - }))); - } - - public Flux delete(String organisasjonsnummer) { - - return altinnConsumer.delete(organisasjonsnummer) - .flatMap(status -> organisasjonTilgangRepository.deleteByOrganisasjonNummer(organisasjonsnummer)); - } -} diff --git a/apps/organisasjon-tilgang-service/src/main/resources/application-local.yml b/apps/organisasjon-tilgang-service/src/main/resources/application-local.yml deleted file mode 100644 index e6debad7f2a..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/resources/application-local.yml +++ /dev/null @@ -1,17 +0,0 @@ -ALTINN_API_KEY: dummy -ALTINN_URL: https://tt02.altinn.no -AZURE_APP_CLIENT_ID: ${sm://azure-app-client-id} -AZURE_APP_CLIENT_SECRET: ${sm://azure-app-client-secret} -MASKINPORTEN_CLIENT_ID: dummy -MASKINPORTEN_CLIENT_JWK: dummy -MASKINPORTEN_SCOPES: dummy -MASKINPORTEN_WELL_KNOWN_URL: dummy -TOKEN_X_ISSUER: dummy - -spring: - config: - import: "sm://" - flyway: - url: jdbc:h2:mem:testdb - username: sa - password: diff --git a/apps/organisasjon-tilgang-service/src/main/resources/application-prod.yml b/apps/organisasjon-tilgang-service/src/main/resources/application-prod.yml deleted file mode 100644 index 9e15570c1b8..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/resources/application-prod.yml +++ /dev/null @@ -1,12 +0,0 @@ -ALTINN_URL: https://altinn.no - -spring: - flyway: - locations: classpath:db/migration - url: jdbc:postgresql://${NAIS_DATABASE_TESTNAV_ORGANISASJON_TILGANGER_TESTNAV_ORGANISASJON_TILGANGER_HOST}:${NAIS_DATABASE_TESTNAV_ORGANISASJON_TILGANGER_TESTNAV_ORGANISASJON_TILGANGER_PORT}/${NAIS_DATABASE_TESTNAV_ORGANISASJON_TILGANGER_TESTNAV_ORGANISASJON_TILGANGER_DATABASE} - username: ${NAIS_DATABASE_TESTNAV_ORGANISASJON_TILGANGER_TESTNAV_ORGANISASJON_TILGANGER_USERNAME} - password: ${NAIS_DATABASE_TESTNAV_ORGANISASJON_TILGANGER_TESTNAV_ORGANISASJON_TILGANGER_PASSWORD} - r2dbc: - url: r2dbc:postgresql://${NAIS_DATABASE_TESTNAV_ORGANISASJON_TILGANGER_TESTNAV_ORGANISASJON_TILGANGER_HOST}:${NAIS_DATABASE_TESTNAV_ORGANISASJON_TILGANGER_TESTNAV_ORGANISASJON_TILGANGER_PORT}/${NAIS_DATABASE_TESTNAV_ORGANISASJON_TILGANGER_TESTNAV_ORGANISASJON_TILGANGER_DATABASE} - username: ${NAIS_DATABASE_TESTNAV_ORGANISASJON_TILGANGER_TESTNAV_ORGANISASJON_TILGANGER_USERNAME} - password: ${NAIS_DATABASE_TESTNAV_ORGANISASJON_TILGANGER_TESTNAV_ORGANISASJON_TILGANGER_PASSWORD} \ No newline at end of file diff --git a/apps/organisasjon-tilgang-service/src/main/resources/application.yml b/apps/organisasjon-tilgang-service/src/main/resources/application.yml deleted file mode 100644 index 543d3d30f23..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/resources/application.yml +++ /dev/null @@ -1,56 +0,0 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - -spring: - application: - version: application.version.todo - name: testnav-organisasjon-tilgang-service - description: Tjeneste for hente og sette tilganger for orgnisasjoner - security: - oauth2: - resourceserver: - aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys - accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} - tokenx: - issuer-uri: ${TOKEN_X_ISSUER} - jwk-set-uri: ${TOKEN_X_JWKS_URI} - accepted-audience: ${TOKEN_X_CLIENT_ID} - jackson: - serialization: - write_dates_as_timestamps: false - -springdoc: - swagger-ui: - disable-swagger-default-url: true - url: /v3/api-docs - -altinn: - api: - url: ${ALTINN_URL} - key: ${ALTINN_API_KEY} - service: - code: 5748 - edition: 1 - -management: - endpoints: - enabled-by-default: true - web: - base-path: /internal - exposure.include: prometheus,heapdump,health - path-mapping: - prometheus: metrics - endpoint: - prometheus.enabled: true - heapdump.enabled: true - prometheus: - metrics: - export: - enabled: true -server: - servlet: - encoding: - charset: UTF-8 - error: - include-message: always \ No newline at end of file diff --git a/apps/organisasjon-tilgang-service/src/main/resources/db/migration/V1.0.0__CreateTables.sql b/apps/organisasjon-tilgang-service/src/main/resources/db/migration/V1.0.0__CreateTables.sql deleted file mode 100644 index 074fa6a3eb9..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/resources/db/migration/V1.0.0__CreateTables.sql +++ /dev/null @@ -1,10 +0,0 @@ -------------------------------- --- C R E A T E T A B L E S -- -------------------------------- - -create table organisasjon_tilgang -( - id serial primary key, - organisajon_nummer varchar(50) unique, - miljoe varchar(100) -); \ No newline at end of file diff --git a/apps/organisasjon-tilgang-service/src/main/resources/logback-spring.xml b/apps/organisasjon-tilgang-service/src/main/resources/logback-spring.xml deleted file mode 100644 index 379a17ddc3e..00000000000 --- a/apps/organisasjon-tilgang-service/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - true - - 10280 - 20 - ^sun\.reflect\..*\.invoke - ^net\.sf\.cglib\.proxy\.MethodProxy\.invoke - java\.util\.concurrent\..* - org\.apache\.catalina\..* - org\.apache\.coyote\..* - org\.apache\.tomcat\..* - - - - - - - - - - - - - %d{HH:mm:ss.SSS} | %5p | %logger{25} | %m%n - - utf8 - - - - - - - - - - \ No newline at end of file diff --git a/apps/organisasjon-tilgang-service/src/test/java/no/nav/testnav/apps/organisasjontilgangservice/ApplicationContextTest.java b/apps/organisasjon-tilgang-service/src/test/java/no/nav/testnav/apps/organisasjontilgangservice/ApplicationContextTest.java deleted file mode 100644 index 83743843260..00000000000 --- a/apps/organisasjon-tilgang-service/src/test/java/no/nav/testnav/apps/organisasjontilgangservice/ApplicationContextTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package no.nav.testnav.apps.organisasjontilgangservice; - -import ma.glasnost.orika.MapperFacade; -import org.flywaydb.core.Flyway; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.ReactiveJwtDecoder; -import org.springframework.test.context.ActiveProfiles; - -@SpringBootTest -@ActiveProfiles("test") -class ApplicationContextTest { - - @MockBean - public ReactiveJwtDecoder jwtDecoder; - - @MockBean - public MapperFacade mapperFacade; - - @MockBean - public Flyway flyway; - - @Test - @SuppressWarnings("java:S2699") - void load_app_context() { - } -} diff --git a/apps/organisasjon-tilgang-service/src/test/resources/application-test.yml b/apps/organisasjon-tilgang-service/src/test/resources/application-test.yml deleted file mode 100644 index 0468cb34222..00000000000 --- a/apps/organisasjon-tilgang-service/src/test/resources/application-test.yml +++ /dev/null @@ -1,13 +0,0 @@ -ALTINN_URL: http://localhost:8080 -ALTINN_API_KEY: dummy -MASKINPORTEN_CLIENT_ID: dummy -MASKINPORTEN_CLIENT_JWK: dummy -MASKINPORTEN_SCOPES: dummy -MASKINPORTEN_WELL_KNOWN_URL: http://localhost:8080 -TOKEN_X_ISSUER: dummy - -spring: - cloud: - gcp: - secretmanager: - enabled: false \ No newline at end of file diff --git a/apps/orgnummer-service/src/main/resources/application.yml b/apps/orgnummer-service/src/main/resources/application.yml index 7928e2c4f00..2de7966ba4c 100644 --- a/apps/orgnummer-service/src/main/resources/application.yml +++ b/apps/orgnummer-service/src/main/resources/application.yml @@ -43,12 +43,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/oversikt-frontend/build.gradle b/apps/oversikt-frontend/build.gradle index b2e13e3acfa..5e50676ce88 100644 --- a/apps/oversikt-frontend/build.gradle +++ b/apps/oversikt-frontend/build.gradle @@ -13,6 +13,7 @@ sonarqube { dependencies { implementation "io.grpc:grpc-netty:$versions.grpc" + implementation 'no.nav.testnav.libs:data-transfer-objects' implementation "no.nav.testnav.libs:reactive-core" implementation "no.nav.testnav.libs:reactive-frontend" implementation "no.nav.testnav.libs:reactive-security" diff --git a/apps/oversikt-frontend/config.yml b/apps/oversikt-frontend/config.yml index 53082bdaa3f..a94d8e92a2e 100644 --- a/apps/oversikt-frontend/config.yml +++ b/apps/oversikt-frontend/config.yml @@ -26,65 +26,10 @@ spec: accessPolicy: outbound: rules: - - application: dolly-backend - - application: dolly-backend-dev - - application: generer-navn-service - - application: organisasjon-bestilling-service - - application: synthdata-amelding - - application: synthdata-arena-aap - - application: synthdata-arena-dagpenger - - application: synthdata-arena-meldekort - - application: synthdata-arena-tilleggsstonad - - application: synthdata-arena-tiltak - - application: synthdata-arena-vedtakshistorikk - - application: synthdata-elsam-gcp - - application: testnav-adresse-service - - application: testnav-amelding-service - - application: testnav-app-tilgang-analyse-service - - application: testnav-arbeidsforhold-service - - application: testnav-arbeidsplassencv-proxy - - application: testnav-batch-bestilling-service - - application: testnav-bruker-service - application: testnav-bruker-service-dev - - application: testnav-endringsmelding-service - - application: testnav-generer-arbeidsforhold-populasjon-service - - application: testnav-generer-organisasjon-populasjon-service - - application: testnav-generer-synt-amelding-service - - application: testnav-helsepersonell-service - - application: testnav-ident-pool - - application: testnav-inntektsmelding-generator-service - - application: testnav-inntektsmelding-service - - application: testnav-jenkins-batch-status-service - - application: testnav-joark-dokument-service - - application: testnav-kodeverk-service - - application: testnav-miljoer-service - - application: testnav-oppsummeringsdokument-service - - application: testnav-organisasjon-faste-data-service - - application: testnav-organisasjon-forvalter - - application: testnav-organisasjon-mottak-service - - application: testnav-organisasjon-service - - application: testnav-organisasjon-tilgang-service - - application: testnav-orgnummer-service - - application: testnav-pdl-forvalter - - application: testnav-pdl-forvalter-dev - - application: testnav-person-faste-data-service - - application: testnav-person-organisasjon-tilgang-service-dev - - application: testnav-person-search-service - - application: testnav-person-service - - application: testnav-skattekort-service - - application: testnav-sykemelding-api - - application: testnav-synt-sykemelding-api - - application: testnav-synt-vedtakshistorikk-service - - application: testnav-tenor-search-service - - application: testnav-tps-messaging-service - - application: testnav-varslinger-service - - application: testnav-varslinger-service-dev - - application: testnorge-profil-api + - application: testnav-app-tilgang-analyse-service - application: testnorge-profil-api-dev - - application: testnorge-tilbakemelding-api - - application: testnav-levende-arbeidsforhold-ansettelse - - application: testnav-levende-arbeidsforhold-service - - application: testnav-levende-arbeidsforhold-scheduler + - application: testnav-altinn3-tilgang-service liveness: path: /internal/isAlive initialDelay: 4 diff --git a/apps/oversikt-frontend/settings.gradle b/apps/oversikt-frontend/settings.gradle index 77232fe6e5f..b8cdf008d31 100644 --- a/apps/oversikt-frontend/settings.gradle +++ b/apps/oversikt-frontend/settings.gradle @@ -6,6 +6,7 @@ rootProject.name = 'oversikt-frontend' includeBuild "../../plugins/java" +includeBuild '../../libs/data-transfer-objects' includeBuild '../../libs/reactive-core' includeBuild '../../libs/reactive-frontend' includeBuild '../../libs/reactive-security' diff --git a/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/OversiktFrontendApplicationStarter.java b/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/OversiktFrontendApplicationStarter.java index 8efb3b07e95..d6805193226 100644 --- a/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/OversiktFrontendApplicationStarter.java +++ b/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/OversiktFrontendApplicationStarter.java @@ -44,9 +44,9 @@ public RouteLocator customRouteLocator(RouteLocatorBuilder builder) { addAuthenticationHeaderFilterFrom(consumers.getTestnorgeProfilApi()) )) .route(createRoute( - "testnav-organisasjon-tilgang-service", - consumers.getTestnavPersonOrganisasjonTilgangService().getUrl(), - addAuthenticationHeaderFilterFrom(consumers.getTestnavPersonOrganisasjonTilgangService()) + "testnav-altinn3-tilgang-service", + consumers.getTestnavAltinn3TilgangService().getUrl(), + addAuthenticationHeaderFilterFrom(consumers.getTestnavAltinn3TilgangService()) )) .build(); } diff --git a/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/config/Consumers.java b/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/config/Consumers.java index 9906d9803e5..91e71c891b4 100644 --- a/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/config/Consumers.java +++ b/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/config/Consumers.java @@ -25,7 +25,7 @@ public class Consumers { private ServerProperties testnavAppTilgangAnalyseService; - private ServerProperties testnavPersonOrganisasjonTilgangService; + private ServerProperties testnavAltinn3TilgangService; private ServerProperties testnorgeProfilApi; private ServerProperties testnavBrukerService; diff --git a/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/consumer/AltinnTilgangServiceConsumer.java b/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/consumer/AltinnTilgangServiceConsumer.java new file mode 100644 index 00000000000..684da824c75 --- /dev/null +++ b/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/consumer/AltinnTilgangServiceConsumer.java @@ -0,0 +1,59 @@ +package no.nav.testnav.apps.oversiktfrontend.consumer; + +import lombok.extern.slf4j.Slf4j; +import no.nav.testnav.apps.oversiktfrontend.config.Consumers; +import no.nav.testnav.apps.oversiktfrontend.consumer.command.GetAltinnBrukertilgangTilgangCommand; +import no.nav.testnav.libs.dto.altinn3.v1.OrganisasjonDTO; +import no.nav.testnav.libs.reactivesecurity.action.GetAuthenticatedUserId; +import no.nav.testnav.libs.reactivesecurity.exchange.TokenExchange; +import no.nav.testnav.libs.securitycore.domain.ServerProperties; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.client.WebClient; +import org.springframework.web.reactive.function.client.WebClientResponseException; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +@Slf4j +@Component +public class AltinnTilgangServiceConsumer { + private final WebClient webClient; + private final ServerProperties serverProperties; + private final TokenExchange tokenExchange; + private final GetAuthenticatedUserId getAuthenticatedUserId; + + public AltinnTilgangServiceConsumer( + Consumers consumers, + TokenExchange tokenExchange, + WebClient.Builder webClientBuilder, + GetAuthenticatedUserId getAuthenticatedUserId) { + + serverProperties = consumers.getTestnavAltinn3TilgangService(); + this.tokenExchange = tokenExchange; + this.webClient = webClientBuilder + .baseUrl(serverProperties.getUrl()) + .build(); + this.getAuthenticatedUserId = getAuthenticatedUserId; + } + + public Flux getOrganisasjoner() { + + return getAuthenticatedUserId.call() + .flatMapMany(userId -> tokenExchange.exchange(serverProperties) + .flatMapMany(accessToken -> + new GetAltinnBrukertilgangTilgangCommand(webClient, userId, accessToken.getTokenValue()).call())); + } + + public Mono hasAccess(String organisasjonsnummer) { + + return Mono.from(getOrganisasjoner() + .filter(org -> org.getOrganisasjonsnummer().equals(organisasjonsnummer)) + .onErrorResume( + WebClientResponseException.class::isInstance, + throwable -> { + log.warn("Person har ikke tilgang til organisasjon {}.", organisasjonsnummer); + return Mono.empty(); + }) + .flatMap(value -> Mono.just(true)) + .switchIfEmpty(Mono.just(false))); + } +} diff --git a/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/consumer/PersonOrganisasjonTilgangConsumer.java b/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/consumer/PersonOrganisasjonTilgangConsumer.java deleted file mode 100644 index 05fcb8a1528..00000000000 --- a/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/consumer/PersonOrganisasjonTilgangConsumer.java +++ /dev/null @@ -1,71 +0,0 @@ -package no.nav.testnav.apps.oversiktfrontend.consumer; - -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.extern.slf4j.Slf4j; -import no.nav.testnav.apps.oversiktfrontend.config.Consumers; -import no.nav.testnav.apps.oversiktfrontend.consumer.command.GetPersonOrganisasjonTilgangCommand; -import no.nav.testnav.apps.oversiktfrontend.consumer.command.GetPersonOrganisasjonerTilgangCommand; -import no.nav.testnav.apps.oversiktfrontend.consumer.dto.OrganisasjonDTO; -import no.nav.testnav.libs.reactivesecurity.exchange.TokenExchange; -import no.nav.testnav.libs.securitycore.domain.ServerProperties; -import org.springframework.http.MediaType; -import org.springframework.http.codec.json.Jackson2JsonDecoder; -import org.springframework.http.codec.json.Jackson2JsonEncoder; -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.client.ExchangeStrategies; -import org.springframework.web.reactive.function.client.WebClient; -import org.springframework.web.reactive.function.client.WebClientResponseException; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -@Slf4j -@Component -public class PersonOrganisasjonTilgangConsumer { - private final WebClient webClient; - private final ServerProperties serverProperties; - private final TokenExchange tokenExchange; - - public PersonOrganisasjonTilgangConsumer( - Consumers consumers, - TokenExchange tokenExchange, - ObjectMapper objectMapper, - WebClient.Builder webClientBuilder) { - - serverProperties = consumers.getTestnavPersonOrganisasjonTilgangService(); - this.tokenExchange = tokenExchange; - ExchangeStrategies jacksonStrategy = ExchangeStrategies - .builder() - .codecs( - config -> { - config - .defaultCodecs() - .jackson2JsonEncoder(new Jackson2JsonEncoder(objectMapper, MediaType.APPLICATION_JSON)); - config - .defaultCodecs() - .jackson2JsonDecoder(new Jackson2JsonDecoder(objectMapper, MediaType.APPLICATION_JSON)); - }) - .build(); - this.webClient = webClientBuilder - .exchangeStrategies(jacksonStrategy) - .baseUrl(serverProperties.getUrl()) - .build(); - } - - public Flux getOrganisasjoner() { - return tokenExchange.exchange(serverProperties) - .flatMapMany(accessToken -> new GetPersonOrganisasjonerTilgangCommand(webClient, accessToken.getTokenValue()).call()); - } - - public Mono hasAccess(String organisasjonsnummer) { - return tokenExchange.exchange(serverProperties) - .flatMap(accessToken -> new GetPersonOrganisasjonTilgangCommand(webClient, accessToken.getTokenValue(), organisasjonsnummer).call()) - .onErrorResume( - WebClientResponseException.class::isInstance, - throwable -> { - log.warn("Person har ikke tilgang til organisasjon {}.", organisasjonsnummer); - return Mono.empty(); - }) - .flatMap(value -> Mono.just(true)) - .switchIfEmpty(Mono.just(false)); - } -} diff --git a/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/consumer/command/GetPersonOrganisasjonerTilgangCommand.java b/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/consumer/command/GetAltinnBrukertilgangTilgangCommand.java similarity index 64% rename from apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/consumer/command/GetPersonOrganisasjonerTilgangCommand.java rename to apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/consumer/command/GetAltinnBrukertilgangTilgangCommand.java index 2649253571b..d68f1a09485 100644 --- a/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/consumer/command/GetPersonOrganisasjonerTilgangCommand.java +++ b/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/consumer/command/GetAltinnBrukertilgangTilgangCommand.java @@ -1,7 +1,8 @@ package no.nav.testnav.apps.oversiktfrontend.consumer.command; import lombok.RequiredArgsConstructor; -import no.nav.testnav.apps.oversiktfrontend.consumer.dto.OrganisasjonDTO; +import no.nav.testnav.apps.oversiktfrontend.consumer.dto.AltinnBrukerRequest; +import no.nav.testnav.libs.dto.altinn3.v1.OrganisasjonDTO; import no.nav.testnav.libs.reactivecore.utils.WebClientFilter; import org.springframework.http.HttpHeaders; import org.springframework.web.reactive.function.client.WebClient; @@ -12,16 +13,18 @@ import java.util.concurrent.Callable; @RequiredArgsConstructor -public class GetPersonOrganisasjonerTilgangCommand implements Callable> { +public class GetAltinnBrukertilgangTilgangCommand implements Callable> { private final WebClient webClient; + private final String ident; private final String token; @Override - public Flux call() { + public Flux call() { return webClient - .get() - .uri("/api/v1/person/organisasjoner") + .post() + .uri("/api/v1/brukertilgang") .header(HttpHeaders.AUTHORIZATION, "Bearer " + token) + .bodyValue(new AltinnBrukerRequest(ident)) .retrieve() .bodyToFlux(OrganisasjonDTO.class) .retryWhen(Retry.backoff(3, Duration.ofSeconds(5)) diff --git a/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/consumer/command/GetPersonOrganisasjonTilgangCommand.java b/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/consumer/command/GetPersonOrganisasjonTilgangCommand.java deleted file mode 100644 index ab394911458..00000000000 --- a/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/consumer/command/GetPersonOrganisasjonTilgangCommand.java +++ /dev/null @@ -1,31 +0,0 @@ -package no.nav.testnav.apps.oversiktfrontend.consumer.command; - -import lombok.RequiredArgsConstructor; -import no.nav.testnav.apps.oversiktfrontend.consumer.dto.OrganisasjonDTO; -import no.nav.testnav.libs.reactivecore.utils.WebClientFilter; -import org.springframework.http.HttpHeaders; -import org.springframework.web.reactive.function.client.WebClient; -import reactor.core.publisher.Mono; -import reactor.util.retry.Retry; - -import java.time.Duration; -import java.util.concurrent.Callable; - -@RequiredArgsConstructor -public class GetPersonOrganisasjonTilgangCommand implements Callable> { - private final WebClient webClient; - private final String token; - private final String organisasjonsnummer; - - @Override - public Mono call() { - return webClient - .get() - .uri(builder -> builder.path("/api/v1/person/organisasjoner/{organisasjonsnummer}").build(organisasjonsnummer)) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + token) - .retrieve() - .bodyToMono(OrganisasjonDTO.class) - .retryWhen(Retry.backoff(3, Duration.ofSeconds(5)) - .filter(WebClientFilter::is5xxException)); - } -} diff --git a/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/consumer/dto/AltinnBrukerRequest.java b/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/consumer/dto/AltinnBrukerRequest.java new file mode 100644 index 00000000000..9d1422591c4 --- /dev/null +++ b/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/consumer/dto/AltinnBrukerRequest.java @@ -0,0 +1,11 @@ +package no.nav.testnav.apps.oversiktfrontend.consumer.dto; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class AltinnBrukerRequest { + + private String ident; +} diff --git a/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/consumer/dto/OrganisasjonDTO.java b/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/consumer/dto/OrganisasjonDTO.java deleted file mode 100644 index 5981ab1ebae..00000000000 --- a/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/consumer/dto/OrganisasjonDTO.java +++ /dev/null @@ -1,11 +0,0 @@ -package no.nav.testnav.apps.oversiktfrontend.consumer.dto; - -import java.time.LocalDateTime; - -public record OrganisasjonDTO( - String navn, - String orgnisasjonsnummer, - String orgnisasjonsfrom, - LocalDateTime gyldigTil -) { -} diff --git a/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/controller/PersonOrganisasjonController.java b/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/controller/PersonOrganisasjonController.java new file mode 100644 index 00000000000..2a5c519c294 --- /dev/null +++ b/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/controller/PersonOrganisasjonController.java @@ -0,0 +1,23 @@ +package no.nav.testnav.apps.oversiktfrontend.controller; + +import lombok.RequiredArgsConstructor; +import no.nav.testnav.apps.oversiktfrontend.consumer.AltinnTilgangServiceConsumer; +import no.nav.testnav.libs.dto.altinn3.v1.OrganisasjonDTO; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import reactor.core.publisher.Flux; + +@RestController +@RequestMapping("/api/v1/person-organisasjoner") +@RequiredArgsConstructor +public class PersonOrganisasjonController { + + private final AltinnTilgangServiceConsumer altinnTilgangServiceConsumer; + + @GetMapping + public Flux getOrganisasjoner() { + + return altinnTilgangServiceConsumer.getOrganisasjoner(); + } +} diff --git a/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/service/AccessService.java b/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/service/AccessService.java index c398412334c..f9d56fc8e2e 100644 --- a/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/service/AccessService.java +++ b/apps/oversikt-frontend/src/main/java/no/nav/testnav/apps/oversiktfrontend/service/AccessService.java @@ -1,16 +1,16 @@ package no.nav.testnav.apps.oversiktfrontend.service; import lombok.RequiredArgsConstructor; -import no.nav.testnav.apps.oversiktfrontend.consumer.PersonOrganisasjonTilgangConsumer; +import no.nav.testnav.apps.oversiktfrontend.consumer.AltinnTilgangServiceConsumer; import org.springframework.stereotype.Service; import reactor.core.publisher.Mono; @Service @RequiredArgsConstructor public class AccessService { - private final PersonOrganisasjonTilgangConsumer personOrganisasjonTilgangConsumer; + private final AltinnTilgangServiceConsumer altinnTilgangServiceConsumer; public Mono hasAccess(String organisasjonsnummer) { - return personOrganisasjonTilgangConsumer.hasAccess(organisasjonsnummer); + return altinnTilgangServiceConsumer.hasAccess(organisasjonsnummer); } } diff --git a/apps/oversikt-frontend/src/main/js/proxy-routes.json b/apps/oversikt-frontend/src/main/js/proxy-routes.json index 323be714bd5..ca3b9c4f10c 100644 --- a/apps/oversikt-frontend/src/main/js/proxy-routes.json +++ b/apps/oversikt-frontend/src/main/js/proxy-routes.json @@ -7,10 +7,6 @@ "target": "http://localhost:8080", "changeOrigin": true }, - "/testnav-person-organisasjon-tilgang-service/api": { - "target": "http://localhost:8080", - "changeOrigin": true - }, "/testnav-bruker-service/api": { "target": "http://localhost:8080", "changeOrigin": true diff --git a/apps/oversikt-frontend/src/main/js/src/pages/UserPage/OrgTableBox.tsx b/apps/oversikt-frontend/src/main/js/src/pages/UserPage/OrgTableBox.tsx index 4ead089850b..d976e9d12f8 100644 --- a/apps/oversikt-frontend/src/main/js/src/pages/UserPage/OrgTableBox.tsx +++ b/apps/oversikt-frontend/src/main/js/src/pages/UserPage/OrgTableBox.tsx @@ -31,7 +31,7 @@ const OrgTableBox = () => ( {list && list.map((item, index) => ( - {item.navn + (item.organisasjonsfrom === 'AS' ? ' AS' : '')} + {item.navn + (item.organisasjonsform === 'AS' ? ' AS' : '')} event.preventDefault()}> diff --git a/apps/oversikt-frontend/src/main/js/src/services/OrganisasjonService.ts b/apps/oversikt-frontend/src/main/js/src/services/OrganisasjonService.ts index c766de44cd2..539fc029d5d 100644 --- a/apps/oversikt-frontend/src/main/js/src/services/OrganisasjonService.ts +++ b/apps/oversikt-frontend/src/main/js/src/services/OrganisasjonService.ts @@ -3,11 +3,10 @@ import { Api } from '@navikt/dolly-lib' export type Organisasjon = { navn: string organisasjonsnummer: string - organisasjonsfrom: string - gyldigTil: string + organisasjonsform: string } const getOrganisasjoner = (): Promise => - Api.fetchJson('/testnav-person-organisasjon-tilgang-service/api/v1/person/organisasjoner', { + Api.fetchJson('/api/v1/person-organisasjoner', { method: 'GET', }) diff --git a/apps/oversikt-frontend/src/main/resources/application-local.yml b/apps/oversikt-frontend/src/main/resources/application-local.yml index f186349ca25..42d104adaa8 100644 --- a/apps/oversikt-frontend/src/main/resources/application-local.yml +++ b/apps/oversikt-frontend/src/main/resources/application-local.yml @@ -14,7 +14,7 @@ consumers: url: https://testnorge-profil-api-dev.intern.dev.nav.no/api testnav-app-tilgang-analyse-service: url: https://testnav-app-tilgang-analyse-service.intern.dev.nav.no - testnav-person-organisasjon-tilgang-service: - url: https://testnav-person-organisasjon-tilgang-service-dev.intern.dev.nav.no + testnav-altinn3-tilgang-service: + url: https://testnav-altinn3-tilgang-service.intern.dev.nav.no testnav-bruker-service: url: https://testnav-bruker-service-dev.intern.dev.nav.no \ No newline at end of file diff --git a/apps/oversikt-frontend/src/main/resources/application.yml b/apps/oversikt-frontend/src/main/resources/application.yml index cab26a3240a..e843d6fb138 100644 --- a/apps/oversikt-frontend/src/main/resources/application.yml +++ b/apps/oversikt-frontend/src/main/resources/application.yml @@ -23,11 +23,11 @@ consumers: namespace: dolly name: testnav-app-tilgang-analyse-service url: http://testnav-app-tilgang-analyse-service.dolly.svc.cluster.local - testnav-person-organisasjon-tilgang-service: + testnav-altinn3-tilgang-service: cluster: dev-gcp namespace: dolly - name: testnav-person-organisasjon-tilgang-service-dev - url: http://testnav-person-organisasjon-tilgang-service-dev.dolly.svc.cluster.local + name: testnav-altinn3-tilgang-service + url: http://testnav-altinn3-tilgang-service.dolly.svc.cluster.local testnav-bruker-service: cluster: dev-gcp namespace: dolly @@ -39,12 +39,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/pdl-forvalter/src/main/resources/application.yml b/apps/pdl-forvalter/src/main/resources/application.yml index e2b6c90f4ca..5acfc5165d8 100644 --- a/apps/pdl-forvalter/src/main/resources/application.yml +++ b/apps/pdl-forvalter/src/main/resources/application.yml @@ -56,12 +56,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true health: elasticsearch: enabled: false diff --git a/apps/person-faste-data-service/src/main/resources/application.yml b/apps/person-faste-data-service/src/main/resources/application.yml index 96c6b85b36e..aaa24d49517 100644 --- a/apps/person-faste-data-service/src/main/resources/application.yml +++ b/apps/person-faste-data-service/src/main/resources/application.yml @@ -32,12 +32,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/person-organisasjon-tilgang-service/Dockerfile b/apps/person-organisasjon-tilgang-service/Dockerfile deleted file mode 100644 index 11043b561a5..00000000000 --- a/apps/person-organisasjon-tilgang-service/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM ghcr.io/navikt/baseimages/temurin:21 -LABEL maintainer="Team Dolly" - -ADD build/libs/app.jar /app/app.jar - -EXPOSE 8080 \ No newline at end of file diff --git a/apps/person-organisasjon-tilgang-service/README.md b/apps/person-organisasjon-tilgang-service/README.md deleted file mode 100644 index c51ae05b890..00000000000 --- a/apps/person-organisasjon-tilgang-service/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# Person Organisasjon Tilgang Service -Service som henter organisasjoner fra Altinn og hvilke tilganger de har. - -## Lokal kjøring -* [Generelt.](../../docs/local_general.md) -* [Secret Manager.](../../docs/local_secretmanager.md) \ No newline at end of file diff --git a/apps/person-organisasjon-tilgang-service/build.gradle b/apps/person-organisasjon-tilgang-service/build.gradle deleted file mode 100644 index a3ff5f959d4..00000000000 --- a/apps/person-organisasjon-tilgang-service/build.gradle +++ /dev/null @@ -1,39 +0,0 @@ -plugins { - id "dolly-apps" -} - -def test = tasks.named("test") { - useJUnitPlatform { - excludeTags "integration" - } -} -def iTest = tasks.register("iTest", Test) { - useJUnitPlatform { - includeTags "integration" - } - shouldRunAfter test -} - -sonarqube { - properties { - property "sonar.projectKey", "testnav-person-organisasjon-tilgang-service" - property "sonar.projectName", "testnav-person-organisasjon-tilgang-service" - } -} - -dependencies { - implementation "no.nav.testnav.libs:reactive-core" - implementation "no.nav.testnav.libs:reactive-security" - implementation "no.nav.testnav.libs:security-core" - - implementation "org.springframework.boot:spring-boot-starter-oauth2-resource-server" - - implementation "org.springdoc:springdoc-openapi-starter-webflux-ui:$versions.springdoc" - - implementation "com.fasterxml.jackson.core:jackson-core:$versions.jackson" - - testImplementation "org.springframework.cloud:spring-cloud-contract-wiremock" - testImplementation "no.nav.testnav.libs:integration-test" - testImplementation "com.squareup.okhttp3:okhttp:$versions.okhttp" - testImplementation "com.squareup.okhttp3:mockwebserver:$versions.okhttp" -} diff --git a/apps/person-organisasjon-tilgang-service/config.yml b/apps/person-organisasjon-tilgang-service/config.yml deleted file mode 100644 index e36d5c507e6..00000000000 --- a/apps/person-organisasjon-tilgang-service/config.yml +++ /dev/null @@ -1,69 +0,0 @@ -apiVersion: "nais.io/v1alpha1" -kind: "Application" -metadata: - name: testnav-person-organisasjon-tilgang-service - namespace: dolly - labels: - team: dolly -spec: - image: "{{image}}" - port: 8080 - azure: - application: - allowAllUsers: true - enabled: true - tenant: nav.no - tokenx: - enabled: true - accessPolicy: - inbound: - rules: - - application: dolly-frontend - - application: dolly-idporten - - application: team-dolly-lokal-app - - application: testnav-oversikt-frontend - - application: testnav-bruker-service - - application: testnorge-profil-api - outbound: - external: - - host: altinn.no - - host: maskinporten.no - liveness: - path: /internal/isAlive - initialDelay: 4 - periodSeconds: 5 - failureThreshold: 500 - observability: - logging: - destinations: - - id: elastic - autoInstrumentation: - enabled: true - runtime: java - readiness: - path: /internal/isReady - initialDelay: 4 - periodSeconds: 5 - failureThreshold: 500 - prometheus: - enabled: true - path: /internal/metrics - envFrom: - - secret: altinn-prod - - secret: maskinporten-dolly-prod - replicas: - min: 1 - max: 1 - resources: - requests: - cpu: 200m - memory: 1024Mi - limits: - memory: 2048Mi - ingresses: - - "https://testnav-person-organisasjon-tilgang-service.intern.dev.nav.no" - env: - - name: SPRING_PROFILES_ACTIVE - value: prod - - name: ALTINN_URL - value: https://altinn.no \ No newline at end of file diff --git a/apps/person-organisasjon-tilgang-service/gradle/wrapper/gradle-wrapper.jar b/apps/person-organisasjon-tilgang-service/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 7454180f2ae..00000000000 Binary files a/apps/person-organisasjon-tilgang-service/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/apps/person-organisasjon-tilgang-service/gradle/wrapper/gradle-wrapper.properties b/apps/person-organisasjon-tilgang-service/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 48c0a02ca41..00000000000 --- a/apps/person-organisasjon-tilgang-service/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/apps/person-organisasjon-tilgang-service/gradlew b/apps/person-organisasjon-tilgang-service/gradlew deleted file mode 100755 index 3da45c161b0..00000000000 --- a/apps/person-organisasjon-tilgang-service/gradlew +++ /dev/null @@ -1,234 +0,0 @@ -#!/bin/sh - -# -# Copyright ? 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions ?$var?, ?${var}?, ?${var:-default}?, ?${var+SET}?, -# ?${var#prefix}?, ?${var%suffix}?, and ?$( cmd )?; -# * compound commands having a testable exit status, especially ?case?; -# * various built-in commands including ?command?, ?set?, and ?ulimit?. -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" -APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/apps/person-organisasjon-tilgang-service/gradlew.bat b/apps/person-organisasjon-tilgang-service/gradlew.bat deleted file mode 100644 index ac1b06f9382..00000000000 --- a/apps/person-organisasjon-tilgang-service/gradlew.bat +++ /dev/null @@ -1,89 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/apps/person-organisasjon-tilgang-service/gradlewUpdate.sh b/apps/person-organisasjon-tilgang-service/gradlewUpdate.sh deleted file mode 100755 index e5ee6361152..00000000000 --- a/apps/person-organisasjon-tilgang-service/gradlewUpdate.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -gradle wrapper \ No newline at end of file diff --git a/apps/person-organisasjon-tilgang-service/settings.gradle b/apps/person-organisasjon-tilgang-service/settings.gradle deleted file mode 100644 index 6c93b49e1a4..00000000000 --- a/apps/person-organisasjon-tilgang-service/settings.gradle +++ /dev/null @@ -1,19 +0,0 @@ -plugins { - id "com.gradle.develocity" version "3.17.4" -} - -rootProject.name = 'person-organisasjon-tilgang-service' - -includeBuild "../../plugins/java" - -includeBuild '../../libs/integration-test' -includeBuild '../../libs/reactive-core' -includeBuild '../../libs/reactive-security' -includeBuild '../../libs/security-core' - -develocity { - buildScan { - termsOfUseUrl = "https://gradle.com/terms-of-service" - termsOfUseAgree = "yes" - } -} \ No newline at end of file diff --git a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/PersonOrganisasjonTilgangServiceApplicationStarter.java b/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/PersonOrganisasjonTilgangServiceApplicationStarter.java deleted file mode 100644 index 9b61b5fd26c..00000000000 --- a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/PersonOrganisasjonTilgangServiceApplicationStarter.java +++ /dev/null @@ -1,22 +0,0 @@ -package no.nav.testnav.apps.persontilgangservice; - -import no.nav.testnav.libs.reactivecore.config.CoreConfig; -import no.nav.testnav.libs.reactivesecurity.config.SecureOAuth2ServerToServerConfiguration; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Import; -import org.springframework.web.reactive.config.EnableWebFlux; - - -@Import({ - CoreConfig.class, - SecureOAuth2ServerToServerConfiguration.class -}) -@EnableWebFlux -@SpringBootApplication -public class PersonOrganisasjonTilgangServiceApplicationStarter { - - public static void main(String[] args) { - SpringApplication.run(PersonOrganisasjonTilgangServiceApplicationStarter.class, args); - } -} diff --git a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/client/altinn/v1/AltinnClient.java b/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/client/altinn/v1/AltinnClient.java deleted file mode 100644 index ee46fe8a4c0..00000000000 --- a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/client/altinn/v1/AltinnClient.java +++ /dev/null @@ -1,78 +0,0 @@ -package no.nav.testnav.apps.persontilgangservice.client.altinn.v1; - -import com.fasterxml.jackson.databind.ObjectMapper; -import no.nav.testnav.apps.persontilgangservice.client.altinn.v1.command.GetPersonAccessCommand; -import no.nav.testnav.apps.persontilgangservice.client.altinn.v1.dto.AccessDTO; -import no.nav.testnav.apps.persontilgangservice.client.maskinporten.v1.MaskinportenClient; -import no.nav.testnav.apps.persontilgangservice.config.AltinnConfig; -import no.nav.testnav.apps.persontilgangservice.domain.Access; -import no.nav.testnav.libs.reactivesecurity.action.GetAuthenticatedUserId; -import org.springframework.http.codec.json.Jackson2JsonDecoder; -import org.springframework.http.codec.json.Jackson2JsonEncoder; -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.client.WebClient; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.util.Arrays; - -@Component -public class AltinnClient { - - private final WebClient webClient; - private final AltinnConfig altinnConfig; - private final MaskinportenClient maskinportenClient; - private final GetAuthenticatedUserId getAuthenticatedUserId; - - public AltinnClient( - AltinnConfig altinnConfig, - MaskinportenClient maskinportenClient, - ObjectMapper objectMapper, - GetAuthenticatedUserId getAuthenticatedUserId - ) { - this.altinnConfig = altinnConfig; - this.maskinportenClient = maskinportenClient; - this.getAuthenticatedUserId = getAuthenticatedUserId; - this.webClient = WebClient - .builder() - .baseUrl(altinnConfig.getUrl()) - .codecs(clientDefaultCodecsConfigurer -> { - clientDefaultCodecsConfigurer - .defaultCodecs() - .jackson2JsonEncoder(new Jackson2JsonEncoder(objectMapper)); - clientDefaultCodecsConfigurer - .defaultCodecs() - .jackson2JsonDecoder(new Jackson2JsonDecoder(objectMapper)); - }) - .build(); - } - - public Flux getAccess() { - return getAuthenticatedUserId - .call() - .flatMapMany(userId -> maskinportenClient - .getAccessToken() - .flatMap(accessToken -> new GetPersonAccessCommand( - webClient, - accessToken.value(), - userId, - altinnConfig.getCode(), - altinnConfig.getEdition(), - altinnConfig.getApiKey() - ).call() - ).map(accesses -> Arrays - .stream(accesses) - .filter(AccessDTO::isActive) - .map(Access::new) - .toList() - ).flatMapIterable(list -> list) - ); - } - - public Mono getAccess(String organiasjonsnummer) { - return getAccess() - .filter(value -> value.getOrganisajonsnummer().equals(organiasjonsnummer)) - .next(); - } - -} diff --git a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/client/altinn/v1/command/GetPersonAccessCommand.java b/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/client/altinn/v1/command/GetPersonAccessCommand.java deleted file mode 100644 index 5db7644abc0..00000000000 --- a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/client/altinn/v1/command/GetPersonAccessCommand.java +++ /dev/null @@ -1,48 +0,0 @@ -package no.nav.testnav.apps.persontilgangservice.client.altinn.v1.command; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import no.nav.testnav.apps.persontilgangservice.client.altinn.v1.dto.AccessDTO; -import no.nav.testnav.libs.reactivecore.utils.WebClientFilter; -import org.springframework.http.HttpHeaders; -import org.springframework.web.reactive.function.client.WebClient; -import reactor.core.publisher.Mono; -import reactor.util.retry.Retry; - -import java.time.Duration; -import java.util.Arrays; -import java.util.concurrent.Callable; - -@Slf4j -@RequiredArgsConstructor -public class GetPersonAccessCommand implements Callable> { - private final WebClient webClient; - private final String token; - private final String ident; - private final String serviceCode; - private final String serviceEdition; - private final String apiKey; - - @Override - public Mono call() { - return webClient - .get() - .uri(builder -> builder.path("/api/serviceowner/reportees") - .queryParam("subject", ident) - .queryParam("serviceCode", serviceCode) - .queryParam("serviceEdition", serviceEdition) - .build() - ) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + token) - .header("ApiKey", apiKey) - .retrieve() - .bodyToMono(AccessDTO[].class) - .doOnNext(response -> Arrays.stream(response) - .forEach(entry -> - log.info("Hentet organisasjon fra Altinn: navn: {}, type: {}, orgnr: {}, orgform: {}, status: {} ", - entry.name(), entry.type(), entry.organizationNumber(), entry.organizationForm(), entry.status()))) - .doOnError(error -> log.error("Henting av \"/reportees\" feilet: {}", WebClientFilter.getMessage(error), error)) - .retryWhen(Retry.backoff(3, Duration.ofSeconds(5)) - .filter(WebClientFilter::is5xxException)); - } -} diff --git a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/client/altinn/v1/dto/AccessDTO.java b/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/client/altinn/v1/dto/AccessDTO.java deleted file mode 100644 index dad4ebe38ca..00000000000 --- a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/client/altinn/v1/dto/AccessDTO.java +++ /dev/null @@ -1,21 +0,0 @@ -package no.nav.testnav.apps.persontilgangservice.client.altinn.v1.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public record AccessDTO( - @JsonProperty("Name") - String name, - @JsonProperty("Type") - String type, - @JsonProperty("OrganizationNumber") - String organizationNumber, - @JsonProperty("OrganizationForm") - String organizationForm, - @JsonProperty("Status") - String status -) { - - public boolean isActive() { - return status.equals("Active"); - } -} diff --git a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/client/maskinporten/v1/MaskinportenClient.java b/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/client/maskinporten/v1/MaskinportenClient.java deleted file mode 100644 index e8e640b7220..00000000000 --- a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/client/maskinporten/v1/MaskinportenClient.java +++ /dev/null @@ -1,91 +0,0 @@ -package no.nav.testnav.apps.persontilgangservice.client.maskinporten.v1; - -import com.nimbusds.jose.JOSEException; -import com.nimbusds.jose.JOSEObjectType; -import com.nimbusds.jose.JWSAlgorithm; -import com.nimbusds.jose.JWSHeader; -import com.nimbusds.jose.JWSSigner; -import com.nimbusds.jose.crypto.RSASSASigner; -import com.nimbusds.jose.jwk.RSAKey; -import com.nimbusds.jwt.JWTClaimsSet; -import com.nimbusds.jwt.SignedJWT; -import lombok.SneakyThrows; -import lombok.extern.slf4j.Slf4j; -import no.nav.testnav.apps.persontilgangservice.client.maskinporten.v1.command.GetAccessTokenCommand; -import no.nav.testnav.apps.persontilgangservice.client.maskinporten.v1.command.GetWellKnownCommand; -import no.nav.testnav.apps.persontilgangservice.client.maskinporten.v1.dto.AccessToken; -import no.nav.testnav.apps.persontilgangservice.config.MaskinportenConfig; -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.client.WebClient; -import reactor.core.publisher.Mono; - -import java.time.Duration; -import java.time.Instant; -import java.util.Date; -import java.util.UUID; -import java.util.function.Function; - -@Slf4j -@Component -public class MaskinportenClient { - - private final WebClient webClient; - private final MaskinportenConfig maskinportenConfig; - private final Mono accessToken; - - public MaskinportenClient(MaskinportenConfig maskinportenConfig) { - this.webClient = WebClient.builder().build(); - this.maskinportenConfig = maskinportenConfig; - var wellKnownMono = cache( - new GetWellKnownCommand(webClient, maskinportenConfig).call(), - value -> Duration.ofDays(7) - ); - this.accessToken = cache( - wellKnownMono.flatMap(wellKnown -> new GetAccessTokenCommand(webClient, wellKnown, createJwtClaims(wellKnown.issuer())).call()), - value -> Duration.ofSeconds(value.expiresIn() - 10L) - ); - } - - private static Mono cache(Mono value, Function ttlForValue) { - return value.cache( - ttlForValue, - throwable -> Duration.ZERO, - () -> Duration.ZERO - ); - } - - public Mono getAccessToken() { - return accessToken.map(no.nav.testnav.apps.persontilgangservice.domain.AccessToken::new); - } - - @SneakyThrows - private String createJwtClaims(String audience) { - Instant now = Instant.now(); - var rsaKey = RSAKey.parse(maskinportenConfig.getJwkPrivate()); - return createSignedJWT(rsaKey, - new JWTClaimsSet.Builder() - .audience(audience) - .claim("scope", maskinportenConfig.getScope()) - .issuer(maskinportenConfig.getClientId()) - .issueTime(Date.from(now)) - .expirationTime(Date.from(now.plusSeconds(119))) - .jwtID(UUID.randomUUID().toString()) - .build()) - .serialize(); - } - - private SignedJWT createSignedJWT(RSAKey rsaJwk, JWTClaimsSet claimsSet) { - try { - JWSHeader.Builder header = new JWSHeader.Builder(JWSAlgorithm.RS256) - .keyID(rsaJwk.getKeyID()) - .type(JOSEObjectType.JWT); - SignedJWT signedJWT = new SignedJWT(header.build(), claimsSet); - JWSSigner signer = new RSASSASigner(rsaJwk.toPrivateKey()); - signedJWT.sign(signer); - return signedJWT; - } catch (JOSEException e) { - throw new RuntimeException(e); - } - } - -} diff --git a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/client/maskinporten/v1/command/GetAccessTokenCommand.java b/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/client/maskinporten/v1/command/GetAccessTokenCommand.java deleted file mode 100644 index f1da03d101d..00000000000 --- a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/client/maskinporten/v1/command/GetAccessTokenCommand.java +++ /dev/null @@ -1,40 +0,0 @@ -package no.nav.testnav.apps.persontilgangservice.client.maskinporten.v1.command; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import no.nav.testnav.apps.persontilgangservice.client.maskinporten.v1.dto.AccessToken; -import no.nav.testnav.apps.persontilgangservice.client.maskinporten.v1.dto.WellKnown; -import org.springframework.web.reactive.function.BodyInserters; -import org.springframework.web.reactive.function.client.WebClient; -import org.springframework.web.reactive.function.client.WebClientResponseException; -import reactor.core.publisher.Mono; - -import java.util.concurrent.Callable; - -@Slf4j -@RequiredArgsConstructor -public class GetAccessTokenCommand implements Callable> { - private final WebClient webClient; - private final WellKnown wellKnown; - private final String assertion; - - @Override - public Mono call() { - return webClient.post() - .uri(wellKnown.tokenEndpoint()) - .body(BodyInserters - .fromFormData("grant_type", wellKnown.grantTypesSupported().get(0)) - .with("assertion", assertion) - ) - .retrieve() - .bodyToMono(AccessToken.class) - .doOnSuccess(value -> log.info("AccessToken hentet fra maskinporten.")) - .doOnError( - WebClientResponseException.class::isInstance, - throwable -> log.error( - "Feil ved henting av AccessToken for maskinporten. \n{}", - ((WebClientResponseException) throwable).getResponseBodyAsString() - ) - ); - } -} diff --git a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/client/maskinporten/v1/command/GetWellKnownCommand.java b/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/client/maskinporten/v1/command/GetWellKnownCommand.java deleted file mode 100644 index 41d3a870157..00000000000 --- a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/client/maskinporten/v1/command/GetWellKnownCommand.java +++ /dev/null @@ -1,34 +0,0 @@ -package no.nav.testnav.apps.persontilgangservice.client.maskinporten.v1.command; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import no.nav.testnav.apps.persontilgangservice.client.maskinporten.v1.dto.WellKnown; -import no.nav.testnav.apps.persontilgangservice.config.MaskinportenConfig; -import org.springframework.web.reactive.function.client.WebClient; -import org.springframework.web.reactive.function.client.WebClientResponseException; -import reactor.core.publisher.Mono; - -import java.util.concurrent.Callable; - -@Slf4j -@RequiredArgsConstructor -public class GetWellKnownCommand implements Callable> { - private final WebClient webClient; - private final MaskinportenConfig maskinportenConfig; - - @Override - public Mono call() { - return webClient.get() - .uri(maskinportenConfig.getWellKnownUrl()) - .retrieve() - .bodyToMono(WellKnown.class) - .doOnSuccess(value -> log.info("WellKnown hentet for maskinporten.")) - .doOnError( - WebClientResponseException.class::isInstance, - throwable -> log.error( - "Feil ved henting av well known for maskinporten. \n{}", - ((WebClientResponseException) throwable).getResponseBodyAsString() - ) - ); - } -} diff --git a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/client/maskinporten/v1/dto/AccessToken.java b/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/client/maskinporten/v1/dto/AccessToken.java deleted file mode 100644 index 90ede59fe24..00000000000 --- a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/client/maskinporten/v1/dto/AccessToken.java +++ /dev/null @@ -1,16 +0,0 @@ -package no.nav.testnav.apps.persontilgangservice.client.maskinporten.v1.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public record AccessToken( - @JsonProperty("access_token") - String accessToken, - @JsonProperty("token_type") - String tokenType, - @JsonProperty("expires_in") - Integer expiresIn, - @JsonProperty("scope") - String scope -) { - -} diff --git a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/client/maskinporten/v1/dto/WellKnown.java b/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/client/maskinporten/v1/dto/WellKnown.java deleted file mode 100644 index da750ff225d..00000000000 --- a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/client/maskinporten/v1/dto/WellKnown.java +++ /dev/null @@ -1,18 +0,0 @@ -package no.nav.testnav.apps.persontilgangservice.client.maskinporten.v1.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public record WellKnown( - String issuer, - @JsonProperty("token_endpoint") - String tokenEndpoint, - @JsonProperty("jwks_uri") - String jwksUri, - @JsonProperty("token_endpoint_auth_methods_supported") - List tokenEndpointAuthMethodsSupported, - @JsonProperty("grant_types_supported") - List grantTypesSupported -) { -} diff --git a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/config/AltinnConfig.java b/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/config/AltinnConfig.java deleted file mode 100644 index e1ecc5f9e30..00000000000 --- a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/config/AltinnConfig.java +++ /dev/null @@ -1,41 +0,0 @@ -package no.nav.testnav.apps.persontilgangservice.config; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class AltinnConfig { - - private final String url; - private final String apiKey; - private final String code; - private final String edition; - - public AltinnConfig( - @Value("${altinn.api.url}") String url, - @Value("${altinn.api.key}") String apiKey, - @Value("${altinn.service.code}") String code, - @Value("${altinn.service.edition}") String edition - ) { - this.url = url; - this.apiKey = apiKey; - this.code = code; - this.edition = edition; - } - - public String getCode() { - return code; - } - - public String getEdition() { - return edition; - } - - public String getUrl() { - return url; - } - - public String getApiKey() { - return apiKey; - } -} diff --git a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/config/JacksonConfig.java b/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/config/JacksonConfig.java deleted file mode 100644 index cbc95a05771..00000000000 --- a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/config/JacksonConfig.java +++ /dev/null @@ -1,27 +0,0 @@ -package no.nav.testnav.apps.persontilgangservice.config; - -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.RequiredArgsConstructor; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.codec.ServerCodecConfigurer; -import org.springframework.http.codec.json.Jackson2JsonDecoder; -import org.springframework.http.codec.json.Jackson2JsonEncoder; -import org.springframework.web.reactive.config.WebFluxConfigurer; - -@Configuration -@RequiredArgsConstructor -public class JacksonConfig implements WebFluxConfigurer { - - private final ObjectMapper objectMapper; - - @Override - public void configureHttpMessageCodecs(ServerCodecConfigurer configurer) { - configurer.defaultCodecs().jackson2JsonEncoder( - new Jackson2JsonEncoder(objectMapper) - ); - - configurer.defaultCodecs().jackson2JsonDecoder( - new Jackson2JsonDecoder(objectMapper) - ); - } -} \ No newline at end of file diff --git a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/config/MaskinportenConfig.java b/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/config/MaskinportenConfig.java deleted file mode 100644 index faa744f3be2..00000000000 --- a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/config/MaskinportenConfig.java +++ /dev/null @@ -1,41 +0,0 @@ -package no.nav.testnav.apps.persontilgangservice.config; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class MaskinportenConfig { - - private final String clientId; - private final String jwkPrivate; - private final String scope; - private final String wellKnownUrl; - - public MaskinportenConfig( - @Value("${MASKINPORTEN_CLIENT_ID}") String clientId, - @Value("${MASKINPORTEN_CLIENT_JWK}") String jwkPrivate, - @Value("${MASKINPORTEN_SCOPES}") String scope, - @Value("${MASKINPORTEN_WELL_KNOWN_URL}") String wellKnownUrl - ) { - this.clientId = clientId; - this.scope = scope; - this.jwkPrivate = jwkPrivate; - this.wellKnownUrl = wellKnownUrl; - } - - public String getClientId() { - return clientId; - } - - public String getJwkPrivate() { - return jwkPrivate; - } - - public String getScope() { - return scope; - } - - public String getWellKnownUrl() { - return wellKnownUrl; - } -} diff --git a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/config/OpenApiConfig.java b/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/config/OpenApiConfig.java deleted file mode 100644 index 65c78d3efbd..00000000000 --- a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/config/OpenApiConfig.java +++ /dev/null @@ -1,49 +0,0 @@ -package no.nav.testnav.apps.persontilgangservice.config; - -import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Contact; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.info.License; -import io.swagger.v3.oas.models.security.SecurityRequirement; -import io.swagger.v3.oas.models.security.SecurityScheme; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import java.util.Arrays; - -import no.nav.testnav.libs.reactivecore.config.ApplicationProperties; - - -@Configuration -public class OpenApiConfig { - - @Bean - public OpenAPI openApi(ApplicationProperties applicationProperties) { - return new OpenAPI() - .components(new Components().addSecuritySchemes("bearer-jwt", new SecurityScheme() - .type(SecurityScheme.Type.HTTP) - .scheme("bearer") - .bearerFormat("JWT") - .in(SecurityScheme.In.HEADER) - .name("Authorization") - )) - .addSecurityItem( - new SecurityRequirement().addList("bearer-jwt", Arrays.asList("read", "write"))) - .info(new Info() - .title(applicationProperties.getName()) - .version(applicationProperties.getVersion()) - .description(applicationProperties.getDescription()) - .termsOfService("https://nav.no") - .contact(new Contact() - .url("https://nav-it.slack.com/archives/CA3P9NGA2") - .email("dolly@nav.no") - .name("Team Dolly") - ) - .license(new License() - .name("MIT License") - .url("https://opensource.org/licenses/MIT") - ) - ); - } -} \ No newline at end of file diff --git a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/config/SecurityConfig.java b/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/config/SecurityConfig.java deleted file mode 100644 index 0701a612ba3..00000000000 --- a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/config/SecurityConfig.java +++ /dev/null @@ -1,40 +0,0 @@ -package no.nav.testnav.apps.persontilgangservice.config; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import no.nav.testnav.libs.reactivesecurity.manager.JwtReactiveAuthenticationManager; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.method.configuration.EnableReactiveMethodSecurity; -import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity; -import org.springframework.security.config.web.server.ServerHttpSecurity; -import org.springframework.security.web.server.SecurityWebFilterChain; - - -@Slf4j -@Configuration -@EnableWebFluxSecurity -@EnableReactiveMethodSecurity -@RequiredArgsConstructor -public class SecurityConfig { - - private final JwtReactiveAuthenticationManager jwtReactiveAuthenticationManager; - - @Bean - public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity httpSecurity) { - return httpSecurity - .csrf(ServerHttpSecurity.CsrfSpec::disable) - .authorizeExchange(authorizeConfig -> authorizeConfig.pathMatchers( - "/internal/**", - "/webjars/**", - "/swagger-resources/**", - "/v3/api-docs/**", - "/swagger-ui/**", - "/swagger", - "/error", - "/swagger-ui.html" - ).permitAll().anyExchange().authenticated()) - .oauth2ResourceServer(oauth2RSConfig -> oauth2RSConfig.jwt(jwtSpec -> jwtSpec.authenticationManager(jwtReactiveAuthenticationManager))) - .build(); - } -} diff --git a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/controller/PersonOrganisasjonController.java b/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/controller/PersonOrganisasjonController.java deleted file mode 100644 index bf27e55d982..00000000000 --- a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/controller/PersonOrganisasjonController.java +++ /dev/null @@ -1,42 +0,0 @@ -package no.nav.testnav.apps.persontilgangservice.controller; - -import lombok.RequiredArgsConstructor; -import no.nav.testnav.apps.persontilgangservice.controller.dto.OrganisasjonDTO; -import no.nav.testnav.apps.persontilgangservice.domain.Access; -import no.nav.testnav.apps.persontilgangservice.domain.AccessToken; -import no.nav.testnav.apps.persontilgangservice.service.PersonOrganisasjonService; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -@RestController -@RequestMapping("/api/v1/person/organisasjoner") -@RequiredArgsConstructor -public class PersonOrganisasjonController { - - private final PersonOrganisasjonService personOrganisasjonService; - - @GetMapping - public Flux getOrganiasjoner() { - return personOrganisasjonService.getAccess().map(Access::toDTO); - } - - @GetMapping("/token") - public Mono getMaskinportenToken() { - return personOrganisasjonService.getAccessToken(); - } - - - @GetMapping("/{organisasjonsnummer}") - public Mono> getOrganiasjoner(@PathVariable String organisasjonsnummer) { - return personOrganisasjonService - .getAccess(organisasjonsnummer) - .map(Access::toDTO) - .map(ResponseEntity::ok) - .switchIfEmpty(Mono.just(ResponseEntity.notFound().build())); - } -} \ No newline at end of file diff --git a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/controller/dto/OrganisasjonDTO.java b/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/controller/dto/OrganisasjonDTO.java deleted file mode 100644 index 991b8127bd2..00000000000 --- a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/controller/dto/OrganisasjonDTO.java +++ /dev/null @@ -1,14 +0,0 @@ -package no.nav.testnav.apps.persontilgangservice.controller.dto; - -import com.fasterxml.jackson.annotation.JsonInclude; - -import java.time.LocalDateTime; - -@JsonInclude(JsonInclude.Include.NON_NULL) -public record OrganisasjonDTO( - String navn, - String organisasjonsnummer, - String organisasjonsfrom, - LocalDateTime gyldigTil -) { -} diff --git a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/domain/Access.java b/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/domain/Access.java deleted file mode 100644 index 59c416dd45c..00000000000 --- a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/domain/Access.java +++ /dev/null @@ -1,29 +0,0 @@ -package no.nav.testnav.apps.persontilgangservice.domain; - -import no.nav.testnav.apps.persontilgangservice.client.altinn.v1.dto.AccessDTO; -import no.nav.testnav.apps.persontilgangservice.controller.dto.OrganisasjonDTO; - -public class Access { - private final String navn; - private final String organisajonsnummer; - private final String organisajonsfrom; - - public Access(AccessDTO accessDTO) { - this.navn = accessDTO.name(); - this.organisajonsnummer = accessDTO.organizationNumber(); - this.organisajonsfrom = accessDTO.organizationForm(); - } - - public OrganisasjonDTO toDTO() { - return new OrganisasjonDTO( - navn, - organisajonsnummer, - organisajonsfrom, - null // TODO Set gyldigTil - ); - } - - public String getOrganisajonsnummer() { - return organisajonsnummer; - } -} diff --git a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/domain/AccessToken.java b/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/domain/AccessToken.java deleted file mode 100644 index 636a4aa3510..00000000000 --- a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/domain/AccessToken.java +++ /dev/null @@ -1,7 +0,0 @@ -package no.nav.testnav.apps.persontilgangservice.domain; - -public record AccessToken(String value) { - public AccessToken(no.nav.testnav.apps.persontilgangservice.client.maskinporten.v1.dto.AccessToken accessToken) { - this(accessToken.accessToken()); - } -} diff --git a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/service/PersonOrganisasjonService.java b/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/service/PersonOrganisasjonService.java deleted file mode 100644 index bc8bfc06fc4..00000000000 --- a/apps/person-organisasjon-tilgang-service/src/main/java/no/nav/testnav/apps/persontilgangservice/service/PersonOrganisasjonService.java +++ /dev/null @@ -1,31 +0,0 @@ -package no.nav.testnav.apps.persontilgangservice.service; - -import lombok.RequiredArgsConstructor; -import no.nav.testnav.apps.persontilgangservice.client.maskinporten.v1.MaskinportenClient; -import no.nav.testnav.apps.persontilgangservice.domain.AccessToken; -import org.springframework.stereotype.Service; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import no.nav.testnav.apps.persontilgangservice.client.altinn.v1.AltinnClient; -import no.nav.testnav.apps.persontilgangservice.domain.Access; - -@Service -@RequiredArgsConstructor -public class PersonOrganisasjonService { - - private final AltinnClient client; - private final MaskinportenClient maskinportenClient; - - public Flux getAccess() { - return client.getAccess(); - } - - public Mono getAccessToken() { - return maskinportenClient.getAccessToken(); - } - - public Mono getAccess(String organiasjonsnummer) { - return client.getAccess(organiasjonsnummer); - } -} diff --git a/apps/person-organisasjon-tilgang-service/src/main/resources/application-local.yml b/apps/person-organisasjon-tilgang-service/src/main/resources/application-local.yml deleted file mode 100644 index 1d0b7c93e9d..00000000000 --- a/apps/person-organisasjon-tilgang-service/src/main/resources/application-local.yml +++ /dev/null @@ -1,15 +0,0 @@ -ALTINN_API_KEY: dummy -ALTINN_URL: https://tt02.altinn.no -AZURE_APP_CLIENT_ID: ${sm://azure-app-client-id} -AZURE_APP_CLIENT_SECRET: ${sm://azure-app-client-secret} -MASKINPORTEN_CLIENT_ID: dummy -MASKINPORTEN_CLIENT_JWK: dummy -MASKINPORTEN_SCOPES: dummy -MASKINPORTEN_WELL_KNOWN_URL: dummy -OKEN_X_JWKS_URI: dummy -TOKEN_X_CLIENT_ID: dummy -TOKEN_X_ISSUER: dummy - -spring: - config: - import: "sm://" diff --git a/apps/person-organisasjon-tilgang-service/src/main/resources/application-virtual.yml b/apps/person-organisasjon-tilgang-service/src/main/resources/application-virtual.yml deleted file mode 100644 index 2a087356478..00000000000 --- a/apps/person-organisasjon-tilgang-service/src/main/resources/application-virtual.yml +++ /dev/null @@ -1,20 +0,0 @@ -TOKEN_X_ISSUER: http://tokendings:8080 -TOKEN_X_JWKS_URI: http://tokendings:8080/jwks -TOKEN_X_CLIENT_ID: dev-gcp:dolly:testnav-person-organisasjon-tilgang-service - -spring: - cloud: - gcp: - secretmanager: - enabled: false - -altinn: - api: - url: http://altinn:8080 - key: dummy-altinn-key - -TOKEN_X_WELL_KNOWN_URL: http://tokendings:8080/.well-known/oauth-authorization-server - -MASKINPORTEN_CLIENT_ID: client-id -MASKINPORTEN_SCOPES: scopes -MASKINPORTEN_WELL_KNOWN_URL: http://maskinporten:8080/.well-known/oauth-authorization-server \ No newline at end of file diff --git a/apps/person-organisasjon-tilgang-service/src/main/resources/application.yml b/apps/person-organisasjon-tilgang-service/src/main/resources/application.yml deleted file mode 100644 index 1da5b3b1184..00000000000 --- a/apps/person-organisasjon-tilgang-service/src/main/resources/application.yml +++ /dev/null @@ -1,56 +0,0 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - -spring: - application: - version: application.version.todo - name: testnav-person-organisasjon-tilgang-service - description: Tjeneste for å hente tilganger for personer - security: - oauth2: - resourceserver: - aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys - accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} - tokenx: - issuer-uri: ${TOKEN_X_ISSUER} - jwk-set-uri: ${TOKEN_X_JWKS_URI} - accepted-audience: ${TOKEN_X_CLIENT_ID} - jackson: - serialization: - write_dates_as_timestamps: false - -springdoc: - swagger-ui: - disable-swagger-default-url: true - url: /v3/api-docs - -altinn: - api: - url: ${ALTINN_URL} - key: ${ALTINN_API_KEY} - service: - code: 5748 - edition: 1 - -management: - endpoints: - enabled-by-default: true - web: - base-path: /internal - exposure.include: prometheus,heapdump,health - path-mapping: - prometheus: metrics - endpoint: - prometheus.enabled: true - heapdump.enabled: true - prometheus: - metrics: - export: - enabled: true -server: - servlet: - encoding: - charset: UTF-8 - error: - include-message: always \ No newline at end of file diff --git a/apps/person-organisasjon-tilgang-service/src/main/resources/logback-spring.xml b/apps/person-organisasjon-tilgang-service/src/main/resources/logback-spring.xml deleted file mode 100644 index 4e4897ae999..00000000000 --- a/apps/person-organisasjon-tilgang-service/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - true - - 10280 - 20 - ^sun\.reflect\..*\.invoke - ^net\.sf\.cglib\.proxy\.MethodProxy\.invoke - java\.util\.concurrent\..* - org\.apache\.catalina\..* - org\.apache\.coyote\..* - org\.apache\.tomcat\..* - - - - - - - - - - - - - %d{HH:mm:ss.SSS} | %5p | %logger{25} | %m%n - - utf8 - - - - - - - - - - - - %d{HH:mm:ss.SSS} | %5p | %logger{25} | %m%n - - utf8 - - - - - - - - - \ No newline at end of file diff --git a/apps/person-organisasjon-tilgang-service/src/test/java/no/nav/testnav/apps/persontilgangservice/ApplicationContextTest.java b/apps/person-organisasjon-tilgang-service/src/test/java/no/nav/testnav/apps/persontilgangservice/ApplicationContextTest.java deleted file mode 100644 index 384f37ebae5..00000000000 --- a/apps/person-organisasjon-tilgang-service/src/test/java/no/nav/testnav/apps/persontilgangservice/ApplicationContextTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package no.nav.testnav.apps.persontilgangservice; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.ReactiveJwtDecoder; -import org.springframework.test.context.ActiveProfiles; - -@SpringBootTest -@ActiveProfiles("test") -class ApplicationContextTest { - - @MockBean - public ReactiveJwtDecoder jwtDecoder; - - @Test - @SuppressWarnings("java:S2699") - void load_app_context() { - } -} diff --git a/apps/person-organisasjon-tilgang-service/src/test/java/no/nav/testnav/apps/persontilgangservice/integrationtest/PersonTilgangServiceIntegrationTest.java b/apps/person-organisasjon-tilgang-service/src/test/java/no/nav/testnav/apps/persontilgangservice/integrationtest/PersonTilgangServiceIntegrationTest.java deleted file mode 100644 index c8080baed10..00000000000 --- a/apps/person-organisasjon-tilgang-service/src/test/java/no/nav/testnav/apps/persontilgangservice/integrationtest/PersonTilgangServiceIntegrationTest.java +++ /dev/null @@ -1,101 +0,0 @@ -package no.nav.testnav.apps.persontilgangservice.integrationtest; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import no.nav.testnav.apps.persontilgangservice.controller.dto.OrganisasjonDTO; -import no.nav.testnav.integrationtest.client.TokendingsClient; -import no.nav.testnav.libs.securitycore.domain.AccessToken; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; -import org.springframework.security.oauth2.jwt.JwtDecoder; -import org.springframework.web.reactive.function.client.WebClient; - -import java.io.IOException; -import java.time.LocalDateTime; - -import static java.util.Collections.singletonList; - -@Tag("integration") -class PersonTilgangServiceIntegrationTest { - - private static final String PID = "01810048413"; - public static MockWebServer mockBackEnd; - @MockBean - JwtDecoder jwtDecoder; - private ObjectMapper objectMapper; - private WebClient webClient; - private TokendingsClient tokendingsClient; - - @BeforeAll - static void setUp() throws IOException { - mockBackEnd = new MockWebServer(); - mockBackEnd.start(); - } - - @AfterAll - static void tearDown() throws IOException { - mockBackEnd.shutdown(); - } - - @BeforeEach - void initialize() { - String baseUrl = String.format("http://localhost:%s", - mockBackEnd.getPort()); - tokendingsClient = new TokendingsClient(baseUrl); - webClient = WebClient.builder().baseUrl(baseUrl).build(); - objectMapper = new ObjectMapper(); - objectMapper.registerModule(new JavaTimeModule()); - } - - @Test - void should_get_all_organisasjons_user_has_access_to_and_get_a_single_organisasjon() throws JsonProcessingException { - - mockBackEnd.enqueue( - new MockResponse().setResponseCode(200) - .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) - .setBody(objectMapper.writeValueAsString(new AccessToken("test")))); - // Opprett token for brukeren - var token = tokendingsClient.generateToken("dev-gcp:dolly:testnav-person-organisasjon-tilgang-service", PID).block(); - - mockBackEnd.enqueue( - new MockResponse().setResponseCode(200) - .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) - .setBody(objectMapper.writeValueAsString(singletonList(new OrganisasjonDTO("test", "123", "test", LocalDateTime.now()))))); - // Hent alle organiasjoner brukeren har tilgang til - var organisasjoner = webClient.get() - .uri("/api/v1/person/organisasjoner") - .header(HttpHeaders.AUTHORIZATION, "Bearer " + token.getTokenValue()) - .retrieve() - .bodyToMono(OrganisasjonDTO[].class) - .block(); - - Assertions.assertThat(organisasjoner).isNotEmpty(); - - mockBackEnd.enqueue( - new MockResponse().setResponseCode(200) - .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) - .setBody(objectMapper.writeValueAsString(new OrganisasjonDTO("test", "123", "test", LocalDateTime.now())))); - - // Hent en organisasjon - var organisasjon = webClient.get() - .uri(builder -> builder.path("/api/v1/person/organisasjoner/{organisasjonsnummer}").build(organisasjoner[0].organisasjonsnummer())) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + token.getTokenValue()) - .retrieve() - .bodyToMono(OrganisasjonDTO.class) - .block(); - - Assertions.assertThat(organisasjon).isNotNull(); - } - - -} diff --git a/apps/person-organisasjon-tilgang-service/src/test/resources/application-test.yml b/apps/person-organisasjon-tilgang-service/src/test/resources/application-test.yml deleted file mode 100644 index 7e52003da3c..00000000000 --- a/apps/person-organisasjon-tilgang-service/src/test/resources/application-test.yml +++ /dev/null @@ -1,13 +0,0 @@ -TOKEN_X_ISSUER: dummy -ALTINN_URL: dummy -ALTINN_API_KEY: dummy -MASKINPORTEN_CLIENT_ID: dummy -MASKINPORTEN_CLIENT_JWK: dummy -MASKINPORTEN_SCOPES: dummy -MASKINPORTEN_WELL_KNOWN_URL: dummy - -spring: - cloud: - gcp: - secretmanager: - enabled: false \ No newline at end of file diff --git a/apps/person-organisasjon-tilgang-service/src/test/resources/logback-spring.xml b/apps/person-organisasjon-tilgang-service/src/test/resources/logback-spring.xml deleted file mode 100644 index 328f2de802b..00000000000 --- a/apps/person-organisasjon-tilgang-service/src/test/resources/logback-spring.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - %d{HH:mm:ss.SSS} | %5p | %logger{25} | %m%n - - utf8 - - - - - - - - - - - \ No newline at end of file diff --git a/apps/person-search-service/src/main/resources/application.yml b/apps/person-search-service/src/main/resources/application.yml index 1aecee96702..e2fbb948c45 100644 --- a/apps/person-search-service/src/main/resources/application.yml +++ b/apps/person-search-service/src/main/resources/application.yml @@ -41,12 +41,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/person-service/src/main/resources/application.yml b/apps/person-service/src/main/resources/application.yml index 6a61ab08e39..8c6411c1eaf 100644 --- a/apps/person-service/src/main/resources/application.yml +++ b/apps/person-service/src/main/resources/application.yml @@ -39,12 +39,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/profil-api/config.test.yml b/apps/profil-api/config.test.yml index 82b365c1e24..60428643fbe 100644 --- a/apps/profil-api/config.test.yml +++ b/apps/profil-api/config.test.yml @@ -7,10 +7,10 @@ metadata: team: dolly spec: env: - - name: PERSON_ORG_TILGANG_NAME - value: testnav-person-organisasjon-tilgang-service-dev - - name: PERSON_ORG_TILGANG_URL - value: http://testnav-person-organisasjon-tilgang-service-dev.dolly.svc.cluster.local + - name: ALTINN3_TILGANG_NAME + value: testnav-altinn3-tilgang-service + - name: ALTINN3_TILGANG_URL + value: https://testnav-altinn3-tilgang-service.intern.dev.nav.no image: "{{image}}" tokenx: enabled: true @@ -35,7 +35,7 @@ spec: - application: testnorge-tilbakemelding-api outbound: rules: - - application: testnav-person-organisasjon-tilgang-service-dev + - application: testnav-altinn3-tilgang-service liveness: path: /internal/isAlive initialDelay: 4 diff --git a/apps/profil-api/config.yml b/apps/profil-api/config.yml index 0fafd9f254f..e22cb6b0657 100644 --- a/apps/profil-api/config.yml +++ b/apps/profil-api/config.yml @@ -7,10 +7,10 @@ metadata: team: dolly spec: env: - - name: PERSON_ORG_TILGANG_NAME - value: testnav-person-organisasjon-tilgang-service - - name: PERSON_ORG_TILGANG_URL - value: http://testnav-person-organisasjon-tilgang-service.dolly.svc.cluster.local + - name: ALTINN3_TILGANG_NAME + value: testnav-altinn3-tilgang-proxy + - name: ALTINN3_TILGANG_URL + value: https://testnav-altinn3-tilgang-proxy.intern.dev.nav.no image: "{{image}}" tokenx: enabled: true @@ -35,7 +35,7 @@ spec: - application: testnorge-tilbakemelding-api outbound: rules: - - application: testnav-person-organisasjon-tilgang-service + - application: testnav-altinn3-tilgang-proxy liveness: path: /internal/isAlive initialDelay: 4 diff --git a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/ProfilApiApplicationStarter.java b/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/ProfilApiApplicationStarter.java index ece981fb1f8..a701184e6d8 100644 --- a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/ProfilApiApplicationStarter.java +++ b/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/ProfilApiApplicationStarter.java @@ -1,12 +1,11 @@ package no.nav.registre.testnorge.profil; +import no.nav.testnav.libs.servletcore.config.ApplicationCoreConfig; +import no.nav.testnav.libs.servletsecurity.config.SecureOAuth2ServerToServerConfiguration; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Import; -import no.nav.testnav.libs.servletcore.config.ApplicationCoreConfig; -import no.nav.testnav.libs.servletsecurity.config.SecureOAuth2ServerToServerConfiguration; - @SpringBootApplication @Import({ ApplicationCoreConfig.class, diff --git a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/config/Consumers.java b/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/config/Consumers.java index 121e1e769d9..2b6d64efe27 100644 --- a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/config/Consumers.java +++ b/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/config/Consumers.java @@ -24,6 +24,6 @@ @Setter(PACKAGE) public class Consumers { - private ServerProperties testnavPersonOrganisasjonTilgangService; + private ServerProperties testnavAltinn3TilgangService; } diff --git a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/config/SecurityConfiguration.java b/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/config/SecurityConfiguration.java index 7d810ae9a20..fd9469f6714 100644 --- a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/config/SecurityConfiguration.java +++ b/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/config/SecurityConfiguration.java @@ -2,7 +2,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; import org.springframework.security.config.Customizer; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; @@ -12,7 +11,6 @@ @EnableWebSecurity @Configuration -@Profile({ "dev", "prod" }) public class SecurityConfiguration { @Bean diff --git a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/consumer/AzureAdProfileConsumer.java b/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/consumer/AzureAdProfileConsumer.java index 7f5a0341fc3..d899735893c 100644 --- a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/consumer/AzureAdProfileConsumer.java +++ b/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/consumer/AzureAdProfileConsumer.java @@ -7,7 +7,7 @@ import no.nav.registre.testnorge.profil.service.AzureAdTokenService; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.client.reactive.ReactorClientHttpConnector; -import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; import org.springframework.web.reactive.function.client.ExchangeStrategies; import org.springframework.web.reactive.function.client.WebClient; import reactor.netty.http.client.HttpClient; @@ -17,8 +17,9 @@ import java.util.Optional; @Slf4j -@Component +@Service public class AzureAdProfileConsumer { + private final WebClient webClient; private final AzureAdTokenService azureAdTokenService; @@ -67,7 +68,7 @@ public Optional getProfilImage() { .flatMap(accessToken -> new GetProfileImageCommand(webClient, accessToken.getTokenValue()).call()) .block()); } catch (IllegalStateException e) { - log.warn("Finner ikke profil bilde", e); + log.warn("Finner ikke profilbilde", e); return Optional.empty(); } } diff --git a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/consumer/PersonOrganisasjonTilgangConsumer.java b/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/consumer/PersonOrganisasjonTilgangConsumer.java index 3e1df266723..4e1ee9177f2 100644 --- a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/consumer/PersonOrganisasjonTilgangConsumer.java +++ b/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/consumer/PersonOrganisasjonTilgangConsumer.java @@ -1,19 +1,15 @@ package no.nav.registre.testnorge.profil.consumer; -import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; import no.nav.registre.testnorge.profil.config.Consumers; import no.nav.registre.testnorge.profil.consumer.command.GetPersonOrganisasjonTilgangCommand; -import no.nav.registre.testnorge.profil.consumer.dto.OrganisasjonDTO; +import no.nav.testnav.libs.dto.altinn3.v1.OrganisasjonDTO; import no.nav.testnav.libs.securitycore.domain.ServerProperties; +import no.nav.testnav.libs.securitycore.domain.UserInfo; +import no.nav.testnav.libs.servletsecurity.action.GetUserInfo; import no.nav.testnav.libs.servletsecurity.exchange.TokenExchange; -import org.springframework.http.MediaType; -import org.springframework.http.codec.json.Jackson2JsonDecoder; -import org.springframework.http.codec.json.Jackson2JsonEncoder; import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.client.ExchangeStrategies; import org.springframework.web.reactive.function.client.WebClient; -import org.springframework.web.reactive.function.client.WebClientResponseException; import reactor.core.publisher.Mono; @@ -23,41 +19,32 @@ public class PersonOrganisasjonTilgangConsumer { private final WebClient webClient; private final ServerProperties serverProperties; private final TokenExchange tokenExchange; + private final GetUserInfo getUserInfo; public PersonOrganisasjonTilgangConsumer( Consumers consumers, TokenExchange tokenExchange, - ObjectMapper objectMapper, - WebClient.Builder webClientBuilder - ) { - serverProperties = consumers.getTestnavPersonOrganisasjonTilgangService(); + WebClient.Builder webClientBuilder, + GetUserInfo getUserInfo) { + + serverProperties = consumers.getTestnavAltinn3TilgangService(); this.tokenExchange = tokenExchange; - ExchangeStrategies jacksonStrategy = ExchangeStrategies - .builder() - .codecs( - config -> { - config - .defaultCodecs() - .jackson2JsonEncoder(new Jackson2JsonEncoder(objectMapper, MediaType.APPLICATION_JSON)); - config - .defaultCodecs() - .jackson2JsonDecoder(new Jackson2JsonDecoder(objectMapper, MediaType.APPLICATION_JSON)); - }) - .build(); this.webClient = webClientBuilder - .exchangeStrategies(jacksonStrategy) .baseUrl(serverProperties.getUrl()) .build(); + this.getUserInfo = getUserInfo; } public Mono getOrganisasjon(String organisasjonsnummer) { - return tokenExchange.exchange(serverProperties) - .flatMap(accessToken -> new GetPersonOrganisasjonTilgangCommand(webClient, accessToken.getTokenValue(), organisasjonsnummer).call()) - .onErrorResume( - WebClientResponseException.class::isInstance, - throwable -> { - log.warn("Person har ikke tilgang til organisasjon {}.", organisasjonsnummer); - return Mono.empty(); - }); + + var userId = getUserInfo.call() + .map(UserInfo::id) + .orElse(null); + + return Mono.from(tokenExchange.exchange(serverProperties) + .flatMapMany(accessToken -> + new GetPersonOrganisasjonTilgangCommand(webClient, userId, accessToken.getTokenValue()).call())) + .doOnNext(organisasjon -> log.info("Mottatt organisasjon: {}", organisasjon)) + .filter(organisasjon -> organisasjon.getOrganisasjonsnummer().equals(organisasjonsnummer)); } } diff --git a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/consumer/command/GetPersonOrganisasjonTilgangCommand.java b/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/consumer/command/GetPersonOrganisasjonTilgangCommand.java index b07657f13df..7a0502ebdc1 100644 --- a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/consumer/command/GetPersonOrganisasjonTilgangCommand.java +++ b/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/consumer/command/GetPersonOrganisasjonTilgangCommand.java @@ -1,30 +1,35 @@ package no.nav.registre.testnorge.profil.consumer.command; import lombok.RequiredArgsConstructor; -import no.nav.registre.testnorge.profil.consumer.dto.OrganisasjonDTO; -import no.nav.registre.testnorge.profil.util.WebClientFilter; +import no.nav.registre.testnorge.profil.consumer.dto.AltinnRequestDTO; +import no.nav.testnav.libs.dto.altinn3.v1.OrganisasjonDTO; +import no.nav.testnav.libs.reactivecore.utils.WebClientFilter; import org.springframework.http.HttpHeaders; import org.springframework.web.reactive.function.client.WebClient; -import reactor.core.publisher.Mono; +import reactor.core.publisher.Flux; import reactor.util.retry.Retry; import java.time.Duration; import java.util.concurrent.Callable; @RequiredArgsConstructor -public class GetPersonOrganisasjonTilgangCommand implements Callable> { +public class GetPersonOrganisasjonTilgangCommand implements Callable> { private final WebClient webClient; + private final String ident; private final String token; - private final String organisasjonsnummer; @Override - public Mono call() { + public Flux call() { + return webClient - .get() - .uri(builder -> builder.path("/api/v1/person/organisasjoner/{organisasjonsnummer}").build(organisasjonsnummer)) + .post() + .uri(builder -> builder.path("/api/v1/brukertilgang") + .build()) .header(HttpHeaders.AUTHORIZATION, "Bearer " + token) + .bodyValue(new AltinnRequestDTO(ident)) .retrieve() - .bodyToMono(OrganisasjonDTO.class) + .bodyToFlux(OrganisasjonDTO.class) + .doOnError(WebClientFilter::logErrorMessage) .retryWhen(Retry.backoff(3, Duration.ofSeconds(5)) .filter(WebClientFilter::is5xxException)); } diff --git a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/consumer/command/GetProfileCommand.java b/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/consumer/command/GetProfileCommand.java index f7ef681314c..7d1ae69b933 100644 --- a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/consumer/command/GetProfileCommand.java +++ b/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/consumer/command/GetProfileCommand.java @@ -3,7 +3,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import no.nav.registre.testnorge.profil.consumer.dto.ProfileDTO; -import no.nav.registre.testnorge.profil.util.WebClientFilter; +import no.nav.testnav.libs.reactivecore.utils.WebClientFilter; import org.springframework.http.HttpHeaders; import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Mono; @@ -27,6 +27,7 @@ public Mono call() { .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) .retrieve() .bodyToMono(ProfileDTO.class) + .doOnError(WebClientFilter::logErrorMessage) .retryWhen(Retry.backoff(3, Duration.ofSeconds(5)) .filter(WebClientFilter::is5xxException)); } diff --git a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/consumer/command/GetProfileImageCommand.java b/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/consumer/command/GetProfileImageCommand.java index d4970c7d758..d8a7d5deb89 100644 --- a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/consumer/command/GetProfileImageCommand.java +++ b/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/consumer/command/GetProfileImageCommand.java @@ -2,7 +2,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import no.nav.registre.testnorge.profil.util.WebClientFilter; +import no.nav.testnav.libs.reactivecore.utils.WebClientFilter; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatusCode; import org.springframework.web.reactive.function.client.WebClient; @@ -33,6 +33,7 @@ public Mono call() { .map(IllegalStateException::new) ) .bodyToMono(byte[].class) + .doOnError(WebClientFilter::logErrorMessage) .retryWhen(Retry.backoff(3, Duration.ofSeconds(5)) .filter(WebClientFilter::is5xxException)); } diff --git a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/consumer/dto/AltinnRequestDTO.java b/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/consumer/dto/AltinnRequestDTO.java new file mode 100644 index 00000000000..e2b884a63dc --- /dev/null +++ b/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/consumer/dto/AltinnRequestDTO.java @@ -0,0 +1,13 @@ +package no.nav.registre.testnorge.profil.consumer.dto; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class AltinnRequestDTO { + + private String ident; +} diff --git a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/consumer/dto/OrganisasjonDTO.java b/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/consumer/dto/OrganisasjonDTO.java deleted file mode 100644 index 2c53b8ece95..00000000000 --- a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/consumer/dto/OrganisasjonDTO.java +++ /dev/null @@ -1,14 +0,0 @@ -package no.nav.registre.testnorge.profil.consumer.dto; - -import com.fasterxml.jackson.annotation.JsonInclude; - -import java.time.LocalDateTime; - -@JsonInclude(JsonInclude.Include.NON_NULL) -public record OrganisasjonDTO( - String navn, - String organisasjonsnummer, - String organisasjonsfrom, - LocalDateTime gyldigTil -) { -} diff --git a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/provider/ProfilController.java b/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/provider/ProfilController.java index 8bcfaaac7b8..e08430b3218 100644 --- a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/provider/ProfilController.java +++ b/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/provider/ProfilController.java @@ -33,7 +33,7 @@ public ResponseEntity getProfile() { } @GetMapping(value = "/bilde", produces = MediaType.IMAGE_JPEG_VALUE) - public ResponseEntity getImage() { + public ResponseEntity getImage() { return profilService .getImage() .map(value -> ResponseEntity.ok().cacheControl(cacheControl).body(value)) diff --git a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/service/AzureAdTokenService.java b/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/service/AzureAdTokenService.java index f262be55d05..0efac636604 100644 --- a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/service/AzureAdTokenService.java +++ b/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/service/AzureAdTokenService.java @@ -1,7 +1,10 @@ package no.nav.registre.testnorge.profil.service; import lombok.extern.slf4j.Slf4j; +import no.nav.testnav.libs.securitycore.command.azuread.OnBehalfOfExchangeCommand; +import no.nav.testnav.libs.securitycore.domain.AccessToken; import no.nav.testnav.libs.securitycore.domain.azuread.AzureClientCredential; +import no.nav.testnav.libs.servletsecurity.action.GetAuthenticatedToken; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; @@ -14,10 +17,6 @@ import java.net.URI; -import no.nav.testnav.libs.securitycore.command.azuread.OnBehalfOfExchangeCommand; -import no.nav.testnav.libs.securitycore.domain.AccessToken; -import no.nav.testnav.libs.servletsecurity.action.GetAuthenticatedToken; - @Slf4j @Service public class AzureAdTokenService { diff --git a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/service/ProfilService.java b/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/service/ProfilService.java index e522e02a5aa..d139f556c3f 100644 --- a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/service/ProfilService.java +++ b/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/service/ProfilService.java @@ -25,15 +25,16 @@ public class ProfilService { public Profil getProfile() { if (isTokenX()) { - return getUserInfo.call().map(userInfo -> + return getUserInfo.call() + .map(userInfo -> organisasjonTilgangConsumer .getOrganisasjon(userInfo.organisasjonsnummer()) .map(dto -> new Profil( userInfo.brukernavn(), UKJENT, UKJENT, - dto.navn(), - dto.organisasjonsnummer(), + dto.getNavn(), + dto.getOrganisasjonsnummer(), BANK_ID) ).block() ).orElse(new Profil( diff --git a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/util/WebClientFilter.java b/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/util/WebClientFilter.java deleted file mode 100644 index 97dd7df99ea..00000000000 --- a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/util/WebClientFilter.java +++ /dev/null @@ -1,14 +0,0 @@ -package no.nav.registre.testnorge.profil.util; - -import lombok.experimental.UtilityClass; -import org.springframework.web.reactive.function.client.WebClientResponseException; - -@UtilityClass -public class WebClientFilter { - - public static boolean is5xxException(Throwable throwable) { - - return throwable instanceof WebClientResponseException wce && - wce.getStatusCode().is5xxServerError(); - } -} diff --git a/apps/profil-api/src/main/resources/application-local.yml b/apps/profil-api/src/main/resources/application-local.yml index ab2961d30c7..e2e00d9b43f 100644 --- a/apps/profil-api/src/main/resources/application-local.yml +++ b/apps/profil-api/src/main/resources/application-local.yml @@ -1,10 +1,15 @@ AZURE_APP_CLIENT_ID: ${sm://azure-app-client-id} AZURE_APP_CLIENT_SECRET: ${sm://azure-app-client-secret} +TOKEN_X_ISSUER: https://tokenx.dev-gcp.nav.cloud.nais.io +TOKEN_X_JWKS_URI: https://tokenx.dev-gcp.nav.cloud.nais.io +TOKEN_X_CLIENT_ID: dev-gcp:dolly:testnorge-profil-api-dev + spring: config: import: "sm://" consumers: - testnav-person-organisasjon-tilgang-service: - url: https://testnav-person-organisasjon-tilgang-service-dev.dev.intern.nav.no + testnav-altinn3-tilgang-service: + name: testnav-altinn3-tilgang-service + url: https://testnav-altinn3-tilgang-service.intern.dev.nav.no diff --git a/apps/profil-api/src/main/resources/application.yml b/apps/profil-api/src/main/resources/application.yml index 4c9b6cac076..7e343630c04 100644 --- a/apps/profil-api/src/main/resources/application.yml +++ b/apps/profil-api/src/main/resources/application.yml @@ -30,23 +30,24 @@ access.scopes: api.azuread.url: https://graph.microsoft.com consumers: - testnav-person-organisasjon-tilgang-service: + testnav-altinn3-tilgang-service: cluster: dev-gcp namespace: dolly - name: ${PERSON_ORG_TILGANG_NAME} - url: ${PERSON_ORG_TILGANG_URL} + name: ${ALTINN3_TILGANG_NAME} + url: ${ALTINN3_TILGANG_URL} management: endpoints: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/profil-api/src/test/resources/application-test.yml b/apps/profil-api/src/test/resources/application-test.yml index bf7cc5cb0e7..aa8bfa92394 100644 --- a/apps/profil-api/src/test/resources/application-test.yml +++ b/apps/profil-api/src/test/resources/application-test.yml @@ -4,11 +4,4 @@ spring: cloud: gcp: secretmanager: - enabled: false - -consumers: - testnav-person-organisasjon-tilgang-service: - cluster: cluster - namespace: namespace - name: name - url: http://valid.but.not.used + enabled: false \ No newline at end of file diff --git a/apps/skattekort-service/src/main/resources/application.yml b/apps/skattekort-service/src/main/resources/application.yml index 51e2bcada96..72a52109bee 100644 --- a/apps/skattekort-service/src/main/resources/application.yml +++ b/apps/skattekort-service/src/main/resources/application.yml @@ -23,12 +23,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/sykemelding-api/src/main/resources/application.yml b/apps/sykemelding-api/src/main/resources/application.yml index f1e9d0240b5..b49e9a7862a 100644 --- a/apps/sykemelding-api/src/main/resources/application.yml +++ b/apps/sykemelding-api/src/main/resources/application.yml @@ -31,12 +31,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/synt-sykemelding-api/src/main/resources/application.yml b/apps/synt-sykemelding-api/src/main/resources/application.yml index a9ff3f6ba65..70e49cef899 100644 --- a/apps/synt-sykemelding-api/src/main/resources/application.yml +++ b/apps/synt-sykemelding-api/src/main/resources/application.yml @@ -59,12 +59,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/synt-vedtakshistorikk-service/src/main/resources/application.yml b/apps/synt-vedtakshistorikk-service/src/main/resources/application.yml index 12285d7ae0a..3ab20446b84 100644 --- a/apps/synt-vedtakshistorikk-service/src/main/resources/application.yml +++ b/apps/synt-vedtakshistorikk-service/src/main/resources/application.yml @@ -65,12 +65,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/tenor-search-service/src/main/resources/application.yml b/apps/tenor-search-service/src/main/resources/application.yml index 765f641ea55..72f6aa800c2 100644 --- a/apps/tenor-search-service/src/main/resources/application.yml +++ b/apps/tenor-search-service/src/main/resources/application.yml @@ -29,12 +29,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/testnav-ident-pool/src/main/resources/application.yml b/apps/testnav-ident-pool/src/main/resources/application.yml index eec84e92cc7..50680851ade 100644 --- a/apps/testnav-ident-pool/src/main/resources/application.yml +++ b/apps/testnav-ident-pool/src/main/resources/application.yml @@ -15,12 +15,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/testnorge-statisk-data-forvalter/src/main/resources/application.yml b/apps/testnorge-statisk-data-forvalter/src/main/resources/application.yml index fb9d79b9227..52b818eb1db 100644 --- a/apps/testnorge-statisk-data-forvalter/src/main/resources/application.yml +++ b/apps/testnorge-statisk-data-forvalter/src/main/resources/application.yml @@ -83,12 +83,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/tilbakemelding-api/src/main/resources/application.yml b/apps/tilbakemelding-api/src/main/resources/application.yml index f90336663c1..fdf868899a9 100644 --- a/apps/tilbakemelding-api/src/main/resources/application.yml +++ b/apps/tilbakemelding-api/src/main/resources/application.yml @@ -38,12 +38,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/tps-messaging-service/src/main/resources/application.yml b/apps/tps-messaging-service/src/main/resources/application.yml index c36f3d7945a..b7c23264167 100644 --- a/apps/tps-messaging-service/src/main/resources/application.yml +++ b/apps/tps-messaging-service/src/main/resources/application.yml @@ -50,12 +50,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true health: show-details: always health: diff --git a/apps/udi-stub/src/main/resources/application.yml b/apps/udi-stub/src/main/resources/application.yml index 0072dcc00e8..6d4f4085497 100644 --- a/apps/udi-stub/src/main/resources/application.yml +++ b/apps/udi-stub/src/main/resources/application.yml @@ -33,12 +33,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/apps/varslinger-service/src/main/resources/application.yml b/apps/varslinger-service/src/main/resources/application.yml index 2308249ef43..55331eeaa37 100644 --- a/apps/varslinger-service/src/main/resources/application.yml +++ b/apps/varslinger-service/src/main/resources/application.yml @@ -29,12 +29,13 @@ management: enabled-by-default: true web: base-path: /internal - exposure.include: prometheus,heapdump,health + exposure: + include: prometheus,health path-mapping: prometheus: metrics endpoint: - prometheus.enabled: true - heapdump.enabled: true + prometheus: + enabled: true prometheus: metrics: export: diff --git a/docker-compose.yml b/docker-compose.yml index f917991a0db..f20d218d0a0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,13 +1,13 @@ services: - testnav-person-organisasjon-tilgang-service: - container_name: testnav-person-organisasjon-tilgang-service + testnav-altinn3-tilgang-service: + container_name: testnav-altinn3-tilgang-service environment: - SPRING_PROFILES_ACTIVE=virtual - JAVA_TOOL_OPTIONS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 - TOKEN_X_PRIVATE_JWK=${JWK} - MASKINPORTEN_CLIENT_JWK=${JWK} build: - context: ./apps/person-organisasjon-tilgang-service + context: ./apps/testnav-altinn3-tilgang-service depends_on: - tokendings - maskinporten @@ -54,7 +54,7 @@ services: context: ./apps/bruker-service depends_on: - testnav-bruker-service-db - - testnav-person-organisasjon-tilgang-service + - testnav-altinn3-tilgang-service - tokendings ports: - "8002:8080" diff --git a/docs/solution-description/azure-ad-og-z-ident.md b/docs/solution-description/azure-ad-og-z-ident.md index faf91d76a7c..ee5139cf616 100644 --- a/docs/solution-description/azure-ad-og-z-ident.md +++ b/docs/solution-description/azure-ad-og-z-ident.md @@ -75,9 +75,3 @@ Med access_tokene, som brukes i kommunikasjon fra frontend til backend, vil back Det betyr at vi kan bruke dagens mekanismer for å hente ut epost istedenfor for Z-bruker i Dolly. I Dolly frontend vil vi nå ha mulighet til å hente ut personlige informasjon om brukeren. Som epost, navn osv... som vil hjelpe oss til bedre feilsøkning, og være et steg i å kunne hjelpe personer utenfor NAV. - -### Migererig fra Z-Bruker - -I en periode vil vi legge til funksjonalitet for å kunne kopiere en Z-bruker over til din personlige bruker. På den måten vil ingen miste allerede opprettede brukere. - -[Prototype](https://invis.io/ENXCGRI6XD8#/429665609_Innlogging_Personlig_ident_1) \ No newline at end of file diff --git a/proxies/altinn3-tilgang-proxy/config.yml b/proxies/altinn3-tilgang-proxy/config.yml index 286fa0d5ab3..700fe0a5b05 100644 --- a/proxies/altinn3-tilgang-proxy/config.yml +++ b/proxies/altinn3-tilgang-proxy/config.yml @@ -26,6 +26,7 @@ spec: - application: dolly-frontend - application: dolly-idporten - application: testnav-bruker-service + - application: testnorge-profil-api outbound: external: - host: testnav-altinn3-tilgang-service.nav.no