(improvement)(Headless) Fix model list auth checking (#883)

* (improvement)(Headless) Fix model list auth check

* (improvement)(Headless) Fix row permission

---------

Co-authored-by: jolunoluo
This commit is contained in:
LXW
2024-04-03 20:36:49 +08:00
committed by GitHub
parent ff56fd1e46
commit 6b60bfe6bc
3 changed files with 12 additions and 7 deletions

View File

@@ -306,11 +306,16 @@ public class ModelServiceImpl implements ModelService {
List<Long> domainIds = domainService.getDomainAuthSet(user, authType)
.stream().map(DomainResp::getId)
.collect(Collectors.toList());
if (domainIds.contains(domainId)) {
domainIds = Lists.newArrayList(domainId);
} else {
if (CollectionUtils.isEmpty(domainIds)) {
return Lists.newArrayList();
}
if (domainId != null) {
if (domainIds.contains(domainId)) {
domainIds = Lists.newArrayList(domainId);
} else {
return Lists.newArrayList();
}
}
ModelFilter modelFilter = new ModelFilter();
modelFilter.setIncludesDetail(false);
modelFilter.setDomainIds(domainIds);

View File

@@ -39,7 +39,7 @@ public class SchemaAuthTest extends BaseTest {
@Test
public void test_getModelList_alice() {
User user = DataUtils.getUserAlice();
List<ModelResp> modelResps = modelService.getModelListWithAuth(user, 0L, AuthType.ADMIN);
List<ModelResp> modelResps = modelService.getModelListWithAuth(user, null, AuthType.ADMIN);
List<Long> expectedModelIds = Lists.newArrayList(1L, 4L);
Assertions.assertEquals(expectedModelIds,
modelResps.stream().map(ModelResp::getId).collect(Collectors.toList()));
@@ -48,7 +48,7 @@ public class SchemaAuthTest extends BaseTest {
@Test
public void test_getVisibleModelList_alice() {
User user = DataUtils.getUserAlice();
List<ModelResp> modelResps = modelService.getModelListWithAuth(user, 0L, AuthType.VISIBLE);
List<ModelResp> modelResps = modelService.getModelListWithAuth(user, null, AuthType.VISIBLE);
List<Long> expectedModelIds = Lists.newArrayList(1L, 4L);
Assertions.assertEquals(expectedModelIds,
modelResps.stream().map(ModelResp::getId).collect(Collectors.toList()));
@@ -75,7 +75,7 @@ public class SchemaAuthTest extends BaseTest {
@Test
public void test_getModelList_jack() {
User user = DataUtils.getUserJack();
List<ModelResp> modelResps = modelService.getModelListWithAuth(user, 0L, AuthType.ADMIN);
List<ModelResp> modelResps = modelService.getModelListWithAuth(user, null, AuthType.ADMIN);
List<Long> expectedModelIds = Lists.newArrayList(1L, 2L, 3L);
Assertions.assertEquals(expectedModelIds,
modelResps.stream().map(ModelResp::getId).collect(Collectors.toList()));

View File

@@ -77,4 +77,4 @@ logging:
inMemoryEmbeddingStore:
persistent:
path: d://
path: /tmp