Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:接入审计中心 #9414 #9543

Merged
merged 78 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
bd31da2
feat:接入审计中心 #9414
fcfang123 Sep 5, 2023
e902659
feat:接入审计中心 #9414
fcfang123 Sep 5, 2023
ef5f94d
feat:接入审计中心 #9414
fcfang123 Sep 6, 2023
0d8f0f5
feat:接入审计中心 #9414
fcfang123 Sep 7, 2023
e60cf08
feat:接入审计中心 #9414
fcfang123 Sep 7, 2023
11f8164
feat:接入审计中心 #9414
fcfang123 Sep 7, 2023
aa9faac
feat:接入审计中心 #9414
fcfang123 Sep 7, 2023
3aaae24
feat:接入审计中心 #9414
fcfang123 Sep 11, 2023
98d529f
feat:接入审计中心 #9414
fcfang123 Sep 12, 2023
9239e06
feat:接入审计中心 #9414
fcfang123 Sep 12, 2023
f269638
feat:接入审计中心 #9414
fcfang123 Sep 12, 2023
65559fa
feat:接入审计中心 #9414
fcfang123 Sep 12, 2023
48e84f5
feat:接入审计中心 #9414
fcfang123 Sep 15, 2023
fd1521f
feat:接入审计中心 #9414
fcfang123 Sep 18, 2023
10d49fd
feat:接入审计中心 #9414
fcfang123 Sep 21, 2023
7103c0e
feat:接入审计中心 #9414
fcfang123 Sep 21, 2023
45f486b
feat:接入审计中心 #9414
fcfang123 Sep 21, 2023
9183d6b
feat:接入审计中心 #9414
fcfang123 Sep 21, 2023
8465010
feat:接入审计中心 #9414
fcfang123 Sep 22, 2023
e04cb13
feat:接入审计中心 #9414
fcfang123 Sep 26, 2023
72c65aa
feat:接入审计中心 #9414
fcfang123 Sep 26, 2023
ae7ba5b
feat:接入审计中心 #9414
fcfang123 Sep 26, 2023
c9627b5
feat:接入审计中心 #9414
fcfang123 Oct 10, 2023
ab96b35
Merge branch 'tencent-master' into issue-9414
fcfang123 Oct 10, 2023
e31a967
feat:接入审计中心 #9414
fcfang123 Oct 10, 2023
6b18b94
feat:接入审计中心 #9414
fcfang123 Oct 10, 2023
d16df54
feat:接入审计中心 #9414
fcfang123 Oct 10, 2023
fa01366
Merge branch 'issue-9392' into issue-9414
fcfang123 Oct 10, 2023
639a8d7
feat:接入审计中心 #9414
fcfang123 Oct 10, 2023
b6a4f87
feat:接入审计中心 #9414
fcfang123 Oct 10, 2023
c6a4b40
feat:接入审计中心 #9414
fcfang123 Oct 11, 2023
610fadc
feat:接入审计中心 #9414
fcfang123 Oct 11, 2023
9d08fb7
feat:接入审计中心 #9414
fcfang123 Oct 12, 2023
470d49b
feat:接入审计中心 #9414
fcfang123 Oct 12, 2023
05c0731
feat:接入审计中心 #9414
fcfang123 Oct 12, 2023
c33fed1
feat:接入审计中心 #9414
fcfang123 Oct 12, 2023
12afaad
feat:接入审计中心 #9414
fcfang123 Oct 12, 2023
6633e32
feat:接入审计中心 #9414
fcfang123 Oct 12, 2023
24770c9
feat:接入审计中心 #9414
fcfang123 Oct 17, 2023
e0ed481
Merge branch 'tencent-master' into issue-9414
fcfang123 Oct 17, 2023
6344052
feat:接入审计中心 #9414
fcfang123 Oct 17, 2023
a6bdba2
feat:接入审计中心 #9414
fcfang123 Oct 19, 2023
c6b057a
feat:接入审计中心 #9414
fcfang123 Oct 19, 2023
94087ac
feat:接入审计中心 #9414
fcfang123 Oct 19, 2023
6ec377e
feat:接入审计中心 #9414
fcfang123 Oct 19, 2023
1c2879c
feat:接入审计中心 #9414
fcfang123 Oct 19, 2023
3ed2e2d
feat:接入审计中心 #9414
fcfang123 Oct 20, 2023
93c2b5b
Merge branch 'tencent-master' into issue-9414
fcfang123 Oct 20, 2023
024ae62
feat:接入审计中心 #9414
fcfang123 Oct 20, 2023
76e3b1c
feat:接入审计中心 #9414
fcfang123 Oct 26, 2023
62769e5
feat:接入审计中心 #9414
fcfang123 Oct 26, 2023
9afaedb
feat:接入审计中心 #9414
fcfang123 Oct 26, 2023
9f5ac1c
feat:接入审计中心 #9414
fcfang123 Oct 26, 2023
bdc598a
feat:接入审计中心 #9414
fcfang123 Oct 30, 2023
44a291b
feat:接入审计中心 #9414
fcfang123 Oct 30, 2023
ef6a8ca
feat:接入审计中心 #9414
fcfang123 Oct 30, 2023
97b4990
feat:接入审计中心 #9414
fcfang123 Nov 1, 2023
34a8702
feat:接入审计中心 #9414
fcfang123 Nov 8, 2023
9b802f0
Merge branch 'tencent-master' into issue-9414
fcfang123 Nov 8, 2023
58bf268
feat:接入审计中心 #9414
fcfang123 Nov 8, 2023
64a23f8
feat:接入审计中心 #9414
fcfang123 Nov 8, 2023
c5b6263
feat:接入审计中心 #9414
fcfang123 Nov 9, 2023
8fb9a51
feat:接入审计中心 #9414
fcfang123 Nov 9, 2023
d807eac
feat:接入审计中心 #9414
fcfang123 Nov 11, 2023
0fa8b2a
feat:接入审计中心 #9414
fcfang123 Nov 11, 2023
cdfe290
feat:接入审计中心 #9414
fcfang123 Nov 11, 2023
7dab269
feat:接入审计中心 #9414
fcfang123 Nov 13, 2023
f145f96
Merge branch 'tencent-master' into issue-9414
fcfang123 Nov 13, 2023
723c82e
feat:接入审计中心 #9414
fcfang123 Nov 15, 2023
0320e8c
feat:接入审计中心 #9414
fcfang123 Nov 17, 2023
7e9a65a
Merge branch 'tencent-master' into issue-9414
fcfang123 Nov 17, 2023
595d4e4
feat:接入审计中心 #9414
fcfang123 Nov 17, 2023
35a68d8
feat:接入审计中心 #9414
fcfang123 Nov 17, 2023
0720524
feat:接入审计中心 #9414
fcfang123 Nov 20, 2023
e9c7276
feat:接入审计中心 #9414
fcfang123 Nov 20, 2023
fdc36dd
feat:接入审计中心 #9414
fcfang123 Nov 20, 2023
6d61eb3
feat:接入审计中心 #9414
fcfang123 Nov 20, 2023
b5ee66d
feat:接入审计中心 #9414
fcfang123 Nov 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion scripts/bkenv.properties
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@ BK_CI_OPENAPI_API_PUB_OUTER=
BK_CI_OPENAPI_API_AUTH=true
# BK_CI_OPENAPI_VERIFY_PROJECT 在 blueking api filter 中使用,是否开启projectId强校验。
BK_CI_OPENAPI_VERIFY_PROJECT=false

# 是否开启审计,默认不开启
BK_CI_AUDIT_ENABLED=false

##########
# 4-微服务依赖
Expand Down
4 changes: 2 additions & 2 deletions src/backend/ci/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ apply(plugin = "org.owasp.dependencycheck")

allprojects {
apply(plugin = "com.tencent.devops.boot")

// 包路径
group = "com.tencent.bk.devops.ci"
// 版本
version = (System.getProperty("ci_version") ?: "1.9.0") +
if (System.getProperty("snapshot") == "true") "-SNAPSHOT" else ""
if (System.getProperty("snapshot") == "true") "-SNAPSHOT" else ""

// 加载boot的插件
if (name.startsWith("boot-")) {
Expand Down Expand Up @@ -126,6 +125,7 @@ allprojects {
entry("org.eclipse.jgit.ssh.jsch")
}
dependency("com.tencent.bk.sdk:iam-java-sdk:${Versions.iam}")
dependency("com.tencent.bk.sdk:spring-boot-bk-audit-starter:${Versions.audit}")
dependency("com.jakewharton:disklrucache:${Versions.disklrucache}")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ object Versions {
const val jgit = "5.13.1.202206130422-r"
const val iam = "1.0.0"
const val disklrucache = "2.0.2"
const val audit = "1.0.8"
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dependencies {
api(project(":core:common:common-archive"))
api(project(":core:common:common-db"))
api(project(":core:common:common-auth:common-auth-api"))
api(project(":core:common:common-audit"))
api(project(":core:artifactory:api-artifactory"))
api(project(":core:artifactory:model-artifactory"))
api(project(":core:project:api-project"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const val LOCALE_LANGUAGE = "BK_CI_LOCALE_LANGUAGE" // locale国际化语言信
const val DEFAULT_LOCALE_LANGUAGE = "zh_CN" // 默认语言信息
const val REQUEST_CHANNEL = "BK_CI_REQUEST_CHANNEL" // 请求渠道
const val API_PERMISSION = "BK_CI_API_PERMISSION" // 请求API权限
const val REQUEST_IP = "X-Forwarded-For" // 请求IP
const val BK_CREATE = "bkCreate" // 创建
const val BK_REVISE = "bkRevise" // 修改

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ enum class RequestChannelTypeEnum {
SERVICE,
BUILD,
OP,
OPEN
OPEN,
API
}
4 changes: 4 additions & 0 deletions src/backend/ci/core/common/common-audit/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dependencies {
api("com.tencent.bk.sdk:spring-boot-bk-audit-starter")
api(project(":core:common:common-web"))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package com.tencent.devops.common.audit

import com.tencent.bk.audit.constants.AuditAttributeNames.INSTANCE_ID
import com.tencent.bk.audit.constants.AuditAttributeNames.INSTANCE_NAME

@Suppress("MaxLineLength")
object ActionAuditContent {
private const val CONTENT_TEMPLATE = "[{{$INSTANCE_NAME}}]({{$INSTANCE_ID}})"
private const val PROJECT_CODE_CONTENT_TEMPLATE = "[{{@PROJECT_CODE}}]"
const val PROJECT_CODE_TEMPLATE = "@PROJECT_CODE"
const val BUILD_ID_TEMPLATE = "@BUILD_ID"
const val ASSIGNS_TEMPLATE = "@ASSIGNS"

// 项目
const val PROJECT_MANAGE_RESTORE_PIPELINE_CONTENT = "restore pipeline $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"

// 流水线
const val PIPELINE_VIEW_CONTENT = "get pipeline info $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val PIPELINE_SHARE_CONTENT = "share pipeline $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val PIPELINE_CREATE_CONTENT = "create pipeline $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val PIPELINE_LIST_CONTENT = "list pipeline $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val PIPELINE_DOWNLOAD_CONTENT = "download pipeline $CONTENT_TEMPLATE buildId [{{$BUILD_ID_TEMPLATE}}] " +
"in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val PIPELINE_EDIT_CONTENT = "update pipeline $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val PIPELINE_EDIT_SAVE_SETTING_CONTENT = "save pipeline setting $CONTENT_TEMPLATE " +
"in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val PIPELINE_EDIT_EXPORT_PIPELINE_CONTENT = "export pipeline $CONTENT_TEMPLATE " +
"in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val PIPELINE_EDIT_BIND_PIPELINE_CALLBACK_CONTENT = "bind pipeline call back $CONTENT_TEMPLATE" +
" in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val PIPELINE_DELETE_CONTENT = "delete pipeline $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val PIPELINE_DELETE_VERSION_CONTENT = "delete pipeline version $CONTENT_TEMPLATE " +
"in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val PIPELINE_EXECUTE_CONTENT = "execute pipeline $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"

// 流水线模板
const val PIPELINE_TEMPLATE_CREATE_CONTENT = "create template $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val PIPELINE_TEMPLATE_EDIT_COPY_CONTENT = "copy template $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val PIPELINE_TEMPLATE_EDIT_SAVE_AS_CONTENT = "save as template $CONTENT_TEMPLATE " +
"in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val PIPELINE_TEMPLATE_DELETE_CONTENT = "delete template $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val PIPELINE_TEMPLATE_EDIT_SETTING_CONTENT = "update template setting $CONTENT_TEMPLATE " +
"in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val PIPELINE_TEMPLATE_EDIT_CONTENT = "update template $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"

// 证书
const val CERT_CREATE_CONTENT = "create cert $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val CERT_VIEW_CONTENT = "get cert info $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val CERT_EDIT_CONTENT = "update cert $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val CERT_DELETE_CONTENT = "delete cert $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val CERT_LIST_CONTENT = "list cert $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val CERT_USE_CONTENT = "use cert $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"

// 凭据
const val CREDENTIAL_CREATE_CONTENT = "create credential $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val CREDENTIAL_VIEW_CONTENT = "get credential info $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val CREDENTIAL_EDIT_CONTENT = "update credential $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val CREDENTIAL_EDIT_SETTING_CONTENT = "update credential setting $CONTENT_TEMPLATE " +
"in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val CREDENTIAL_DELETE_CONTENT = "delete credential $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val CREDENTIAL_LIST_CONTENT = "list credential $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val CREDENTIAL_USE_CONTENT = "use credential $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"

// 云桌面
const val CGS_CREATE_CONTENT = "create workspace $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val CGS_LIST_CONTENT = "list workspace $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val CGS_VIEW_CONTENT = "get workspace $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val CGS_STOP_CONTENT = "stop workspace $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val CGS_START_CONTENT = "start workspace $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val CGS_RESTART_CONTENT = "restart workspace $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val CGS_ASSIGN_USER_CONTENT = "assign workspace $CONTENT_TEMPLATE " +
"to [{{$ASSIGNS_TEMPLATE}}] from $PROJECT_CODE_CONTENT_TEMPLATE"
const val CGS_ASSIGN_PROJECT_CONTENT = "assign workspace $CONTENT_TEMPLATE to project $PROJECT_CODE_CONTENT_TEMPLATE"
const val CGS_EDIT_TYPE_CONTENT = "modify workspace type $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val CGS_REBUILD_SYSTEM_DISK_CONTENT = "rebuild workspace system disk $CONTENT_TEMPLATE " +
"in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val CGS_MAKE_IMAGE_CONTENT = "make workspace image $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val CGS_EXPAND_DISK_CONTENT = "expand workspace disk $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val CGS_DELETE_CONTENT = "delete workspace $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val CGS_SHARE_CONTENT = "share workspace $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val CGS_EDIT_CONTENT = "edit workspace $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"

// 云桌面镜像
const val IMAGE_LIST_CONTENT = "list workspace image $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val IMAGE_DELETE_CONTENT = "delete workspace image $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val IMAGE_EDIT_CONTENT = "modify workspace image $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"

// 代理仓库
const val CODE_PROXY_CREATE_CONTENT = "create code proxy $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val CODE_PROXY_LIST_CONTENT = "list code proxy $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
const val CODE_PROXY_DELETE_CONTENT = "delete code proxy $CONTENT_TEMPLATE in project $PROJECT_CODE_CONTENT_TEMPLATE"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.tencent.devops.common.audit

import com.tencent.bk.audit.AuditRequestProvider
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Primary

@Configuration
@ConditionalOnProperty(name = ["audit.enabled"], havingValue = "true", matchIfMissing = true)
class BkAuditConfiguration {
@Bean
@Primary
fun bkAuditRequestProvider(): AuditRequestProvider {
return BkAuditRequestProvider()
}

@Bean
fun bkAuditPostFilter(): BkAuditPostFilter {
return BkAuditPostFilter()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.tencent.devops.common.audit

import com.tencent.bk.audit.filter.AuditPostFilter
import com.tencent.bk.audit.model.AuditEvent

class BkAuditPostFilter : AuditPostFilter {
override fun map(auditEvent: AuditEvent): AuditEvent {
auditEvent.scopeType = "project"
return auditEvent
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package com.tencent.devops.common.audit

import com.tencent.bk.audit.AuditRequestProvider
import com.tencent.bk.audit.constants.AccessTypeEnum
import com.tencent.bk.audit.constants.UserIdentifyTypeEnum
import com.tencent.bk.audit.exception.AuditException
import com.tencent.bk.audit.model.AuditHttpRequest
import com.tencent.devops.common.api.auth.AUTH_HEADER_USER_ID
import com.tencent.devops.common.api.constant.REQUEST_CHANNEL
import com.tencent.devops.common.api.constant.REQUEST_IP
import com.tencent.devops.common.api.enums.RequestChannelTypeEnum
import org.slf4j.LoggerFactory
import org.springframework.web.context.request.RequestContextHolder
import org.springframework.web.context.request.ServletRequestAttributes
import javax.servlet.http.HttpServletRequest

class BkAuditRequestProvider : AuditRequestProvider {
companion object {
private const val HEADER_USER_IDENTIFY_TENANT_ID = "X-User-Identify-Tenant-Id"
private const val HEADER_USER_IDENTIFY_TYPE = "X-User-Identify-Type"
private const val HEADER_REQUEST_ID = "X-DEVOPS-RID"
private val logger = LoggerFactory.getLogger(BkAuditRequestProvider::class.java)
}

override fun getRequest(): AuditHttpRequest {
val httpServletRequest: HttpServletRequest = getHttpServletRequest()
return AuditHttpRequest(httpServletRequest)
}

private fun getHttpServletRequest(): HttpServletRequest {
val requestAttributes = RequestContextHolder.getRequestAttributes()
if (requestAttributes == null) {
logger.error("Could not get RequestAttributes from RequestContext!")
throw AuditException("Parse http request error")
}
return (requestAttributes as ServletRequestAttributes).request
}

override fun getUsername(): String? {
val httpServletRequest = getHttpServletRequest()
return httpServletRequest.getHeader(AUTH_HEADER_USER_ID)
}

override fun getUserIdentifyType(): UserIdentifyTypeEnum? {
val httpServletRequest = getHttpServletRequest()
return UserIdentifyTypeEnum.valOf(
httpServletRequest.getHeader(HEADER_USER_IDENTIFY_TYPE)
)
}

override fun getUserIdentifyTenantId(): String? {
val httpServletRequest = getHttpServletRequest()
return httpServletRequest.getHeader(HEADER_USER_IDENTIFY_TENANT_ID)
}

override fun getAccessType(): AccessTypeEnum {
val httpServletRequest = getHttpServletRequest()
val requestChannel = (httpServletRequest.getAttribute(REQUEST_CHANNEL)
?: httpServletRequest.getHeader(REQUEST_CHANNEL))?.toString()
logger.debug("get request channel:$requestChannel")
return when (requestChannel) {
RequestChannelTypeEnum.USER.name,
RequestChannelTypeEnum.OP.name -> AccessTypeEnum.WEB
RequestChannelTypeEnum.API.name -> AccessTypeEnum.API
else -> AccessTypeEnum.OTHER
}
}

override fun getRequestId(): String? {
val httpServletRequest = getHttpServletRequest()
return httpServletRequest.getHeader(HEADER_REQUEST_ID)
}

override fun getClientIp(): String? {
val request = getHttpServletRequest()
val xff = request.getHeader(REQUEST_IP)
return if (xff == null) {
request.remoteAddr
} else {
if (xff.contains(",")) xff.split(",".toRegex()).toTypedArray()[0] else xff
}
}

override fun getUserAgent(): String? {
val request = getHttpServletRequest()
return request.getHeader("User-Agent")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.tencent.devops.common.audit.BkAuditConfiguration
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.tencent.devops.common.auth.api

object ActionId {
// 项目
const val PROJECT_MANAGE = "project_manage"

// 流水线
const val PIPELINE_CREATE = "pipeline_create"
const val PIPELINE_VIEW = "pipeline_view"
const val PIPELINE_EDIT = "pipeline_edit"
const val PIPELINE_DELETE = "pipeline_delete"
const val PIPELINE_EXECUTE = "pipeline_execute"
const val PIPELINE_LIST = "pipeline_list"
const val PIPELINE_SHARE = "pipeline_share"
const val PIPELINE_DOWNLOAD = "pipeline_download"

// 流水线模板
const val PIPELINE_TEMPLATE_CREATE = "pipeline_template_create"
const val PIPELINE_TEMPLATE_EDIT = "pipeline_template_edit"
const val PIPELINE_TEMPLATE_DELETE = "pipeline_template_delete"

// 凭据
const val CREDENTIAL_CREATE = "credential_create"
const val CREDENTIAL_VIEW = "credential_view"
const val CREDENTIAL_EDIT = "credential_edit"
const val CREDENTIAL_DELETE = "credential_delete"
const val CREDENTIAL_LIST = "credential_list"
const val CREDENTIAL_USE = "credential_use"

// 证书
const val CERT_CREATE = "cert_create"
const val CERT_VIEW = "cert_view"
const val CERT_EDIT = "cert_edit"
const val CERT_DELETE = "cert_delete"
const val CERT_LIST = "cert_list"
const val CERT_USE = "cert_use"

// 云桌面
const val CGS_CREATE = "cgs_create"
const val CGS_LIST = "cgs_list"
const val CGS_VIEW = "cgs_view"
const val CGS_STOP = "cgs_stop"
const val CGS_START = "cgs_start"
const val CGS_RESTART = "cgs_restart"
const val CGS_ASSIGN = "cgs_assign"
const val CGS_EDIT_TYPE = "cgs_edit-type"
const val CGS_REBUILD_SYSTEM_DISK = "cgs_rebuild-system-disk"
const val CGS_MAKE_IMAGE = "cgs_make-image"
const val CGS_EXPAND_DISK = "cgs_expand-disk"
const val CGS_DELETE = "cgs_delete"
const val CGS_SHARE = "cgs_share"
const val CGS_EDIT = "cgs_edit"

// 镜像
const val IMAGE_LIST = "image_list"
const val IMAGE_DELETE = "image_delete"
const val IMAGE_EDIT = "image_edit"

// 代理仓库
const val CODE_PROXY_CREATE = "code_proxy_create"
const val CODE_PROXY_LIST = "code_proxy_list"
const val CODE_PROXY_DELETE = "code_proxy_delete"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.tencent.devops.common.auth.api

object ResourceTypeId {
const val PROJECT = "project"
const val PIPELINE = "pipeline"
const val PIPELINE_TEMPLATE = "pipeline_template"
const val CREDENTIAL = "credential"
const val CERT = "cert"
const val CGS = "cgs"
const val IMAGE = "image"
const val CODE_PROXY = "code_proxy"
}
Loading