인증 서버 클라이언트 차단 API 추가:
- `ClientBlockApiController` 신규 생성 및 차단 로직 구현 - `ClientManService`에 클라이언트 차단 메서드 추가 - 승인 요청 삭제 로직 개발 환경 제한 문구 수정
This commit is contained in:
@@ -194,7 +194,7 @@
|
||||
<div class="title">승인 요청 목록<span class="tooltip">승인 요청을 관리합니다.</span></div>
|
||||
<c:if test="${hardDeleteEnabled}">
|
||||
<div style="background:#fff3cd; border:1px solid #ffc107; padding:8px 15px; margin:5px 0; border-radius:4px; color:#856404;">
|
||||
<strong>[주의]</strong> 선택 삭제 시 승인 요청과 승인자 이력이 DB에서 영구 삭제됩니다.
|
||||
<strong>[주의]</strong> 삭제 기능은 <strong>개발(dev) 환경에서만</strong> 동작합니다. 선택 삭제 시 승인 요청과 승인자 이력이 DB에서 영구 삭제됩니다.
|
||||
</div>
|
||||
</c:if>
|
||||
<form id="ajaxForm" onsubmit="return false;">
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.eactive.eai.rms.onl.apim.portalorg.PortalOrgManService;
|
||||
import com.eactive.eai.rms.onl.apim.portaluser.PortalUserManService;
|
||||
import com.eactive.eai.rms.onl.apim.portaluser.PortalUserUI;
|
||||
import com.eactive.eai.rms.common.acl.user.ui.UserUI;
|
||||
import com.eactive.eai.common.util.SystemUtil;
|
||||
import com.eactive.eai.rms.onl.common.exception.BizException;
|
||||
import com.eactive.eai.rms.onl.transaction.apim.ApiInterfaceService;
|
||||
import com.eactive.eai.rms.onl.transaction.apim.mapping.ApiSpecUIMapper;
|
||||
@@ -359,6 +360,10 @@ public class PortalApprovalManService extends BaseService {
|
||||
}
|
||||
|
||||
public boolean isHardDeleteEnabled() {
|
||||
// 승인 요청 완전삭제는 dev(개발) 환경에서만 허용
|
||||
if (!SystemUtil.isDevServer()) {
|
||||
return false;
|
||||
}
|
||||
Map<String, String> properties = portalPropertyService.getPortalPropertiesAsMap(PORTAL_PROPERTY_GROUP);
|
||||
return Boolean.parseBoolean(properties.getOrDefault(HARD_DELETE_FLAG_KEY, "false"));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.eactive.eai.rms.onl.apim.authserver;
|
||||
|
||||
import com.eactive.eai.agent.command.CommonCommand;
|
||||
import com.eactive.eai.rms.common.datasource.DataSourceContextHolder;
|
||||
import com.eactive.eai.rms.common.datasource.DataSourceType;
|
||||
import com.eactive.eai.rms.common.datasource.DataSourceTypeManager;
|
||||
import com.eactive.eai.rms.onl.apim.common.BaseRestController;
|
||||
import com.eactive.eai.rms.onl.common.service.AgentUtilService;
|
||||
import com.eactive.eai.rms.onl.manage.authserver.client.ClientManService;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
/**
|
||||
* 포털 등 내부 시스템이 호출하는 인증서버(GW) 클라이언트 제어용 내부 API.
|
||||
*
|
||||
* <p>{@link BaseRestController} 를 상속하여 ① 세션 인증을 skip(InterceptorSkipController)하고
|
||||
* ② {@code IpWhitelistInterceptor} 를 통해 {@code kjb.api.allow_ip_list} 기준 IP 화이트리스트
|
||||
* 인증을 적용받는다. (호출 측 포털 서버 IP를 반드시 허용목록에 등록해야 함)</p>
|
||||
*
|
||||
* @see com.eactive.eai.rms.common.interceptor.IpWhitelistInterceptor
|
||||
*/
|
||||
@Controller
|
||||
public class ClientBlockApiController extends BaseRestController {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ClientBlockApiController.class);
|
||||
|
||||
private final ClientManService clientManService;
|
||||
|
||||
@Qualifier("onlAgentUtilService")
|
||||
@Autowired
|
||||
private AgentUtilService agentUtilService;
|
||||
|
||||
@Autowired
|
||||
public ClientBlockApiController(ClientManService clientManService) {
|
||||
this.clientManService = clientManService;
|
||||
}
|
||||
|
||||
/**
|
||||
* clientId 의 GW 인증 클라이언트를 차단(TSEAIAU01.appstatus = '0')한 뒤,
|
||||
* 승인 경로와 동일하게 GW 인증서버로 RELOAD_CLIENT 명령을 broadcast 하여 캐시를 갱신한다.
|
||||
*
|
||||
* @param clientId 차단할 클라이언트 ID
|
||||
* @return 처리 결과 JSON ({@code {"success":true,"clientId":...}} 또는 {@code {"success":false,"msg":...}})
|
||||
*/
|
||||
@RequestMapping(value = "/onl/admin/authserver/clientBlock.json", method = RequestMethod.POST, produces = JSON_CONTENT_TYPE)
|
||||
@ResponseBody
|
||||
public String blockClient(@RequestParam String clientId) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
// TSEAIAU01(ClientEntity)은 APIGW 데이터소스에 있으므로 라우팅을 먼저 설정한다.
|
||||
DataSourceType type = DataSourceTypeManager.getDataSourceType("APIGW");
|
||||
DataSourceContextHolder.setDataSourceType(type);
|
||||
|
||||
// 상태 차단 (appstatus = '0')
|
||||
clientManService.blockClient(clientId);
|
||||
|
||||
// GW 인증서버 캐시 리로드 (승인 경로 PortalAppApprovalListener 와 동일)
|
||||
CommonCommand.builder()
|
||||
.name(CommonCommand.RELOAD_CLIENT_COMMAND)
|
||||
.args(clientId)
|
||||
.build().broadcast(agentUtilService);
|
||||
|
||||
logger.warn("GW client 차단(appstatus=0)+리로드 완료 - clientId={}", clientId);
|
||||
result.put("success", true);
|
||||
result.put("clientId", clientId);
|
||||
} catch (Exception e) {
|
||||
logger.error("GW client 차단 실패 - clientId={}", clientId, e);
|
||||
result.put("success", false);
|
||||
result.put("msg", e.getMessage());
|
||||
}
|
||||
return toJson(result);
|
||||
}
|
||||
}
|
||||
@@ -103,6 +103,18 @@ public class ClientManService extends OnlBaseService {
|
||||
clientEntityService.deleteById(clientId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 인증 클라이언트를 차단합니다. (appstatus = '0')
|
||||
* 삭제하지 않고 상태만 차단으로 변경합니다.
|
||||
*
|
||||
* @param clientId 차단할 클라이언트 ID
|
||||
*/
|
||||
public void blockClient(String clientId) {
|
||||
ClientEntity clientEntity = clientEntityService.getById(clientId);
|
||||
clientEntity.setAppstatus("0"); // 0: 차단, 1: 정상
|
||||
clientEntityService.save(clientEntity);
|
||||
}
|
||||
|
||||
|
||||
public List<String> findAll() {
|
||||
List<ClientEntity> clientList = clientEntityService.findAll();
|
||||
|
||||
Reference in New Issue
Block a user