考虑两个实体
您想使用Spring Security过滤集合资源,因此覆盖它们的存储库的
Entity
和OtherEntity
,它们作为@RepositoryRestResource
暴露,通过@ManyToOne
关系链接(一个Entity
可能有几个OtherEntities
)。您想使用Spring Security过滤集合资源,因此覆盖它们的存储库的
Iterable<Entity> findAll()
函数。@RepositoryRestResource
@Repository
public interface EntityRepository extends CrudRepository<Entity, Long> {
@Override
@PostFilter("hasPermission(filterObject, 'READ')")
Iterable<Entity> findAll();
}
在调用GET /api/v1/entities
或者GET /api/v1/otherEntities
时,你会得到相应的权限过滤结果。
但是当调用它们的关联资源,GET /api/v1/entities/:id/otherEntities
,检索到的OtherEntity
元素列表没有被过滤。
哪个Repository函数应该被覆盖以使关联资源也被过滤?
或者还有其他方法可以实现这一点吗?