fix #477: default vpd permission filter
This commit is contained in:
@@ -9,4 +9,12 @@ public record VpdPolicyFormOptions(
|
|||||||
List<VpdFunctionOption> functions,
|
List<VpdFunctionOption> functions,
|
||||||
List<String> statementTypes
|
List<String> statementTypes
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
public String defaultPermissionFunctionKey() {
|
||||||
|
return functions.stream()
|
||||||
|
.filter(function -> "CB_AGENT_DOC_VPD_FILTER".equalsIgnoreCase(function.functionName()))
|
||||||
|
.findFirst()
|
||||||
|
.map(VpdFunctionOption::value)
|
||||||
|
.orElse("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ public class VpdPolicyService {
|
|||||||
throw new AppException("선택한 스키마에서 VPD 적용 대상 TABLE/VIEW를 찾을 수 없습니다: " + owner);
|
throw new AppException("선택한 스키마에서 VPD 적용 대상 TABLE/VIEW를 찾을 수 없습니다: " + owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
FunctionRef functionRef = parseFunctionRef(functionKey);
|
FunctionRef functionRef = parseFunctionRef(defaultFunctionKey(functionKey));
|
||||||
String filterPredicate = filterPredicateValue == null ? "" : filterPredicateValue.trim();
|
String filterPredicate = filterPredicateValue == null ? "" : filterPredicateValue.trim();
|
||||||
if (functionRef == null && filterPredicate.isBlank()) {
|
if (functionRef == null && filterPredicate.isBlank()) {
|
||||||
throw new AppException("벌크 적용은 기존 Function을 선택하거나 Filter predicate를 입력해야 합니다.");
|
throw new AppException("벌크 적용은 기존 Function을 선택하거나 Filter predicate를 입력해야 합니다.");
|
||||||
@@ -231,7 +231,7 @@ public class VpdPolicyService {
|
|||||||
String objectName = requiredIdentifier(command.objectName(), "Object name");
|
String objectName = requiredIdentifier(command.objectName(), "Object name");
|
||||||
String policyName = requiredIdentifier(command.policyName(), "Policy name");
|
String policyName = requiredIdentifier(command.policyName(), "Policy name");
|
||||||
String currentUser = jdbcTemplate.queryForObject("SELECT USER FROM dual", String.class);
|
String currentUser = jdbcTemplate.queryForObject("SELECT USER FROM dual", String.class);
|
||||||
FunctionRef functionRef = parseFunctionRef(command.functionKey());
|
FunctionRef functionRef = parseFunctionRef(defaultFunctionKey(command.functionKey()));
|
||||||
String functionOwner;
|
String functionOwner;
|
||||||
String packageName;
|
String packageName;
|
||||||
String functionName;
|
String functionName;
|
||||||
@@ -503,6 +503,13 @@ public class VpdPolicyService {
|
|||||||
throw new AppException("Function 선택 값이 올바르지 않습니다: " + functionKey);
|
throw new AppException("Function 선택 값이 올바르지 않습니다: " + functionKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String defaultFunctionKey(String functionKey) {
|
||||||
|
if (functionKey != null && !functionKey.isBlank()) {
|
||||||
|
return functionKey;
|
||||||
|
}
|
||||||
|
return formOptions().defaultPermissionFunctionKey();
|
||||||
|
}
|
||||||
|
|
||||||
private String normalizeStatementTypes(String value) {
|
private String normalizeStatementTypes(String value) {
|
||||||
String raw = value == null || value.isBlank() ? "SELECT" : value;
|
String raw = value == null || value.isBlank() ? "SELECT" : value;
|
||||||
List<String> statements = List.of(raw.split(",")).stream()
|
List<String> statements = List.of(raw.split(",")).stream()
|
||||||
|
|||||||
@@ -146,12 +146,13 @@
|
|||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<label class="span-2">
|
<label class="span-2">
|
||||||
기존 Function 선택
|
VPD Filter Function
|
||||||
<select class="form-select" name="functionKey">
|
<select class="form-select" name="functionKey">
|
||||||
<option value="">Filter predicate로 새 function 자동 생성</option>
|
<option value="">기본 권한 함수가 없으면 Filter predicate로 새 function 자동 생성</option>
|
||||||
<option th:each="function : ${formOptions.functions()}"
|
<option th:each="function : ${formOptions.functions()}"
|
||||||
th:value="${function.value()}"
|
th:value="${function.value()}"
|
||||||
th:text="${function.label()}"></option>
|
th:text="${function.functionName() == 'CB_AGENT_DOC_VPD_FILTER' ? function.label() + ' / 기본 권한 테이블 필터' : function.label()}"
|
||||||
|
th:selected="${function.value() == formOptions.defaultPermissionFunctionKey()}"></option>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
@@ -274,10 +275,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<label class="span-2">
|
<label class="span-2">
|
||||||
기존 Function 선택
|
VPD Filter Function
|
||||||
<select class="form-select" name="functionKey">
|
<select class="form-select" name="functionKey">
|
||||||
<option value="">Filter predicate로 벌크 function 자동 생성</option>
|
<option value="">기본 권한 함수가 없으면 Filter predicate로 벌크 function 자동 생성</option>
|
||||||
<option th:each="function : ${formOptions.functions()}" th:value="${function.value()}" th:text="${function.label()}"></option>
|
<option th:each="function : ${formOptions.functions()}"
|
||||||
|
th:value="${function.value()}"
|
||||||
|
th:text="${function.functionName() == 'CB_AGENT_DOC_VPD_FILTER' ? function.label() + ' / 기본 권한 테이블 필터' : function.label()}"
|
||||||
|
th:selected="${function.value() == formOptions.defaultPermissionFunctionKey()}"></option>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -97,12 +97,13 @@
|
|||||||
placeholder="예: CB_AGENT_DOC_POLICY" required>
|
placeholder="예: CB_AGENT_DOC_POLICY" required>
|
||||||
</label>
|
</label>
|
||||||
<label class="span-2">
|
<label class="span-2">
|
||||||
기존 Function 선택
|
VPD Filter Function
|
||||||
<select class="form-select" name="functionKey">
|
<select class="form-select" name="functionKey">
|
||||||
<option value="">Filter predicate로 새 function 자동 생성</option>
|
<option value="">기본 권한 함수가 없으면 Filter predicate로 새 function 자동 생성</option>
|
||||||
<option th:each="function : ${formOptions.functions()}"
|
<option th:each="function : ${formOptions.functions()}"
|
||||||
th:value="${function.value()}"
|
th:value="${function.value()}"
|
||||||
th:text="${function.label()}"></option>
|
th:text="${function.functionName() == 'CB_AGENT_DOC_VPD_FILTER' ? function.label() + ' / 기본 권한 테이블 필터' : function.label()}"
|
||||||
|
th:selected="${function.value() == formOptions.defaultPermissionFunctionKey()}"></option>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
@@ -182,11 +183,14 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<label class="span-2">
|
<label class="span-2">
|
||||||
기존 Function 선택
|
VPD Filter Function
|
||||||
<select class="form-select" name="functionKey">
|
<select class="form-select" name="functionKey">
|
||||||
<option value="">Filter predicate로 벌크 function 자동 생성</option>
|
<option value="">기본 권한 함수가 없으면 Filter predicate로 벌크 function 자동 생성</option>
|
||||||
<option th:each="function : ${formOptions.functions()}" th:value="${function.value()}" th:text="${function.label()}"></option>
|
<option th:each="function : ${formOptions.functions()}"
|
||||||
|
th:value="${function.value()}"
|
||||||
|
th:text="${function.functionName() == 'CB_AGENT_DOC_VPD_FILTER' ? function.label() + ' / 기본 권한 테이블 필터' : function.label()}"
|
||||||
|
th:selected="${function.value() == formOptions.defaultPermissionFunctionKey()}"></option>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
Reference in New Issue
Block a user