Skip to content

Commit

Permalink
Merge pull request #437 from navikt/dev
Browse files Browse the repository at this point in the history
Prodsetting
  • Loading branch information
stianStensli authored Sep 26, 2022
2 parents 74de853 + 98017d9 commit 6a99e85
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

<properties>
<java.version>11</java.version>
<common.version>2.2022.07.01_07.12-6a0864fa6938</common.version>
<tjenestespesifikasjoner.version>1.2019.04.03-23.09-56488320520a</tjenestespesifikasjoner.version>
<common.version>2.2022.09.15_07.46-e4fa96eb6813</common.version>
<tjenestespesifikasjoner.version>1.2019.09.25-00.21-49b69f0625e0</tjenestespesifikasjoner.version>
<testcontainers.version>1.16.3</testcontainers.version>
</properties>

Expand Down Expand Up @@ -112,7 +112,7 @@
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>4.0.3</version>
<version>4.2.0</version>
</dependency>
<dependency>
<groupId>com.oracle.ojdbc</groupId>
Expand All @@ -122,7 +122,7 @@
<dependency>
<groupId>net.javacrumbs.shedlock</groupId>
<artifactId>shedlock-provider-jdbc-template</artifactId>
<version>4.36.0</version>
<version>4.37.0</version>
</dependency>

<!-- Tjenestespesifikasjoner -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down
20 changes: 9 additions & 11 deletions src/main/java/no/nav/veilarboppfolging/config/ClientConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit 6a99e85

Please sign in to comment.