Skip to content

Commit

Permalink
feat: IAM回调添加项目审批人 TencentBlueKing#5228 兼容V0,V3不同项目
Browse files Browse the repository at this point in the history
Signed-off-by: fitzcao <cao150260819@126.com>
  • Loading branch information
fitzcao committed Sep 24, 2021
1 parent 88c43f5 commit 902f086
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import com.tencent.devops.common.auth.callback.ListInstanceInfo
import com.tencent.devops.common.auth.callback.SearchInstanceInfo
import com.tencent.devops.common.client.Client
import com.tencent.devops.common.client.ClientTokenService
import com.tencent.devops.common.client.consul.ConsulContent
import com.tencent.devops.project.pojo.enums.ProjectChannelCode
import com.tencent.devops.project.service.ProjectService
import org.slf4j.LoggerFactory
Expand All @@ -54,7 +55,7 @@ class AuthProjectService @Autowired constructor(
val projectService: ProjectService,
val authTokenApi: AuthTokenApi,
val client: Client,
val tokenService: ClientTokenService,
val tokenService: ClientTokenService
) {

// 项目-管理员列表 缓存, 5分钟有效时间
Expand Down Expand Up @@ -139,11 +140,15 @@ class AuthProjectService @Autowired constructor(
if (projectManager.getIfPresent(projectCode) != null) {
return projectManager.getIfPresent(projectCode)!!
}
val managerUser = client.get(ServiceProjectAuthResource::class).getProjectUsers(
token = tokenService.getSystemToken(null)!!,
projectCode = projectCode,
group = BkAuthGroup.MANAGER
).data ?: emptyList()

val routerTag = projectService.getByEnglishName(projectCode)!!.routerTag
val managerUser = ConsulContent.invokeByTag(routerTag) {
client.get(ServiceProjectAuthResource::class).getProjectUsers(
token = tokenService.getSystemToken(null)!!,
projectCode = projectCode,
group = BkAuthGroup.MANAGER
).data ?: emptyList()
}
projectManager.put(projectCode, managerUser)
return managerUser
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ServiceProjectAuthCallBackResourceImpl @Autowired constructor(
CallbackMethodEnum.FETCH_INSTANCE_INFO -> {
val ids = callBackInfo.filter.idList.map { it.toString() }
val attribute = callBackInfo.filter.attribute
return authProjectService.getProjectInfo(ids, token)
return authProjectService.getProjectInfo(ids, token, attribute)
}
CallbackMethodEnum.SEARCH_INSTANCE -> {
return authProjectService.searchProjectInstances(callBackInfo.filter.keyword, page, token)
Expand Down

0 comments on commit 902f086

Please sign in to comment.