Skip to content

Commit

Permalink
Bruk veilarbperson gcp (#196)
Browse files Browse the repository at this point in the history
* Endret discovery urlen til veilarbperson

* Endret urlen til veilarbperson i dev-gcp-yaml

* La til /veilarbperson til urlen i VeilarbpersonClient

* Legger på bearer før token mot veilarbperson (#195)

* Endret lenke til norg2

* La til norg2Url til Environment properties

* Endret clientconfigun til api oppgave for å hente urlene fra yaml og bruke onbehalfof token istedenfor machinetomachine token

* Bruker predefinert funksjonen istedenfor hardkode bearer

* Endret urlen til app oppgave for å gå mot q2 i dev

* La til norg2 og oppgave urlene til env

* Slettet ubrukt DownstreamApis

* Endret urlen til veilarbperson i dev-gcp-yaml

* La til /veilarbperson til urlen i VeilarbpersonClient

* Legger på bearer før token mot veilarbperson (#195)

* Endret lenke til norg2

* La til norg2Url til Environment properties

* Endret clientconfigun til api oppgave for å hente urlene fra yaml og bruke onbehalfof token istedenfor machinetomachine token

* Bruker predefinert funksjonen istedenfor hardkode bearer

* Endret urlen til app oppgave for å gå mot q2 i dev

* La til norg2 og oppgave urlene til env

* Slettet ubrukt DownstreamApis

---------

Co-authored-by: Julie Hill Roa <[email protected]>
  • Loading branch information
sneha-d-desai and JulieHillRoa authored Sep 27, 2024
1 parent 5cff49b commit 2b927c1
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 37 deletions.
13 changes: 11 additions & 2 deletions .nais/application/application-config-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ spec:
namespace: poao
- application: veilarbperson
namespace: obo
- application: norg2
namespace: org
external:
- host: pdl-api.dev-fss-pub.nais.io
- host: norg2.dev-fss-pub.nais.io
- host: oppgave-q1.dev-fss-pub.nais.io
- host: oppgave.dev-fss-pub.nais.io
env:
- name: POAO_TILGANG_URL
value: http://poao-tilgang.poao
Expand All @@ -56,6 +57,14 @@ spec:
value: http://veilarbperson.obo/veilarbperson
- name: VEILARBPERSON_SCOPE
value: api://dev-gcp.obo.veilarbperson/.default
- name: NORG2_URL
value: http://norg2.org/norg2
- name: NORG2_SCOPE
value: api://dev-gcp.org.norg2/.default
- name: OPPGAVE_URL
value: https://oppgave.dev-fss-pub.nais.io
- name: OPPGAVE_SCOPE
value: api://dev-fss.oppgavehandtering.oppgave/.default
prometheus:
enabled: true
path: veilarboppgave/internal/prometheus
Expand Down
11 changes: 10 additions & 1 deletion .nais/application/application-config-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ spec:
namespace: poao
- application: veilarbperson
namespace: obo
- application: norg2
namespace: org
external:
- host: pdl-api.prod-fss-pub.nais.io
- host: norg2.prod-fss-pub.nais.io
- host: oppgave.prod-fss-pub.nais.io
env:
- name: POAO_TILGANG_URL
Expand All @@ -53,6 +54,14 @@ spec:
value: http://veilarbperson.obo/veilarbperson
- name: VEILARBPERSON_SCOPE
value: api://prod-gcp.obo.veilarbperson/.default
- name: NORG2_URL
value: http://norg2.org/norg2
- name: NORG2_SCOPE
value: api://prod-gcp.org.norg2/.default
- name: OPPGAVE_URL
value: https://oppgave.prod-fss-pub.nais.io
- name: OPPGAVE_SCOPE
value: api://prod-fss.oppgavehandtering.oppgave/.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, bearerTokenFromSupplier(userTokenSupplier))
.header("X-Correlation-Id", correlationId)
.post(RestUtils.toJsonRequestBody(opprettOppgaveRequest))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.function.Supplier;

import static no.nav.common.utils.UrlUtils.joinPaths;
import static no.nav.veilarboppgave.util.RestUtils.bearerTokenFromSupplier;
import static org.springframework.http.HttpHeaders.ACCEPT;
import static org.springframework.http.HttpHeaders.AUTHORIZATION;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
Expand All @@ -40,7 +41,7 @@ public Personalia hentPersonalia(Fnr fnr, String behandlingsnummer) {
Request request = new Request.Builder()
.url(joinPaths(veilarbpersonUrl, "/api/v3/hent-person"))
.header(ACCEPT, APPLICATION_JSON_VALUE)
.header(AUTHORIZATION, "Bearer " + userTokenSupplier.get())
.header(AUTHORIZATION, bearerTokenFromSupplier(userTokenSupplier))
.post(RestUtils.toJsonRequestBody(new PersonRequest(fnr, behandlingsnummer)))
.build();

Expand Down
28 changes: 6 additions & 22 deletions src/main/java/no/nav/veilarboppgave/config/ClientConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,9 @@
import no.nav.veilarboppgave.client.oppgave.OppgaveClientImpl;
import no.nav.veilarboppgave.client.veilarbperson.VeilarbpersonClient;
import no.nav.veilarboppgave.client.veilarbperson.VeilarbpersonClientImpl;
import no.nav.veilarboppgave.service.ContextAwareService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.function.Supplier;

import static no.nav.veilarboppgave.config.DownstreamApis.downstreamOppgave;

@Configuration
public class ClientConfig {

Expand All @@ -45,31 +40,20 @@ public CachedAktorOppslagClient aktorOppslagClient(MachineToMachineTokenClient t

@Bean
public Norg2Client norg2Client(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 CachedNorg2Client(new NorgHttp2Client(url));
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
10 changes: 0 additions & 10 deletions src/main/java/no/nav/veilarboppgave/config/DownstreamApis.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,10 @@ public class EnvironmentProperties {

private String veilarbpersonScope;

private String norg2Url;

private String oppgaveUrl;

private String oppgaveScope;

}
3 changes: 3 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ app.env.poaoTilgangUrl=${POAO_TILGANG_URL:#{null}}
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 2b927c1

Please sign in to comment.