Skip to content

Commit

Permalink
Endret clientconfigun til api oppgave for å hente urlene fra yaml og …
Browse files Browse the repository at this point in the history
…bruke onbehalfof token istedenfor machinetomachine token
  • Loading branch information
sneha-d-desai committed Sep 25, 2024
1 parent 2f5b2a3 commit 096405e
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
4 changes: 4 additions & 0 deletions .nais/application/application-config-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ spec:
value: http://norg2.org/norg2
- name: NORG2_SCOPE
value: api://dev-gcp.org.norg2/.default
- name: OPPGAVE_URL
value: https://oppgave-q1.dev-fss-pub.nais.io/api/v1/oppgaver
- name: OPPGAVE_SCOPE
value: api://dev-fss.oppgavehandtering.oppgave-q1/.default
prometheus:
enabled: true
path: veilarboppgave/internal/prometheus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public Optional<OppgaveId> opprettOppgave(Oppgave oppgave) {
Request request = new Request.Builder()
.url(joinPaths(oppgaveUrl, "/api/v1/oppgaver"))
.header(ACCEPT, APPLICATION_JSON_VALUE)
.header(AUTHORIZATION, userTokenSupplier.get())
.header(AUTHORIZATION, "Bearer " + userTokenSupplier.get())
.header("X-Correlation-Id", correlationId)
.post(RestUtils.toJsonRequestBody(opprettOppgaveRequest))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public VeilarbpersonClientImpl(String veilarbpersonUrl, Supplier<String> userTok
@Override
public Personalia hentPersonalia(Fnr fnr, String behandlingsnummer) {
Request request = new Request.Builder()
.url(joinPaths(veilarbpersonUrl, "/veilarbperson/api/v3/hent-person"))
.url(joinPaths(veilarbpersonUrl, "/api/v3/hent-person"))
.header(ACCEPT, APPLICATION_JSON_VALUE)
.header(AUTHORIZATION, "Bearer " + userTokenSupplier.get())
.post(RestUtils.toJsonRequestBody(new PersonRequest(fnr, behandlingsnummer)))
Expand Down
21 changes: 6 additions & 15 deletions src/main/java/no/nav/veilarboppgave/config/ClientConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,29 +45,20 @@ public CachedAktorOppslagClient aktorOppslagClient(MachineToMachineTokenClient t

@Bean
public Norg2Client norg2Client(EnvironmentProperties properties) {
return new CachedNorg2Client(new NorgHttp2Client(
properties.getNorg2Url()));
return new CachedNorg2Client(new NorgHttp2Client(properties.getNorg2Url()));
}

@Bean
public Norg2ArbeidsfordelingClient norg2ArbeidsfordelingClient(EnvironmentProperties properties) {
String url = EnvironmentUtils.isDevelopment().orElse(false)
? "https://norg2.dev-fss-pub.nais.io/norg2"
: "https://norg2.prod-fss-pub.nais.io/norg2";
return new Norg2ArbeidsfordelingClientImpl(url);
return new Norg2ArbeidsfordelingClientImpl(properties.getNorg2Url());
}

@Bean
public OppgaveClient oppgaveClient(ContextAwareService contextAwareService) {
String safCluster = isProduction() ? "prod-fss" : "dev-fss";
Supplier<String> userTokenSupplier = contextAwareService.contextAwareUserTokenSupplier(
downstreamOppgave(safCluster)
public OppgaveClient oppgaveClient(EnvironmentProperties properties, AzureAdOnBehalfOfTokenClient tokenClient, AuthContextHolder authContextHolder) {
return new OppgaveClientImpl(
properties.getOppgaveUrl(),
() -> tokenClient.exchangeOnBehalfOfToken(properties.getOppgaveScope(), authContextHolder.requireIdTokenString())
);
String url = EnvironmentUtils.isDevelopment().orElse(false)
? "https://oppgave-q1.dev-fss-pub.nais.io"
: "https://oppgave.prod-fss-pub.nais.io";

return new OppgaveClientImpl(url, userTokenSupplier);
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ public class EnvironmentProperties {

private String norg2Url;

private String oppgaveUrl;

private String oppgaveScope;

}
2 changes: 2 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ app.env.poaoTilgangScope=${POAO_TILGANG_SCOPE:#{null}}
app.env.veilarbpersonUrl=${VEILARBPERSON_URL:#{null}}
app.env.veilarbpersonScope=${VEILARBPERSON_SCOPE:#{null}}
app.env.norg2Url=${NORG2_URL:#{null}}
app.env.oppgaveUrl=${OPPGAVE_URL:#{null}}
app.env.oppgaveScope=${OPPGAVE_SCOPE:#{null}}

app.env.dbUrl=${DB_JDBC_URL}

0 comments on commit 096405e

Please sign in to comment.