Skip to content

Commit

Permalink
Allow script token principals to read unspecified resources
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerwowen committed Jul 15, 2024
1 parent 4672640 commit 3ae249b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public boolean authorize(
return false;
}

if (AuthZResource.Type.UNSPECIFIED.equals(requestedResource.getType())) {
// Always allow unspecified resources as they are READ operations
return true;
}

if (AuthZResource.Type.ENV_STAGE.equals(requestedResource.getType())) {
if (requestedResource.getEnvName().equals(principal.getResource().getName())) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,18 @@ public void testPublish() throws Exception {
checkPositive(sysOperator, build, TeletraanPrincipalRole.PUBLISHER);
checkNegative(sysReader, build, TeletraanPrincipalRole.PUBLISHER);
}

@Test
public void testUnspecified() throws Exception {
checkPositive(sysAdmin, AuthZResource.UNSPECIFIED_RESOURCE, TeletraanPrincipalRole.READ);
checkPositive(sysOperator, AuthZResource.UNSPECIFIED_RESOURCE, TeletraanPrincipalRole.READ);
checkPositive(sysReader, AuthZResource.UNSPECIFIED_RESOURCE, TeletraanPrincipalRole.READ);

checkPositive(envAdmin, AuthZResource.UNSPECIFIED_RESOURCE, TeletraanPrincipalRole.READ);
checkPositive(envOperator, AuthZResource.UNSPECIFIED_RESOURCE, TeletraanPrincipalRole.READ);
checkPositive(envReader, AuthZResource.UNSPECIFIED_RESOURCE, TeletraanPrincipalRole.READ);

checkPositive(pinger, AuthZResource.UNSPECIFIED_RESOURCE, TeletraanPrincipalRole.READ);
checkPositive(publisher, AuthZResource.UNSPECIFIED_RESOURCE, TeletraanPrincipalRole.READ);
}
}

0 comments on commit 3ae249b

Please sign in to comment.