261102_01_ENH: 프로젝트 접근 권한 확인 API 추가 및 공통 사용자 Context 적용

This commit is contained in:
2026-11-02 15:12:58 +09:00
parent 9bf9cbe135
commit 32b3d374a3
16 changed files with 168 additions and 21 deletions

View File

@@ -4,8 +4,10 @@ import com.kri.common.feature.web.BusinessException;
import com.kri.common.feature.web.RequestUserContext;
import com.kri.kart.server.common.consts.KartConstant;
import com.kri.kart.server.dto.log.VisitLogRequestDto;
import com.kri.kart.server.dto.project.ProjectRefDto;
import com.kri.kart.server.dto.share.ShareLinkDto;
import com.kri.kart.server.service.LogService;
import com.kri.kart.server.service.ProjectService;
import io.swagger.v3.oas.annotations.Parameter;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
@@ -23,6 +25,7 @@ import org.springframework.web.bind.annotation.RestController;
@ConditionalOnProperty(prefix = "kri.kart.database", name = "enabled", havingValue = "true")
public class LogController {
private final LogService logService;
private final ProjectService projectService;
@PostMapping(value = "/visit", produces = MediaType.TEXT_PLAIN_VALUE)
public String visit(
@@ -36,6 +39,12 @@ public class LogController {
|| !link.pkey().equals(request.pkey()))) {
throw BusinessException.forbidden("EXTERNAL_SCOPE_DENIED", "공유 프로젝트의 방문 로그만 기록할 수 있습니다.");
}
if (link == null && (request.projectType() != null || request.pkey() != null)) {
if (request.projectType() == null || request.pkey() == null) {
throw BusinessException.badRequest("projectType과 pkey를 함께 입력해 주세요.");
}
projectService.requireAccess(new ProjectRefDto(request.projectType(), request.pkey()), ctx);
}
logService.writeVisitLog(
request.projectType(), request.pkey(), request.logContent(), ctx);
return "PASS";