fix #494: add delete impact confirmations
This commit is contained in:
56
docs/design/494-delete-impact-confirmation/README.md
Normal file
56
docs/design/494-delete-impact-confirmation/README.md
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
# Redmine #494 - 삭제 영향도와 확인 절차 설계
|
||||||
|
|
||||||
|
## 프로젝트 개요
|
||||||
|
|
||||||
|
VPD Backoffice는 Oracle Database VPD/ORDS 기능을 백오피스 권한 테이블로 제어하는 Spring Boot 관리 도구다. 사용자는 DB schema user가 아니라 Bearer Token으로 식별되는 application user이며, 사용자/그룹/역할/권한 테이블의 조합이 VPD policy function과 redaction 판단에 사용된다.
|
||||||
|
|
||||||
|
## 목표
|
||||||
|
|
||||||
|
권한, 역할, 그룹 관련 삭제/해제/비활성화 작업 전에 영향 범위를 보여주고, 사용자가 영향 확인을 명시한 경우에만 처리한다.
|
||||||
|
|
||||||
|
## 현재 문제
|
||||||
|
|
||||||
|
- 역할 삭제 버튼은 연결 사용자, 그룹, 권한이 남아 있어도 영향 범위를 보여주지 않는다.
|
||||||
|
- 보조 스키마 생성 DDL에는 FK가 없어 연결이 남은 역할을 삭제하면 고아 매핑/권한이 생길 수 있다.
|
||||||
|
- 권한 삭제 시 해당 역할의 TABLE/VIEW 접근이 사라지고 마지막 권한이면 보호 객체가 비활성화될 수 있지만 화면에서 강조하지 않는다.
|
||||||
|
- 그룹 비활성화/그룹 사용자 해제/그룹 역할 해제는 VPD effective role 결과를 바꾸지만 확인 절차가 약하다.
|
||||||
|
- 삭제 검증 실패가 전역 오류 화면으로 빠져 사용자가 원래 화면에서 바로 조치하기 어렵다.
|
||||||
|
|
||||||
|
## 설계
|
||||||
|
|
||||||
|
- 역할 목록에 삭제 영향 요약을 표시한다.
|
||||||
|
- 직접 사용자
|
||||||
|
- 연결 그룹
|
||||||
|
- 영향 사용자
|
||||||
|
- 권한 수와 보호 객체
|
||||||
|
- 역할 삭제는 서버에서 연결 사용자/그룹/권한이 하나라도 있으면 차단한다.
|
||||||
|
- 삭제 전에 사용자 역할, 그룹 역할, 권한을 먼저 해제해야 한다.
|
||||||
|
- 연결이 없는 역할도 영향 확인 체크가 있어야 삭제된다.
|
||||||
|
- 권한 목록에 삭제 영향 요약을 표시한다.
|
||||||
|
- 역할이 잃는 TABLE/VIEW 권한
|
||||||
|
- 마지막 권한 삭제 시 보호 객체 비활성화 가능성
|
||||||
|
- 영향 확인 체크가 없으면 서버에서 차단한다.
|
||||||
|
- 그룹 화면에 비활성화/해제 영향 요약을 표시한다.
|
||||||
|
- 그룹 비활성화는 활성 그룹을 통해 상속되던 역할을 VPD에서 제외한다.
|
||||||
|
- 그룹 사용자 해제는 해당 사용자가 그 그룹 역할을 잃는다.
|
||||||
|
- 그룹 역할 해제는 그룹 사용자 전체가 해당 역할 권한을 잃는다.
|
||||||
|
- 영향 확인 체크가 없으면 서버에서 차단한다.
|
||||||
|
- 삭제/해제 차단 메시지는 전역 오류 페이지 대신 원래 화면의 error alert로 보여준다.
|
||||||
|
|
||||||
|
## 완료 기준
|
||||||
|
|
||||||
|
- 역할 목록에서 삭제 영향이 보이고 연결이 있는 역할 삭제는 차단된다.
|
||||||
|
- 권한 목록에서 삭제 영향과 마지막 권한 경고가 보인다.
|
||||||
|
- 권한 삭제는 영향 확인 체크 없이는 서버에서 실패한다.
|
||||||
|
- 그룹 비활성화/사용자 해제/역할 해제는 영향 확인 체크를 요구한다.
|
||||||
|
- 실패 메시지는 원래 화면 상단에서 확인된다.
|
||||||
|
- 모바일 화면에서 가로 body overflow가 없다.
|
||||||
|
|
||||||
|
## 검증
|
||||||
|
|
||||||
|
- `mvn test`
|
||||||
|
- Playwright:
|
||||||
|
- `/roles`, `/permissions`, `/groups` desktop/mobile 렌더링
|
||||||
|
- 영향 확인 UI 노출 확인
|
||||||
|
- 확인 체크 없는 권한 삭제 시 error alert 확인
|
||||||
|
- 모바일 body overflow 없음
|
||||||
@@ -27,6 +27,12 @@ public interface PermissionMapper {
|
|||||||
|
|
||||||
int deleteRole(@Param("roleId") long roleId);
|
int deleteRole(@Param("roleId") long roleId);
|
||||||
|
|
||||||
|
int countUserRolesByRoleId(@Param("roleId") long roleId);
|
||||||
|
|
||||||
|
int countGroupRolesByRoleId(@Param("roleId") long roleId);
|
||||||
|
|
||||||
|
int countPermissionsByRoleId(@Param("roleId") long roleId);
|
||||||
|
|
||||||
List<PermissionView> findPermissionViews();
|
List<PermissionView> findPermissionViews();
|
||||||
|
|
||||||
PermissionSet findPermissionSet(@Param("roleId") long roleId, @Param("objectId") long objectId);
|
PermissionSet findPermissionSet(@Param("roleId") long roleId, @Param("objectId") long objectId);
|
||||||
|
|||||||
@@ -42,6 +42,14 @@ public class GroupService {
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void setActive(long groupId, boolean active) {
|
public void setActive(long groupId, boolean active) {
|
||||||
|
setActive(groupId, active, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void setActive(long groupId, boolean active, boolean confirmImpact) {
|
||||||
|
if (!active && !confirmImpact) {
|
||||||
|
throw new AppException("그룹 비활성화 전 영향 확인이 필요합니다.");
|
||||||
|
}
|
||||||
int updated = groupMapper.updateActive(groupId, active ? "Y" : "N");
|
int updated = groupMapper.updateActive(groupId, active ? "Y" : "N");
|
||||||
if (updated == 0) {
|
if (updated == 0) {
|
||||||
throw new AppException("그룹을 찾을 수 없습니다.");
|
throw new AppException("그룹을 찾을 수 없습니다.");
|
||||||
@@ -59,6 +67,14 @@ public class GroupService {
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void removeUser(long groupId, long userId) {
|
public void removeUser(long groupId, long userId) {
|
||||||
|
removeUser(groupId, userId, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void removeUser(long groupId, long userId, boolean confirmImpact) {
|
||||||
|
if (!confirmImpact) {
|
||||||
|
throw new AppException("그룹 사용자 해제 전 영향 확인이 필요합니다.");
|
||||||
|
}
|
||||||
int deleted = groupMapper.deleteGroupUser(groupId, userId);
|
int deleted = groupMapper.deleteGroupUser(groupId, userId);
|
||||||
if (deleted == 0) {
|
if (deleted == 0) {
|
||||||
throw new AppException("삭제할 그룹 사용자 매핑을 찾을 수 없습니다.");
|
throw new AppException("삭제할 그룹 사용자 매핑을 찾을 수 없습니다.");
|
||||||
@@ -76,6 +92,14 @@ public class GroupService {
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void removeRole(long groupId, long roleId) {
|
public void removeRole(long groupId, long roleId) {
|
||||||
|
removeRole(groupId, roleId, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void removeRole(long groupId, long roleId, boolean confirmImpact) {
|
||||||
|
if (!confirmImpact) {
|
||||||
|
throw new AppException("그룹 역할 해제 전 영향 확인이 필요합니다.");
|
||||||
|
}
|
||||||
int deleted = groupMapper.deleteGroupRole(groupId, roleId);
|
int deleted = groupMapper.deleteGroupRole(groupId, roleId);
|
||||||
if (deleted == 0) {
|
if (deleted == 0) {
|
||||||
throw new AppException("삭제할 그룹 역할 매핑을 찾을 수 없습니다.");
|
throw new AppException("삭제할 그룹 역할 매핑을 찾을 수 없습니다.");
|
||||||
|
|||||||
@@ -76,6 +76,22 @@ public class PermissionService {
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void deleteRole(long roleId) {
|
public void deleteRole(long roleId) {
|
||||||
|
deleteRole(roleId, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void deleteRole(long roleId, boolean confirmImpact) {
|
||||||
|
if (!confirmImpact) {
|
||||||
|
throw new AppException("역할 삭제 전 영향 확인이 필요합니다.");
|
||||||
|
}
|
||||||
|
int userRoleCount = permissionMapper.countUserRolesByRoleId(roleId);
|
||||||
|
int groupRoleCount = permissionMapper.countGroupRolesByRoleId(roleId);
|
||||||
|
int permissionCount = permissionMapper.countPermissionsByRoleId(roleId);
|
||||||
|
if (userRoleCount + groupRoleCount + permissionCount > 0) {
|
||||||
|
throw new AppException("연결된 사용자/그룹/권한이 있는 역할은 삭제할 수 없습니다. 사용자 역할 "
|
||||||
|
+ userRoleCount + "건, 그룹 역할 " + groupRoleCount + "건, 권한 " + permissionCount
|
||||||
|
+ "건을 먼저 해제하세요.");
|
||||||
|
}
|
||||||
int deleted = permissionMapper.deleteRole(roleId);
|
int deleted = permissionMapper.deleteRole(roleId);
|
||||||
if (deleted == 0) {
|
if (deleted == 0) {
|
||||||
throw new AppException("삭제할 역할을 찾을 수 없습니다.");
|
throw new AppException("삭제할 역할을 찾을 수 없습니다.");
|
||||||
@@ -133,6 +149,14 @@ public class PermissionService {
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void deletePermission(long permissionId) {
|
public void deletePermission(long permissionId) {
|
||||||
|
deletePermission(permissionId, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void deletePermission(long permissionId, boolean confirmImpact) {
|
||||||
|
if (!confirmImpact) {
|
||||||
|
throw new AppException("권한 삭제 전 영향 확인이 필요합니다.");
|
||||||
|
}
|
||||||
Long objectId = permissionMapper.findObjectIdByPermissionId(permissionId);
|
Long objectId = permissionMapper.findObjectIdByPermissionId(permissionId);
|
||||||
permissionMapper.deleteRules(permissionId);
|
permissionMapper.deleteRules(permissionId);
|
||||||
permissionMapper.deleteVisibleColumns(permissionId);
|
permissionMapper.deleteVisibleColumns(permissionId);
|
||||||
@@ -147,6 +171,10 @@ public class PermissionService {
|
|||||||
"permissionId=" + permissionId));
|
"permissionId=" + permissionId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int countPermissionsByObjectId(long objectId) {
|
||||||
|
return permissionMapper.countPermissionsByObjectId(objectId);
|
||||||
|
}
|
||||||
|
|
||||||
private void validateRules(long objectId, List<RuleCommand> rules) {
|
private void validateRules(long objectId, List<RuleCommand> rules) {
|
||||||
if (rules == null || rules.isEmpty()) {
|
if (rules == null || rules.isEmpty()) {
|
||||||
throw new AppException("행 규칙은 하나 이상 필요합니다.");
|
throw new AppException("행 규칙은 하나 이상 필요합니다.");
|
||||||
|
|||||||
@@ -1,9 +1,15 @@
|
|||||||
package com.cloudhandson.vpdbackoffice.web;
|
package com.cloudhandson.vpdbackoffice.web;
|
||||||
|
|
||||||
|
import com.cloudhandson.vpdbackoffice.domain.effective.GroupEffectiveAccessView;
|
||||||
|
import com.cloudhandson.vpdbackoffice.domain.effective.RoleEffectiveImpactView;
|
||||||
import com.cloudhandson.vpdbackoffice.domain.group.GroupCreateCommand;
|
import com.cloudhandson.vpdbackoffice.domain.group.GroupCreateCommand;
|
||||||
|
import com.cloudhandson.vpdbackoffice.service.AppException;
|
||||||
|
import com.cloudhandson.vpdbackoffice.service.EffectiveMatrixService;
|
||||||
import com.cloudhandson.vpdbackoffice.service.GroupService;
|
import com.cloudhandson.vpdbackoffice.service.GroupService;
|
||||||
import com.cloudhandson.vpdbackoffice.service.PermissionService;
|
import com.cloudhandson.vpdbackoffice.service.PermissionService;
|
||||||
import com.cloudhandson.vpdbackoffice.service.UserService;
|
import com.cloudhandson.vpdbackoffice.service.UserService;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@@ -17,20 +23,32 @@ public class GroupController {
|
|||||||
private final GroupService groupService;
|
private final GroupService groupService;
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
private final PermissionService permissionService;
|
private final PermissionService permissionService;
|
||||||
|
private final EffectiveMatrixService effectiveMatrixService;
|
||||||
|
|
||||||
public GroupController(GroupService groupService, UserService userService, PermissionService permissionService) {
|
public GroupController(
|
||||||
|
GroupService groupService,
|
||||||
|
UserService userService,
|
||||||
|
PermissionService permissionService,
|
||||||
|
EffectiveMatrixService effectiveMatrixService
|
||||||
|
) {
|
||||||
this.groupService = groupService;
|
this.groupService = groupService;
|
||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
this.permissionService = permissionService;
|
this.permissionService = permissionService;
|
||||||
|
this.effectiveMatrixService = effectiveMatrixService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/groups")
|
@GetMapping("/groups")
|
||||||
public String groups(Model model) {
|
public String groups(Model model) {
|
||||||
|
var matrix = effectiveMatrixService.matrix();
|
||||||
model.addAttribute("groups", groupService.findAll());
|
model.addAttribute("groups", groupService.findAll());
|
||||||
model.addAttribute("users", userService.findAll());
|
model.addAttribute("users", userService.findAll());
|
||||||
model.addAttribute("roles", permissionService.findRoles());
|
model.addAttribute("roles", permissionService.findRoles());
|
||||||
model.addAttribute("groupUsers", groupService.findGroupUsers());
|
model.addAttribute("groupUsers", groupService.findGroupUsers());
|
||||||
model.addAttribute("groupRoles", groupService.findGroupRoles());
|
model.addAttribute("groupRoles", groupService.findGroupRoles());
|
||||||
|
model.addAttribute("groupImpactByGroupId", matrix.groups().stream()
|
||||||
|
.collect(Collectors.toMap(GroupEffectiveAccessView::groupId, impact -> impact)));
|
||||||
|
model.addAttribute("roleImpactByRoleId", matrix.roles().stream()
|
||||||
|
.collect(Collectors.toMap(RoleEffectiveImpactView::roleId, impact -> impact)));
|
||||||
return "groups";
|
return "groups";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,10 +68,15 @@ public class GroupController {
|
|||||||
public String active(
|
public String active(
|
||||||
@RequestParam long groupId,
|
@RequestParam long groupId,
|
||||||
@RequestParam boolean active,
|
@RequestParam boolean active,
|
||||||
|
@RequestParam(defaultValue = "false") boolean confirmImpact,
|
||||||
RedirectAttributes redirectAttributes
|
RedirectAttributes redirectAttributes
|
||||||
) {
|
) {
|
||||||
groupService.setActive(groupId, active);
|
try {
|
||||||
redirectAttributes.addFlashAttribute("message", "그룹 상태를 변경했습니다.");
|
groupService.setActive(groupId, active, active || confirmImpact);
|
||||||
|
redirectAttributes.addFlashAttribute("message", "그룹 상태를 변경했습니다.");
|
||||||
|
} catch (AppException exception) {
|
||||||
|
redirectAttributes.addFlashAttribute("error", exception.getMessage());
|
||||||
|
}
|
||||||
return "redirect:/groups";
|
return "redirect:/groups";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,10 +95,15 @@ public class GroupController {
|
|||||||
public String removeUser(
|
public String removeUser(
|
||||||
@RequestParam long groupId,
|
@RequestParam long groupId,
|
||||||
@RequestParam long userId,
|
@RequestParam long userId,
|
||||||
|
@RequestParam(defaultValue = "false") boolean confirmImpact,
|
||||||
RedirectAttributes redirectAttributes
|
RedirectAttributes redirectAttributes
|
||||||
) {
|
) {
|
||||||
groupService.removeUser(groupId, userId);
|
try {
|
||||||
redirectAttributes.addFlashAttribute("message", "그룹 사용자를 해제했습니다.");
|
groupService.removeUser(groupId, userId, confirmImpact);
|
||||||
|
redirectAttributes.addFlashAttribute("message", "그룹 사용자를 해제했습니다.");
|
||||||
|
} catch (AppException exception) {
|
||||||
|
redirectAttributes.addFlashAttribute("error", exception.getMessage());
|
||||||
|
}
|
||||||
return "redirect:/groups";
|
return "redirect:/groups";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,10 +122,15 @@ public class GroupController {
|
|||||||
public String removeRole(
|
public String removeRole(
|
||||||
@RequestParam long groupId,
|
@RequestParam long groupId,
|
||||||
@RequestParam long roleId,
|
@RequestParam long roleId,
|
||||||
|
@RequestParam(defaultValue = "false") boolean confirmImpact,
|
||||||
RedirectAttributes redirectAttributes
|
RedirectAttributes redirectAttributes
|
||||||
) {
|
) {
|
||||||
groupService.removeRole(groupId, roleId);
|
try {
|
||||||
redirectAttributes.addFlashAttribute("message", "그룹 역할을 해제했습니다.");
|
groupService.removeRole(groupId, roleId, confirmImpact);
|
||||||
|
redirectAttributes.addFlashAttribute("message", "그룹 역할을 해제했습니다.");
|
||||||
|
} catch (AppException exception) {
|
||||||
|
redirectAttributes.addFlashAttribute("error", exception.getMessage());
|
||||||
|
}
|
||||||
return "redirect:/groups";
|
return "redirect:/groups";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.cloudhandson.vpdbackoffice.domain.permission.AppRole;
|
|||||||
import com.cloudhandson.vpdbackoffice.domain.permission.PermissionSetCommand;
|
import com.cloudhandson.vpdbackoffice.domain.permission.PermissionSetCommand;
|
||||||
import com.cloudhandson.vpdbackoffice.domain.permission.RuleCommand;
|
import com.cloudhandson.vpdbackoffice.domain.permission.RuleCommand;
|
||||||
import com.cloudhandson.vpdbackoffice.domain.protectedobject.ProtectedColumn;
|
import com.cloudhandson.vpdbackoffice.domain.protectedobject.ProtectedColumn;
|
||||||
|
import com.cloudhandson.vpdbackoffice.service.AppException;
|
||||||
import com.cloudhandson.vpdbackoffice.service.GroupService;
|
import com.cloudhandson.vpdbackoffice.service.GroupService;
|
||||||
import com.cloudhandson.vpdbackoffice.service.PermissionService;
|
import com.cloudhandson.vpdbackoffice.service.PermissionService;
|
||||||
import com.cloudhandson.vpdbackoffice.service.ProtectedObjectService;
|
import com.cloudhandson.vpdbackoffice.service.ProtectedObjectService;
|
||||||
@@ -111,6 +112,14 @@ public class PermissionController {
|
|||||||
var dbObjects = protectedObjectService.findDatabaseObjects();
|
var dbObjects = protectedObjectService.findDatabaseObjects();
|
||||||
long dbObjectsAt = System.nanoTime();
|
long dbObjectsAt = System.nanoTime();
|
||||||
var permissions = permissionService.findPermissionViews();
|
var permissions = permissionService.findPermissionViews();
|
||||||
|
var lastPermissionByPermissionId = permissions.stream()
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
permission -> permission.permissionId(),
|
||||||
|
permission -> permission.objectId() > 0
|
||||||
|
&& permissionService.countPermissionsByObjectId(permission.objectId()) <= 1,
|
||||||
|
(left, right) -> left,
|
||||||
|
LinkedHashMap::new
|
||||||
|
));
|
||||||
long permissionsAt = System.nanoTime();
|
long permissionsAt = System.nanoTime();
|
||||||
log.info("permissions page timings: objects={}ms roles={}ms roleImpact={}ms columns={}ms dbObjects={}ms permissions={}ms total={}ms",
|
log.info("permissions page timings: objects={}ms roles={}ms roleImpact={}ms columns={}ms dbObjects={}ms permissions={}ms total={}ms",
|
||||||
elapsedMillis(started, objectsAt),
|
elapsedMillis(started, objectsAt),
|
||||||
@@ -130,6 +139,7 @@ public class PermissionController {
|
|||||||
model.addAttribute("groupUsersByRole", roleImpact.groupUsersByRole());
|
model.addAttribute("groupUsersByRole", roleImpact.groupUsersByRole());
|
||||||
model.addAttribute("dbObjects", dbObjects);
|
model.addAttribute("dbObjects", dbObjects);
|
||||||
model.addAttribute("permissions", permissions);
|
model.addAttribute("permissions", permissions);
|
||||||
|
model.addAttribute("lastPermissionByPermissionId", lastPermissionByPermissionId);
|
||||||
return "permissions";
|
return "permissions";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,9 +267,17 @@ public class PermissionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/permissions/delete")
|
@PostMapping("/permissions/delete")
|
||||||
public String delete(@RequestParam long permissionId, RedirectAttributes redirectAttributes) {
|
public String delete(
|
||||||
permissionService.deletePermission(permissionId);
|
@RequestParam long permissionId,
|
||||||
redirectAttributes.addFlashAttribute("message", "권한을 삭제했습니다.");
|
@RequestParam(defaultValue = "false") boolean confirmImpact,
|
||||||
|
RedirectAttributes redirectAttributes
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
permissionService.deletePermission(permissionId, confirmImpact);
|
||||||
|
redirectAttributes.addFlashAttribute("message", "권한을 삭제했습니다.");
|
||||||
|
} catch (AppException exception) {
|
||||||
|
redirectAttributes.addFlashAttribute("error", exception.getMessage());
|
||||||
|
}
|
||||||
return "redirect:/permissions";
|
return "redirect:/permissions";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
package com.cloudhandson.vpdbackoffice.web;
|
package com.cloudhandson.vpdbackoffice.web;
|
||||||
|
|
||||||
|
import com.cloudhandson.vpdbackoffice.domain.effective.RoleEffectiveImpactView;
|
||||||
|
import com.cloudhandson.vpdbackoffice.service.AppException;
|
||||||
|
import com.cloudhandson.vpdbackoffice.service.EffectiveMatrixService;
|
||||||
import com.cloudhandson.vpdbackoffice.service.PermissionService;
|
import com.cloudhandson.vpdbackoffice.service.PermissionService;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@@ -12,14 +17,19 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|||||||
public class RoleController {
|
public class RoleController {
|
||||||
|
|
||||||
private final PermissionService permissionService;
|
private final PermissionService permissionService;
|
||||||
|
private final EffectiveMatrixService effectiveMatrixService;
|
||||||
|
|
||||||
public RoleController(PermissionService permissionService) {
|
public RoleController(PermissionService permissionService, EffectiveMatrixService effectiveMatrixService) {
|
||||||
this.permissionService = permissionService;
|
this.permissionService = permissionService;
|
||||||
|
this.effectiveMatrixService = effectiveMatrixService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/roles")
|
@GetMapping("/roles")
|
||||||
public String roles(Model model) {
|
public String roles(Model model) {
|
||||||
model.addAttribute("roles", permissionService.findRoles());
|
model.addAttribute("roles", permissionService.findRoles());
|
||||||
|
Map<Long, RoleEffectiveImpactView> roleImpactByRoleId = effectiveMatrixService.matrix().roles().stream()
|
||||||
|
.collect(Collectors.toMap(RoleEffectiveImpactView::roleId, impact -> impact));
|
||||||
|
model.addAttribute("roleImpactByRoleId", roleImpactByRoleId);
|
||||||
return "roles";
|
return "roles";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,9 +57,17 @@ public class RoleController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/roles/delete")
|
@PostMapping("/roles/delete")
|
||||||
public String delete(@RequestParam long roleId, RedirectAttributes redirectAttributes) {
|
public String delete(
|
||||||
permissionService.deleteRole(roleId);
|
@RequestParam long roleId,
|
||||||
redirectAttributes.addFlashAttribute("message", "역할을 삭제했습니다.");
|
@RequestParam(defaultValue = "false") boolean confirmImpact,
|
||||||
|
RedirectAttributes redirectAttributes
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
permissionService.deleteRole(roleId, confirmImpact);
|
||||||
|
redirectAttributes.addFlashAttribute("message", "역할을 삭제했습니다.");
|
||||||
|
} catch (AppException exception) {
|
||||||
|
redirectAttributes.addFlashAttribute("error", exception.getMessage());
|
||||||
|
}
|
||||||
return "redirect:/roles";
|
return "redirect:/roles";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,24 @@
|
|||||||
WHERE role_id = #{roleId,jdbcType=NUMERIC}
|
WHERE role_id = #{roleId,jdbcType=NUMERIC}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
<select id="countUserRolesByRoleId" resultType="int">
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM cb_user_role
|
||||||
|
WHERE role_id = #{roleId,jdbcType=NUMERIC}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="countGroupRolesByRoleId" resultType="int">
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM cb_group_role
|
||||||
|
WHERE role_id = #{roleId,jdbcType=NUMERIC}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="countPermissionsByRoleId" resultType="int">
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM cb_permission
|
||||||
|
WHERE role_id = #{roleId,jdbcType=NUMERIC}
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="findPermissionViews" resultType="com.cloudhandson.vpdbackoffice.domain.permission.PermissionView">
|
<select id="findPermissionViews" resultType="com.cloudhandson.vpdbackoffice.domain.permission.PermissionView">
|
||||||
SELECT p.perm_id AS permission_id,
|
SELECT p.perm_id AS permission_id,
|
||||||
r.role_id,
|
r.role_id,
|
||||||
|
|||||||
@@ -638,6 +638,46 @@ body {
|
|||||||
overflow-wrap: anywhere;
|
overflow-wrap: anywhere;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.delete-impact {
|
||||||
|
color: var(--rw-text);
|
||||||
|
max-width: 24rem;
|
||||||
|
min-width: 14rem;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
|
||||||
|
.delete-impact div + div {
|
||||||
|
margin-top: .35rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.delete-impact span,
|
||||||
|
.delete-impact small {
|
||||||
|
color: var(--rw-muted);
|
||||||
|
display: block;
|
||||||
|
font-size: .76rem;
|
||||||
|
line-height: 1.35;
|
||||||
|
}
|
||||||
|
|
||||||
|
.delete-impact strong {
|
||||||
|
display: block;
|
||||||
|
font-weight: 800;
|
||||||
|
line-height: 1.35;
|
||||||
|
}
|
||||||
|
|
||||||
|
.delete-confirm {
|
||||||
|
align-items: center;
|
||||||
|
color: var(--rw-muted);
|
||||||
|
display: inline-flex;
|
||||||
|
font-size: .76rem;
|
||||||
|
font-weight: 700;
|
||||||
|
gap: .25rem;
|
||||||
|
margin: 0 .35rem .25rem 0;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.delete-confirm.disabled {
|
||||||
|
opacity: .55;
|
||||||
|
}
|
||||||
|
|
||||||
.policy-apply-flow {
|
.policy-apply-flow {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="alert alert-success" th:if="${message}" th:text="${message}"></div>
|
<div class="alert alert-success" th:if="${message}" th:text="${message}"></div>
|
||||||
|
<div class="alert alert-danger" th:if="${error}" th:text="${error}"></div>
|
||||||
|
|
||||||
<section class="content-band">
|
<section class="content-band">
|
||||||
<h2>그룹 추가</h2>
|
<h2>그룹 추가</h2>
|
||||||
@@ -41,28 +42,44 @@
|
|||||||
<th>코드</th>
|
<th>코드</th>
|
||||||
<th>그룹명</th>
|
<th>그룹명</th>
|
||||||
<th>설명</th>
|
<th>설명</th>
|
||||||
|
<th>비활성 영향</th>
|
||||||
<th>상태</th>
|
<th>상태</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr th:each="group : ${groups}">
|
<tr th:each="group : ${groups}" th:with="impact=${groupImpactByGroupId[group.groupId()]}">
|
||||||
<td th:text="${group.groupId()}">1</td>
|
<td th:text="${group.groupId()}">1</td>
|
||||||
<td><code th:text="${group.groupCode()}">SALES_TEAM</code></td>
|
<td><code th:text="${group.groupCode()}">SALES_TEAM</code></td>
|
||||||
<td th:text="${group.groupName()}">영업팀</td>
|
<td th:text="${group.groupName()}">영업팀</td>
|
||||||
<td th:text="${group.description()}">설명</td>
|
<td th:text="${group.description()}">설명</td>
|
||||||
|
<td class="delete-impact">
|
||||||
|
<div>
|
||||||
|
<span>사용자</span>
|
||||||
|
<strong th:text="${impact == null || #lists.isEmpty(impact.users()) ? '0명' : #lists.size(impact.users()) + '명'}">0명</strong>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<span>역할</span>
|
||||||
|
<strong th:text="${impact == null || #lists.isEmpty(impact.roles()) ? '0개' : #lists.size(impact.roles()) + '개'}">0개</strong>
|
||||||
|
</div>
|
||||||
|
<small th:text="${impact == null || #lists.isEmpty(impact.objectNames()) ? '상속 권한 없음' : #strings.listJoin(impact.objectNames(), ', ')}">상속 권한 없음</small>
|
||||||
|
</td>
|
||||||
<td><span class="badge" th:classappend="${group.active()} ? ' text-bg-success' : ' text-bg-secondary'" th:text="${group.activeYn()}">Y</span></td>
|
<td><span class="badge" th:classappend="${group.active()} ? ' text-bg-success' : ' text-bg-secondary'" th:text="${group.activeYn()}">Y</span></td>
|
||||||
<td>
|
<td>
|
||||||
<form method="post" action="/groups/active" class="inline-form">
|
<form method="post" action="/groups/active" class="inline-form">
|
||||||
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}">
|
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}">
|
||||||
<input type="hidden" name="groupId" th:value="${group.groupId()}">
|
<input type="hidden" name="groupId" th:value="${group.groupId()}">
|
||||||
<input type="hidden" name="active" th:value="${!group.active()}">
|
<input type="hidden" name="active" th:value="${!group.active()}">
|
||||||
|
<label class="delete-confirm" th:if="${group.active()}">
|
||||||
|
<input type="checkbox" name="confirmImpact" value="true" required>
|
||||||
|
영향 확인
|
||||||
|
</label>
|
||||||
<button class="btn btn-sm btn-outline-secondary" type="submit" th:text="${group.active()} ? '비활성화' : '활성화'">변경</button>
|
<button class="btn btn-sm btn-outline-secondary" type="submit" th:text="${group.active()} ? '비활성화' : '활성화'">변경</button>
|
||||||
</form>
|
</form>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr th:if="${#lists.isEmpty(groups)}">
|
<tr th:if="${#lists.isEmpty(groups)}">
|
||||||
<td colspan="6" class="text-muted">등록된 그룹이 없습니다.</td>
|
<td colspan="7" class="text-muted">등록된 그룹이 없습니다.</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@@ -95,24 +112,33 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>그룹</th>
|
<th>그룹</th>
|
||||||
<th>사용자</th>
|
<th>사용자</th>
|
||||||
|
<th>해제 영향</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr th:each="mapping : ${groupUsers}" th:attr="data-group-id=${mapping.groupId()}">
|
<tr th:each="mapping : ${groupUsers}" th:attr="data-group-id=${mapping.groupId()}" th:with="impact=${groupImpactByGroupId[mapping.groupId()]}">
|
||||||
<td><code th:text="${mapping.groupCode()}">SALES_TEAM</code></td>
|
<td><code th:text="${mapping.groupCode()}">SALES_TEAM</code></td>
|
||||||
<td th:text="${mapping.username()}">agent_sales</td>
|
<td th:text="${mapping.username()}">agent_sales</td>
|
||||||
|
<td class="delete-impact">
|
||||||
|
<span>이 사용자는 그룹 역할을 더 이상 상속하지 않습니다.</span>
|
||||||
|
<strong th:text="${impact == null || #lists.isEmpty(impact.roles()) ? '그룹 역할 없음' : #strings.listJoin(impact.roles(), ', ')}">그룹 역할 없음</strong>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<form method="post" action="/groups/users/delete" class="inline-form">
|
<form method="post" action="/groups/users/delete" class="inline-form">
|
||||||
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}">
|
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}">
|
||||||
<input type="hidden" name="groupId" th:value="${mapping.groupId()}">
|
<input type="hidden" name="groupId" th:value="${mapping.groupId()}">
|
||||||
<input type="hidden" name="userId" th:value="${mapping.userId()}">
|
<input type="hidden" name="userId" th:value="${mapping.userId()}">
|
||||||
|
<label class="delete-confirm">
|
||||||
|
<input type="checkbox" name="confirmImpact" value="true" required>
|
||||||
|
영향 확인
|
||||||
|
</label>
|
||||||
<button class="btn btn-sm btn-outline-danger" type="submit">해제</button>
|
<button class="btn btn-sm btn-outline-danger" type="submit">해제</button>
|
||||||
</form>
|
</form>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr th:if="${#lists.isEmpty(groupUsers)}">
|
<tr th:if="${#lists.isEmpty(groupUsers)}">
|
||||||
<td colspan="3" class="text-muted">등록된 그룹 사용자가 없습니다.</td>
|
<td colspan="4" class="text-muted">등록된 그룹 사용자가 없습니다.</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@@ -145,24 +171,35 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>그룹</th>
|
<th>그룹</th>
|
||||||
<th>역할</th>
|
<th>역할</th>
|
||||||
|
<th>해제 영향</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr th:each="mapping : ${groupRoles}" th:attr="data-group-id=${mapping.groupId()}">
|
<tr th:each="mapping : ${groupRoles}" th:attr="data-group-id=${mapping.groupId()}"
|
||||||
|
th:with="groupImpact=${groupImpactByGroupId[mapping.groupId()]},roleImpact=${roleImpactByRoleId[mapping.roleId()]}">
|
||||||
<td><code th:text="${mapping.groupCode()}">SALES_TEAM</code></td>
|
<td><code th:text="${mapping.groupCode()}">SALES_TEAM</code></td>
|
||||||
<td th:text="${mapping.roleName()}">SALES_ROLE</td>
|
<td th:text="${mapping.roleName()}">SALES_ROLE</td>
|
||||||
|
<td class="delete-impact">
|
||||||
|
<span>그룹 사용자가 이 역할 권한을 잃습니다.</span>
|
||||||
|
<strong th:text="${groupImpact == null || #lists.isEmpty(groupImpact.users()) ? '영향 사용자 없음' : #strings.listJoin(groupImpact.users(), ', ')}">영향 사용자 없음</strong>
|
||||||
|
<small th:text="${roleImpact == null || #lists.isEmpty(roleImpact.objectNames()) ? '권한 객체 없음' : #strings.listJoin(roleImpact.objectNames(), ', ')}">권한 객체 없음</small>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<form method="post" action="/groups/roles/delete" class="inline-form">
|
<form method="post" action="/groups/roles/delete" class="inline-form">
|
||||||
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}">
|
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}">
|
||||||
<input type="hidden" name="groupId" th:value="${mapping.groupId()}">
|
<input type="hidden" name="groupId" th:value="${mapping.groupId()}">
|
||||||
<input type="hidden" name="roleId" th:value="${mapping.roleId()}">
|
<input type="hidden" name="roleId" th:value="${mapping.roleId()}">
|
||||||
|
<label class="delete-confirm">
|
||||||
|
<input type="checkbox" name="confirmImpact" value="true" required>
|
||||||
|
영향 확인
|
||||||
|
</label>
|
||||||
<button class="btn btn-sm btn-outline-danger" type="submit">해제</button>
|
<button class="btn btn-sm btn-outline-danger" type="submit">해제</button>
|
||||||
</form>
|
</form>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr th:if="${#lists.isEmpty(groupRoles)}">
|
<tr th:if="${#lists.isEmpty(groupRoles)}">
|
||||||
<td colspan="3" class="text-muted">등록된 그룹 역할이 없습니다.</td>
|
<td colspan="4" class="text-muted">등록된 그룹 역할이 없습니다.</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
<section th:replace="~{fragments/layout :: architectureStrip('permission')}"></section>
|
<section th:replace="~{fragments/layout :: architectureStrip('permission')}"></section>
|
||||||
|
|
||||||
<div class="alert alert-success" th:if="${message}" th:text="${message}"></div>
|
<div class="alert alert-success" th:if="${message}" th:text="${message}"></div>
|
||||||
|
<div class="alert alert-danger" th:if="${error}" th:text="${error}"></div>
|
||||||
|
|
||||||
<section class="content-band">
|
<section class="content-band">
|
||||||
<div class="section-heading">
|
<div class="section-heading">
|
||||||
@@ -222,11 +223,13 @@
|
|||||||
<th>행 규칙</th>
|
<th>행 규칙</th>
|
||||||
<th>적용 필터</th>
|
<th>적용 필터</th>
|
||||||
<th>원문 표시 허용 컬럼</th>
|
<th>원문 표시 허용 컬럼</th>
|
||||||
|
<th>삭제 영향</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr th:each="permission : ${permissions}">
|
<tr th:each="permission : ${permissions}"
|
||||||
|
th:with="lastPermission=${lastPermissionByPermissionId[permission.permissionId()]}">
|
||||||
<td th:text="${permission.permissionId()}">100</td>
|
<td th:text="${permission.permissionId()}">100</td>
|
||||||
<td th:text="${permission.roleName()}">HR_DEPT_ROLE</td>
|
<td th:text="${permission.roleName()}">HR_DEPT_ROLE</td>
|
||||||
<td th:text="${permission.objectName()}">CB_V_SEARCH_DOCUMENTS</td>
|
<td th:text="${permission.objectName()}">CB_V_SEARCH_DOCUMENTS</td>
|
||||||
@@ -239,16 +242,26 @@
|
|||||||
<td th:text="${permission.rules()} ?: '-'">ALL</td>
|
<td th:text="${permission.rules()} ?: '-'">ALL</td>
|
||||||
<td><pre class="table-pre" th:text="${permission.filterPreview()} ?: '-'">ALL ROWS</pre></td>
|
<td><pre class="table-pre" th:text="${permission.filterPreview()} ?: '-'">ALL ROWS</pre></td>
|
||||||
<td th:text="${permission.visibleColumns()} ?: '-'">CONTENTS</td>
|
<td th:text="${permission.visibleColumns()} ?: '-'">CONTENTS</td>
|
||||||
|
<td class="delete-impact">
|
||||||
|
<span>역할이 이 TABLE/VIEW의 SELECT 권한을 잃습니다.</span>
|
||||||
|
<strong th:text="${permission.roleName() + ' -> ' + permission.objectName()}">ROLE -> OBJECT</strong>
|
||||||
|
<small th:if="${lastPermission}" class="text-danger">이 객체의 마지막 권한입니다. 삭제 후 보호 객체가 비활성화됩니다.</small>
|
||||||
|
<small th:unless="${lastPermission}">같은 객체에 다른 역할 권한이 남아 있습니다.</small>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<form method="post" action="/permissions/delete" class="inline-form">
|
<form method="post" action="/permissions/delete" class="inline-form">
|
||||||
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}">
|
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}">
|
||||||
<input type="hidden" name="permissionId" th:value="${permission.permissionId()}">
|
<input type="hidden" name="permissionId" th:value="${permission.permissionId()}">
|
||||||
|
<label class="delete-confirm">
|
||||||
|
<input type="checkbox" name="confirmImpact" value="true" required>
|
||||||
|
영향 확인
|
||||||
|
</label>
|
||||||
<button class="btn btn-sm btn-outline-danger" type="submit">삭제</button>
|
<button class="btn btn-sm btn-outline-danger" type="submit">삭제</button>
|
||||||
</form>
|
</form>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr th:if="${#lists.isEmpty(permissions)}">
|
<tr th:if="${#lists.isEmpty(permissions)}">
|
||||||
<td colspan="9" class="text-muted">등록된 권한이 없습니다.</td>
|
<td colspan="10" class="text-muted">등록된 권한이 없습니다.</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="alert alert-success" th:if="${message}" th:text="${message}"></div>
|
<div class="alert alert-success" th:if="${message}" th:text="${message}"></div>
|
||||||
|
<div class="alert alert-danger" th:if="${error}" th:text="${error}"></div>
|
||||||
|
|
||||||
<section class="content-band">
|
<section class="content-band">
|
||||||
<h2>역할 추가</h2>
|
<h2>역할 추가</h2>
|
||||||
@@ -45,11 +46,14 @@
|
|||||||
<th>ID</th>
|
<th>ID</th>
|
||||||
<th>역할명</th>
|
<th>역할명</th>
|
||||||
<th>민감도 허용 상한</th>
|
<th>민감도 허용 상한</th>
|
||||||
|
<th>삭제 영향</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr th:each="role : ${roles}">
|
<tr th:each="role : ${roles}"
|
||||||
|
th:with="impact=${roleImpactByRoleId[role.roleId()]},
|
||||||
|
hasDependencies=${impact != null && (!#lists.isEmpty(impact.directUsers()) || !#lists.isEmpty(impact.groups()) || impact.permissionCount() > 0)}">
|
||||||
<td th:text="${role.roleId()}">10</td>
|
<td th:text="${role.roleId()}">10</td>
|
||||||
<td th:text="${role.roleName()}">HR_DEPT_ROLE</td>
|
<td th:text="${role.roleName()}">HR_DEPT_ROLE</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -65,16 +69,42 @@
|
|||||||
<button class="btn btn-sm btn-outline-primary" type="submit">저장</button>
|
<button class="btn btn-sm btn-outline-primary" type="submit">저장</button>
|
||||||
</form>
|
</form>
|
||||||
</td>
|
</td>
|
||||||
|
<td class="delete-impact">
|
||||||
|
<div>
|
||||||
|
<span>직접 사용자</span>
|
||||||
|
<strong th:text="${impact == null || #lists.isEmpty(impact.directUsers()) ? '없음' : #strings.listJoin(impact.directUsers(), ', ')}">없음</strong>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<span>연결 그룹</span>
|
||||||
|
<strong th:text="${impact == null || #lists.isEmpty(impact.groups()) ? '없음' : #strings.listJoin(impact.groups(), ', ')}">없음</strong>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<span>영향 사용자</span>
|
||||||
|
<strong th:text="${impact == null || #lists.isEmpty(impact.affectedUsers()) ? '없음' : #strings.listJoin(impact.affectedUsers(), ', ')}">없음</strong>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<span>권한/객체</span>
|
||||||
|
<strong th:text="${impact == null ? '0건' : impact.permissionCount() + '건'}">0건</strong>
|
||||||
|
<small th:text="${impact == null || #lists.isEmpty(impact.objectNames()) ? '보호 객체 없음' : #strings.listJoin(impact.objectNames(), ', ')}">보호 객체 없음</small>
|
||||||
|
</div>
|
||||||
|
<p class="text-danger small mb-0" th:if="${hasDependencies}">연결을 먼저 해제해야 역할을 삭제할 수 있습니다.</p>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<form method="post" action="/roles/delete" class="inline-form">
|
<form method="post" action="/roles/delete" class="inline-form">
|
||||||
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}">
|
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}">
|
||||||
<input type="hidden" name="roleId" th:value="${role.roleId()}">
|
<input type="hidden" name="roleId" th:value="${role.roleId()}">
|
||||||
<button class="btn btn-sm btn-outline-danger" type="submit">삭제</button>
|
<label class="delete-confirm" th:classappend="${hasDependencies} ? ' disabled'">
|
||||||
|
<input type="checkbox" name="confirmImpact" value="true" required th:disabled="${hasDependencies}">
|
||||||
|
영향 확인
|
||||||
|
</label>
|
||||||
|
<button class="btn btn-sm btn-outline-danger" type="submit"
|
||||||
|
th:disabled="${hasDependencies}"
|
||||||
|
th:text="${hasDependencies} ? '연결 해제 필요' : '삭제'">삭제</button>
|
||||||
</form>
|
</form>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr th:if="${#lists.isEmpty(roles)}">
|
<tr th:if="${#lists.isEmpty(roles)}">
|
||||||
<td colspan="4" class="text-muted">등록된 역할이 없습니다.</td>
|
<td colspan="5" class="text-muted">등록된 역할이 없습니다.</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -173,6 +173,24 @@ class PermissionServiceTest {
|
|||||||
assertThat(disabled[0]).isTrue();
|
assertThat(disabled[0]).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void rejectsPermissionDeleteWithoutImpactConfirmation() {
|
||||||
|
assertThatThrownBy(() -> permissionService.deletePermission(1000L, false))
|
||||||
|
.isInstanceOf(AppException.class)
|
||||||
|
.hasMessageContaining("영향 확인");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void blocksRoleDeleteWhenDependenciesRemain() {
|
||||||
|
var mapper = new FakePermissionMapper();
|
||||||
|
mapper.userRoleCount = 1;
|
||||||
|
PermissionService service = new PermissionService(mapper, protectedObjectService, new AuditService(new NoopAuditMapper()));
|
||||||
|
|
||||||
|
assertThatThrownBy(() -> service.deleteRole(10L, true))
|
||||||
|
.isInstanceOf(AppException.class)
|
||||||
|
.hasMessageContaining("먼저 해제");
|
||||||
|
}
|
||||||
|
|
||||||
private static class NoopAuditMapper implements AuditMapper {
|
private static class NoopAuditMapper implements AuditMapper {
|
||||||
@Override
|
@Override
|
||||||
public void insert(AuditEvent event) {
|
public void insert(AuditEvent event) {
|
||||||
@@ -211,6 +229,25 @@ class PermissionServiceTest {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int userRoleCount;
|
||||||
|
private int groupRoleCount;
|
||||||
|
private int permissionCountByRole;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int countUserRolesByRoleId(long roleId) {
|
||||||
|
return userRoleCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int countGroupRolesByRoleId(long roleId) {
|
||||||
|
return groupRoleCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int countPermissionsByRoleId(long roleId) {
|
||||||
|
return permissionCountByRole;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PermissionView> findPermissionViews() {
|
public List<PermissionView> findPermissionViews() {
|
||||||
return List.of();
|
return List.of();
|
||||||
|
|||||||
Reference in New Issue
Block a user