-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TFP-5952 AntiABAC fase 1, regler og struktur
- Loading branch information
Showing
28 changed files
with
1,381 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...abac-kontekst/src/main/java/no/nav/foreldrepenger/sikkerhet/populasjon/TilgangKlient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package no.nav.foreldrepenger.sikkerhet.populasjon; | ||
|
||
import java.net.URI; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.ws.rs.core.UriBuilder; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import no.nav.vedtak.felles.integrasjon.rest.FpApplication; | ||
import no.nav.vedtak.felles.integrasjon.rest.RestClient; | ||
import no.nav.vedtak.felles.integrasjon.rest.RestClientConfig; | ||
import no.nav.vedtak.felles.integrasjon.rest.RestConfig; | ||
import no.nav.vedtak.felles.integrasjon.rest.RestRequest; | ||
import no.nav.vedtak.felles.integrasjon.rest.TokenFlow; | ||
import no.nav.vedtak.sikkerhet.abac.policy.Tilgangsvurdering; | ||
import no.nav.vedtak.sikkerhet.populasjon.PopulasjonEksternRequest; | ||
import no.nav.vedtak.sikkerhet.populasjon.PopulasjonInternRequest; | ||
import no.nav.vedtak.sikkerhet.populasjon.PopulasjonKlient; | ||
|
||
@ApplicationScoped | ||
@RestClientConfig(tokenConfig = TokenFlow.AZUREAD_CC, application = FpApplication.FPTILGANG) | ||
public class TilgangKlient implements PopulasjonKlient { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(TilgangKlient.class); | ||
|
||
private final URI internBrukerUri; | ||
|
||
private final URI eksternBrukerUri; | ||
private final RestClient klient; | ||
private final RestConfig restConfig; | ||
|
||
public TilgangKlient() { | ||
this.klient = RestClient.client(); | ||
this.restConfig = RestConfig.forClient(this.getClass()); | ||
this.internBrukerUri = UriBuilder.fromUri(restConfig.fpContextPath()) | ||
.path("/api/populasjon/internbruker") | ||
.build(); | ||
this.eksternBrukerUri = UriBuilder.fromUri(restConfig.fpContextPath()) | ||
.path("/api/populasjon/eksternbruker") | ||
.build(); | ||
} | ||
|
||
@Override | ||
public Tilgangsvurdering vurderTilgang(PopulasjonInternRequest request) { | ||
var rrequest = RestRequest.newPOSTJson(request, internBrukerUri, restConfig); | ||
//return klient.send(rrequest, Tilgangsvurdering.class); | ||
return Tilgangsvurdering.godkjenn(); | ||
} | ||
|
||
@Override | ||
public Tilgangsvurdering vurderTilgang(PopulasjonEksternRequest request) { | ||
var rrequest = RestRequest.newPOSTJson(request, eksternBrukerUri, restConfig); | ||
//return klient.send(rrequest, Tilgangsvurdering.class); | ||
return Tilgangsvurdering.godkjenn(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
felles/abac/src/main/java/no/nav/vedtak/sikkerhet/abac/PdpRequestBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,39 @@ | ||
package no.nav.vedtak.sikkerhet.abac; | ||
|
||
import no.nav.vedtak.sikkerhet.abac.internal.BeskyttetRessursAttributter; | ||
import no.nav.vedtak.sikkerhet.abac.pdp.AppRessursData; | ||
import no.nav.vedtak.sikkerhet.abac.policy.Tilgangsvurdering; | ||
|
||
/** | ||
* Dette grensesnittet må implementeres av alle applikasjoner: | ||
* - Alle må implementere lagAppRessursData | ||
* - De applikasjonene (tilbake, inntektsmelding) som skal kalle K9 sin PDP/abac må implementere abacDomene | ||
* - | ||
*/ | ||
public interface PdpRequestBuilder { | ||
|
||
default String abacDomene() { | ||
return "foreldrepenger"; | ||
} | ||
|
||
AppRessursData lagAppRessursData(AbacDataAttributter dataAttributter); | ||
|
||
// Trenger egentlig bare sette BEHANDLING_STATUS + FAGSAK_STATUS i tilfelle FAGSAK / UPDATE for skrivetilgangs-sjekk | ||
default AppRessursData lagAppRessursDataForSystembruker(AbacDataAttributter dataAttributter) { | ||
return lagAppRessursData(dataAttributter); | ||
} | ||
|
||
|
||
default boolean skalVurdereTilgangLokalt(BeskyttetRessursAttributter beskyttetRessursAttributter, AppRessursData appRessursData) { | ||
return false; | ||
} | ||
|
||
// Fortsette med vanlig tilgangskontroll eller bruke svar fra lokal vurdering | ||
default boolean kunLokalVurdering(BeskyttetRessursAttributter beskyttetRessursAttributter, AppRessursData appRessursData) { | ||
return false; | ||
} | ||
|
||
default Tilgangsvurdering vurderTilgangLokalt(BeskyttetRessursAttributter beskyttetRessursAttributter, AppRessursData appRessursData) { | ||
throw new IllegalArgumentException("Utviklerfeil: viser lokal tilgangsvurdering, men ikke implementert metode"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
felles/abac/src/main/java/no/nav/vedtak/sikkerhet/abac/PopulasjonsTilgang.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package no.nav.vedtak.sikkerhet.abac; | ||
|
||
import no.nav.vedtak.sikkerhet.abac.internal.BeskyttetRessursAttributter; | ||
import no.nav.vedtak.sikkerhet.abac.pdp.AppRessursData; | ||
import no.nav.vedtak.sikkerhet.abac.policy.Tilgangsvurdering; | ||
|
||
public interface PopulasjonsTilgang { | ||
|
||
Tilgangsvurdering vurderTilgang(BeskyttetRessursAttributter beskyttetRessursAttributter, AppRessursData appRessursData); | ||
|
||
} |
Oops, something went wrong.