Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forbid write sharing with group public #101

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static boolean intersect(List<String> a, List<String> b) {
static boolean isShareableGroup(List<String> group, String zone, IdentityParam identityParam) throws ForbiddenException {
List<String> userGroupsForZone = getGroupsForZone(zone, identityParam);
List<String> authorizeGroup = group.stream().filter(userGroupsForZone::contains).toList();
if (!authorizeGroup.isEmpty() || group.isEmpty()){
if (!authorizeGroup.isEmpty() || group.isEmpty()) {
return true;
} else {
throw new ForbiddenException("You are not authorized to give rights to this group: " + group);
Expand All @@ -87,6 +87,9 @@ static void checkReadersWritersGroups(String zone, IdentityParam identityParam,

List<String> writersList = new ArrayList<>(writers);
List<String> readersList = new ArrayList<>(readers);
if (writersList.contains("group/public")) {
throw new ForbiddenException("You are not authorized to give writers rights to this group: group/public");
}
isShareableGroup(writersList, zone, identityParam);
isShareableGroup(readersList, zone, identityParam);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ public void test14DeleteWithJustWriteAccess() {

@Test
public void test15CreateOtherOrganisation() {
id = createData(otherCompany, "mySecondRestrictedDocument", List.of(PUBLIC), List.of(PUBLIC))
id = createData(otherCompany, "mySecondRestrictedDocument", List.of(PUBLIC), Collections.EMPTY_LIST)
.then().statusCode(201)
.body("doc_value", equalTo("{\"age\":1}"))
.extract().jsonPath().get("id");
Expand Down Expand Up @@ -470,6 +470,13 @@ public void test21ListWithPublic() {
deleteData(otherCompany, id3);
}

@Test
public void test22CreateWithPublicWriteAccess() {
createData(technical, "privateDocument", List.of(TECHNICAL), List.of(PUBLIC))
.then().statusCode(403);

}

protected RequestSpecification givenForUser(UserIdentity userIdentity) {
return given().header(userHeader, userIdentity.userId)
.header(groupsHeader, userIdentity.groups)
Expand Down
Loading