Skip to content

Commit

Permalink
#4582 Fix deep permission inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
stroomdev66 committed Nov 1, 2024
1 parent a2fadcd commit cd829ee
Showing 1 changed file with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,19 +227,19 @@ public void addDocumentPermissions(final DocRef sourceDocRef, final DocRef destD

private void checkGetPermission(final DocRef docRef) {
if (!securityContext.hasAppPermission(AppPermission.MANAGE_USERS_PERMISSION) &&
!securityContext.hasDocumentPermission(docRef, DocumentPermission.OWNER)) {
!securityContext.hasDocumentPermission(docRef, DocumentPermission.OWNER)) {
throw new PermissionException(securityContext.getUserRef(), "You do not have permission to get " +
"permissions of " +
docRef.getDisplayValue());
"permissions of " +
docRef.getDisplayValue());
}
}

private void checkSetPermission(final DocRef docRef) {
if (!securityContext.hasAppPermission(AppPermission.MANAGE_USERS_PERMISSION) &&
!securityContext.hasDocumentPermission(docRef, DocumentPermission.OWNER)) {
!securityContext.hasDocumentPermission(docRef, DocumentPermission.OWNER)) {
throw new PermissionException(securityContext.getUserRef(), "You do not have permission to change " +
"permissions of " +
docRef.getDisplayValue());
"permissions of " +
docRef.getDisplayValue());
}
}

Expand Down Expand Up @@ -303,9 +303,9 @@ private void checkSetPermission(final DocRef docRef) {
@Override
public DocumentUserPermissions getPermissions(final DocRef docRef, final UserRef userRef) {
if (!securityContext.hasAppPermission(AppPermission.MANAGE_USERS_PERMISSION) &&
!userRef.equals(securityContext.getUserRef())) {
!userRef.equals(securityContext.getUserRef())) {
throw new PermissionException(securityContext.getUserRef(), "You do not have permission to view user " +
"permissions");
"permissions");
}

final DocumentPermission permission = documentPermissionDao
Expand Down Expand Up @@ -470,10 +470,9 @@ private void addDeepPermissions(final DocRef docRef,
final DocumentPermission documentPermission = documentPermissionDao
.getDocumentUserPermission(docRef.getUuid(), group.getUuid());
if (documentPermission != null) {
if (inheritedPermission.get() != null) {
if (!inheritedPermission.get().isEqualOrHigher(documentPermission)) {
inheritedPermission.set(documentPermission);
}
if (inheritedPermission.get() == null ||
!inheritedPermission.get().isEqualOrHigher(documentPermission)) {
inheritedPermission.set(documentPermission);
}
}
final Set<String> documentUserCreatePermissions = documentPermissionDao
Expand Down

0 comments on commit cd829ee

Please sign in to comment.