Skip to content

Commit

Permalink
Fjerner try-catch og introdusere residentCluster og residentNamespace
Browse files Browse the repository at this point in the history
  • Loading branch information
espenwaaga committed Apr 25, 2023
1 parent 2bbea50 commit 23ec04a
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public class PepImpl implements Pep {
private Set<String> pipUsers;
private TokenProvider tokenProvider;
private String preAuthorized;
private Cluster residentCluster;
private String residentNamespace;

public PepImpl() {
}
Expand All @@ -46,6 +48,8 @@ public PepImpl(PdpKlient pdpKlient,
this.tokenProvider = tokenProvider;
this.pipUsers = konfigurePipUsers(pipUsers);
this.preAuthorized = ENV.getProperty(AzureProperty.AZURE_APP_PRE_AUTHORIZED_APPS.name()); // eg json array av objekt("name", "clientId")
this.residentCluster = ENV.getCluster();
this.residentNamespace = ENV.namespace();
}

protected Set<String> konfigurePipUsers(String pipUsers) {
Expand Down Expand Up @@ -91,16 +95,14 @@ private boolean harTilgang(BeskyttetRessursAttributter attributter) {
}

private boolean erISammeKlusterKlasseOgNamespace(String consumer) {
try {
var elementer = consumer.split(":");
var consumerCluster = elementer[0];
var consumerNamespace = elementer[1];
return ENV.getCluster().isSameClass(Cluster.of(consumerCluster)) && ENV.namespace().equals(consumerNamespace);
} catch (Exception e) {
var elementer = consumer.split(":");
if (elementer.length < 2) {
return false;
}


var consumerCluster = elementer[0];
var consumerNamespace = elementer[1];
return residentCluster.isSameClass(Cluster.of(consumerCluster)) && residentNamespace.equals(consumerNamespace);
}

protected Tilgangsbeslutning vurderTilgangTilPipTjeneste(BeskyttetRessursAttributter beskyttetRessursAttributter, AppRessursData appRessursData) {
Expand Down

0 comments on commit 23ec04a

Please sign in to comment.