Skip to content

Commit

Permalink
(improvement)(Headless) Fix model list auth checking (#883)
Browse files Browse the repository at this point in the history
* (improvement)(Headless) Fix model list auth check

* (improvement)(Headless) Fix row permission

---------

Co-authored-by: jolunoluo
  • Loading branch information
lxwcodemonkey authored Apr 3, 2024
1 parent ff56fd1 commit 6b60bfe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,16 @@ public List<ModelResp> getModelRespAuthInheritDomain(User user, Long domainId, A
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void test_getDomainList_alice() {
@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()));
Expand All @@ -48,7 +48,7 @@ public void test_getModelList_alice() {
@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()));
Expand All @@ -75,7 +75,7 @@ public void test_getDomainList_jack() {
@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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ logging:

inMemoryEmbeddingStore:
persistent:
path: d://
path: /tmp

0 comments on commit 6b60bfe

Please sign in to comment.