diff --git a/pom.xml b/pom.xml index 99ed0b22a..3c5eea991 100644 --- a/pom.xml +++ b/pom.xml @@ -19,8 +19,8 @@ 11 - 2.2022.07.01_07.12-6a0864fa6938 - 1.2019.04.03-23.09-56488320520a + 2.2022.09.15_07.46-e4fa96eb6813 + 1.2019.09.25-00.21-49b69f0625e0 1.16.3 @@ -112,7 +112,7 @@ org.flywaydb flyway-core - 4.0.3 + 4.2.0 com.oracle.ojdbc @@ -122,7 +122,7 @@ net.javacrumbs.shedlock shedlock-provider-jdbc-template - 4.36.0 + 4.37.0 diff --git a/src/main/java/no/nav/veilarboppfolging/config/ApplicationConfig.java b/src/main/java/no/nav/veilarboppfolging/config/ApplicationConfig.java index 27fe698f9..23b9c3d3a 100644 --- a/src/main/java/no/nav/veilarboppfolging/config/ApplicationConfig.java +++ b/src/main/java/no/nav/veilarboppfolging/config/ApplicationConfig.java @@ -21,6 +21,8 @@ import no.nav.common.sts.NaisSystemUserTokenProvider; import no.nav.common.sts.OpenAmSystemUserTokenProvider; import no.nav.common.sts.SystemUserTokenProvider; +import no.nav.common.token_client.builder.AzureAdTokenClientBuilder; +import no.nav.common.token_client.client.AzureAdMachineToMachineTokenClient; import no.nav.common.utils.Credentials; import no.nav.common.utils.NaisUtils; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -85,6 +87,12 @@ public SystemUserTokenProvider systemUserTokenProvider(EnvironmentProperties pro return new NaisSystemUserTokenProvider(properties.getNaisStsDiscoveryUrl(), serviceUserCredentials.username, serviceUserCredentials.password); } + @Bean + public AzureAdMachineToMachineTokenClient azureAdMachineToMachineTokenClient() { + return AzureAdTokenClientBuilder.builder() + .withNaisDefaults() + .buildMachineToMachineTokenClient(); + } @Bean public static StsConfig stsConfig(EnvironmentProperties properties, Credentials serviceUserCredentials) { return StsConfig.builder() diff --git a/src/main/java/no/nav/veilarboppfolging/config/ClientConfig.java b/src/main/java/no/nav/veilarboppfolging/config/ClientConfig.java index 35e1f23d2..b6bef1f86 100644 --- a/src/main/java/no/nav/veilarboppfolging/config/ClientConfig.java +++ b/src/main/java/no/nav/veilarboppfolging/config/ClientConfig.java @@ -6,11 +6,11 @@ import no.nav.common.client.norg2.CachedNorg2Client; import no.nav.common.client.norg2.Norg2Client; import no.nav.common.client.norg2.NorgHttp2Client; -import no.nav.common.client.pdl.PdlClientImpl; import no.nav.common.cxf.StsConfig; import no.nav.common.sts.SystemUserTokenProvider; import no.nav.common.token_client.builder.AzureAdTokenClientBuilder; import no.nav.common.token_client.client.AzureAdOnBehalfOfTokenClient; +import no.nav.common.token_client.client.MachineToMachineTokenClient; import no.nav.common.utils.EnvironmentUtils; import no.nav.common.utils.UrlUtils; import no.nav.veilarboppfolging.client.behandle_arbeidssoker.BehandleArbeidssokerClient; @@ -31,18 +31,16 @@ public class ClientConfig { @Bean - public AktorOppslagClient aktorOppslagClient(SystemUserTokenProvider systemUserTokenProvider) { - final String PDL_URL = "pdl-api"; - String pdlUrl = isProduction() - ? createProdInternalIngressUrl(PDL_URL) - : createDevInternalIngressUrl(PDL_URL); + public AktorOppslagClient aktorOppslagClient(MachineToMachineTokenClient tokenClient) { + String tokenScop = String.format("api://%s-fss.pdl.pdl-api/.default", + isProduction() ? "prod" : "dev" + ); - PdlClientImpl pdlClient = new PdlClientImpl( - pdlUrl, - systemUserTokenProvider::getSystemUserToken, - systemUserTokenProvider::getSystemUserToken); + PdlAktorOppslagClient pdlClient = new PdlAktorOppslagClient( + createServiceUrl("pdl-api", "pdl", false), + () -> tokenClient.createMachineToMachineToken(tokenScop)); - return new CachedAktorOppslagClient(new PdlAktorOppslagClient(pdlClient)); + return new CachedAktorOppslagClient(pdlClient); } @Bean