Skip to content

Commit

Permalink
Merge pull request #9196 from fcfang123/issue-9149
Browse files Browse the repository at this point in the history
对接RBAC权限优化 #9149
  • Loading branch information
mingshewhe authored Jul 25, 2023
2 parents 9e503a9 + 4565649 commit 38c2eea
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,27 @@ class ServiceTicketAuthResourceImpl @Autowired constructor(
override fun credentialInfo(callBackInfo: CallbackRequestDTO, token: String): CallbackBaseResponseDTO? {
val method = callBackInfo.method
val page = callBackInfo.page
val projectId = callBackInfo.filter.parent?.id ?: "" // FETCH_INSTANCE_INFO场景下iam不会传parentId
val projectId = callBackInfo.filter.parent?.id // FETCH_INSTANCE_INFO场景下iam不会传parentId
when (method) {
CallbackMethodEnum.LIST_INSTANCE -> {
return authCredentialService.getCredential(
projectId,
page.offset.toInt(),
page.limit.toInt(),
token
projectId = projectId ?: "",
offset = page.offset.toInt(),
limit = page.limit.toInt(),
token = token
)
}
CallbackMethodEnum.FETCH_INSTANCE_INFO -> {
val ids = callBackInfo.filter.idList.map { it.toString() }
return authCredentialService.getCredentialInfo(ids, token)
return authCredentialService.getCredentialInfo(
projectId = projectId,
ids = ids,
token = token
)
}
CallbackMethodEnum.SEARCH_INSTANCE -> {
return authCredentialService.searchCredential(
projectId = projectId,
projectId = projectId ?: "",
keyword = callBackInfo.filter.keyword,
limit = page.limit.toInt(),
offset = page.offset.toInt(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ class AuthCredentialService @Autowired constructor(
private val authTokenApi: AuthTokenApi
) {

fun getCredential(projectId: String, offset: Int, limit: Int, token: String): ListInstanceResponseDTO? {
fun getCredential(
projectId: String,
offset: Int,
limit: Int,
token: String
): ListInstanceResponseDTO? {
authTokenApi.checkToken(token)
val credentialInfos = credentialService.serviceList(projectId, offset, limit)
val result = ListInstanceInfo()
Expand All @@ -63,9 +68,13 @@ class AuthCredentialService @Autowired constructor(
return result.buildListInstanceResult(entityInfo, credentialInfos.count)
}

fun getCredentialInfo(ids: List<Any>?, token: String): FetchInstanceInfoResponseDTO? {
fun getCredentialInfo(
projectId: String?,
ids: List<Any>?,
token: String
): FetchInstanceInfoResponseDTO? {
authTokenApi.checkToken(token)
val credentialInfos = credentialService.getCredentialByIds(null, ids!!.toSet() as Set<String>)
val credentialInfos = credentialService.getCredentialByIds(projectId, ids!!.toSet() as Set<String>)
val result = FetchInstanceInfo()
if (credentialInfos == null || credentialInfos.isEmpty()) {
logger.info("$ids no credential")
Expand Down Expand Up @@ -95,7 +104,8 @@ class AuthCredentialService @Autowired constructor(
projectId = projectId,
offset = offset,
limit = limit,
credentialId = keyword)
credentialId = keyword
)
val result = SearchInstanceInfo()
if (credentialInfos?.records == null) {
logger.info("$projectId no cert")
Expand Down

0 comments on commit 38c2eea

Please sign in to comment.