diff --git a/server/pom.xml b/server/pom.xml
index 3fc610db..1e1e491a 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -105,7 +105,7 @@
org.projectlombok
lombok
- true
+ 1.18.30
org.springframework.boot
diff --git a/server/src/main/java/access/api/RoleController.java b/server/src/main/java/access/api/RoleController.java
index cb82bad0..4be63c16 100644
--- a/server/src/main/java/access/api/RoleController.java
+++ b/server/src/main/java/access/api/RoleController.java
@@ -75,9 +75,10 @@ public ResponseEntity> rolesByApplication(@Parameter(hidden = true) U
public ResponseEntity role(@PathVariable("id") Long id, User user) {
LOG.debug("/role");
Role role = roleRepository.findById(id).orElseThrow(NotFoundException::new);
+ UserPermissions.assertRoleAccess(user, role, Authority.INVITER);
+
Map provider = manage.providerById(role.getManageType(), role.getManageId());
role.setApplication(provider);
- UserPermissions.assertRoleAccess(user, role, Authority.INVITER);
return ResponseEntity.ok(role);
}
diff --git a/server/src/main/java/access/security/UserPermissions.java b/server/src/main/java/access/security/UserPermissions.java
index bf1699d2..c4e4442c 100644
--- a/server/src/main/java/access/security/UserPermissions.java
+++ b/server/src/main/java/access/security/UserPermissions.java
@@ -100,9 +100,10 @@ public static void assertRoleAccess(User user, Role accessRole, Authority author
return;
}
user.getUserRoles().stream()
- .filter(userRole -> userRole.getRole().getId().equals(accessRole.getId()) ||
+ .filter(userRole -> (userRole.getRole().getId().equals(accessRole.getId()) &&
+ userRole.getAuthority().hasEqualOrHigherRights(authority)) ||
(userRole.getRole().getManageId().equals(accessRole.getManageId()) &&
- userRole.getAuthority().hasEqualOrHigherRights(authority)))
+ userRole.getAuthority().hasEqualOrHigherRights(Authority.MANAGER)))
.findFirst()
.orElseThrow(UserRestrictionException::new);
}
diff --git a/server/src/test/java/access/security/UserPermissionsTest.java b/server/src/test/java/access/security/UserPermissionsTest.java
index 2c62b6b1..c9ae774f 100644
--- a/server/src/test/java/access/security/UserPermissionsTest.java
+++ b/server/src/test/java/access/security/UserPermissionsTest.java
@@ -133,7 +133,7 @@ void assertRoleAccessInstitutionAdmin() {
void assertRoleAccess() {
String identifier = UUID.randomUUID().toString();
User user = userWithRole(Authority.GUEST, identifier);
- UserPermissions.assertRoleAccess(user, user.getUserRoles().iterator().next().getRole());
+ assertThrows(UserRestrictionException.class, () -> UserPermissions.assertRoleAccess(user, user.getUserRoles().iterator().next().getRole()));
}
@Test