Skip to content

Commit

Permalink
fix: 修复auth模块编译失败 TencentBlueKing#1585 (TencentBlueKing#1611)
Browse files Browse the repository at this point in the history
  • Loading branch information
cnlkl authored Jan 2, 2024
1 parent 0a6bbfd commit 7d24959
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ interface ServicePermissionClient {
@RequestParam userId: String
): Response<List<String>>

@ApiOperation("list有权限路径")
@ApiOperation("list无权限路径")
@GetMapping("/path/list")
fun listPermissionPath(
@ApiParam(value = "用户ID")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,17 @@
package com.tencent.bkrepo.auth.pojo.permission

import io.swagger.annotations.ApiModel
import com.tencent.bkrepo.common.query.enums.OperationType

@ApiModel("校验权限请求")
data class ListPathResult(
// when true, need to compare
val status: Boolean,
val path: Map<OperationType, List<String>>,
val path: Map<ListPathOperationType, List<String>>,
)

enum class ListPathOperationType {
/**
* 获取用户没有权限的路径
*/
NIN
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ package com.tencent.bkrepo.auth.controller.service
import com.tencent.bkrepo.auth.api.ServicePermissionClient
import com.tencent.bkrepo.auth.controller.OpenResource
import com.tencent.bkrepo.auth.pojo.permission.CheckPermissionRequest
import com.tencent.bkrepo.auth.pojo.permission.ListPathOperationType
import com.tencent.bkrepo.auth.pojo.permission.ListPathResult
import com.tencent.bkrepo.auth.service.PermissionService
import com.tencent.bkrepo.common.api.pojo.Response
import com.tencent.bkrepo.common.query.enums.OperationType
import com.tencent.bkrepo.common.service.util.ResponseBuilder
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.RestController
Expand All @@ -47,10 +47,13 @@ class ServicePermissionController @Autowired constructor(
private val permissionService: PermissionService
) : ServicePermissionClient, OpenResource(permissionService) {

/**
* 本接口不做权限校验,返回空列表时可能表示所有路径均有权限,也可能为无项目仓库权限,因此需要单独做仓库权限校验
*/
override fun listPermissionPath(userId: String, projectId: String, repoName: String): Response<ListPathResult> {
val permissionPath = permissionService.listPermissionPath(userId, projectId, repoName)
val status = permissionPath.isNotEmpty()
val result = ListPathResult(status = status, path = mapOf(OperationType.NIN to permissionPath))
val result = ListPathResult(status = status, path = mapOf(ListPathOperationType.NIN to permissionPath))
return ResponseBuilder.success(result)
}

Expand Down

0 comments on commit 7d24959

Please sign in to comment.