From e1611a5e2376fadf499c8e01aff8f62f4ca2e53c Mon Sep 17 00:00:00 2001 From: mingshewhe Date: Thu, 24 Oct 2024 19:58:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BC=95=E6=93=8E=E7=AD=89MQ=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=E6=8E=A5=E5=85=A5SCS=E6=A1=86=E6=9E=B6=20#7443?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/common/AuthCoreConfiguration.kt | 24 ++++++----- .../refresh/event/IamCacheRefreshEvent.kt | 40 ------------------- .../event/ManagerOrganizationChangeEvent.kt | 2 +- .../refresh/event/ManagerUserChangeEvent.kt | 2 +- .../refresh/event/RefreshBroadCastEvent.kt | 3 -- .../auth/refresh/event/StrategyUpdateEvent.kt | 2 +- .../common/stream/constants/StreamBinding.kt | 6 ++- 7 files changed, 21 insertions(+), 58 deletions(-) delete mode 100644 src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/refresh/event/IamCacheRefreshEvent.kt diff --git a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/common/AuthCoreConfiguration.kt b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/common/AuthCoreConfiguration.kt index fbcbdfd1c9c..15340a7a3e4 100644 --- a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/common/AuthCoreConfiguration.kt +++ b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/common/AuthCoreConfiguration.kt @@ -29,10 +29,11 @@ package com.tencent.devops.auth.common import com.tencent.devops.auth.filter.BlackListAspect import com.tencent.devops.auth.refresh.dispatch.AuthRefreshDispatch -import com.tencent.devops.auth.refresh.event.RefreshBroadCastEvent +import com.tencent.devops.auth.refresh.event.ManagerOrganizationChangeEvent +import com.tencent.devops.auth.refresh.event.ManagerUserChangeEvent +import com.tencent.devops.auth.refresh.event.StrategyUpdateEvent import com.tencent.devops.auth.refresh.listener.AuthRefreshEventListener import com.tencent.devops.auth.service.AuthUserBlackListService -import com.tencent.devops.auth.service.UserPermissionService import com.tencent.devops.common.event.annotation.EventConsumer import com.tencent.devops.common.stream.ScsConsumerBuilder import org.springframework.beans.factory.annotation.Autowired @@ -46,17 +47,20 @@ class AuthCoreConfiguration { @Bean fun refreshDispatch(streamBridge: StreamBridge) = AuthRefreshDispatch(streamBridge) - @Bean - fun authRefreshEventListener( - @Autowired userPermissionService: UserPermissionService - ) = AuthRefreshEventListener( - userPermissionService = userPermissionService - ) + @EventConsumer(true) + fun managerChangeConsumer( + @Autowired refreshListener: AuthRefreshEventListener + ) = ScsConsumerBuilder.build { refreshListener.execute(it) } + + @EventConsumer(true) + fun managerUserChangeConsumer( + @Autowired refreshListener: AuthRefreshEventListener + ) = ScsConsumerBuilder.build { refreshListener.execute(it) } @EventConsumer(true) - fun refreshBroadCastConsumer( + fun strategyUpdateConsumer( @Autowired refreshListener: AuthRefreshEventListener - ) = ScsConsumerBuilder.build { refreshListener.execute(it) } + ) = ScsConsumerBuilder.build { refreshListener.execute(it) } @Bean fun blackListAspect(authUserBlackListService: AuthUserBlackListService) = BlackListAspect(authUserBlackListService) diff --git a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/refresh/event/IamCacheRefreshEvent.kt b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/refresh/event/IamCacheRefreshEvent.kt deleted file mode 100644 index 4c0752badbd..00000000000 --- a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/refresh/event/IamCacheRefreshEvent.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. - * - * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. - * - * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. - * - * A copy of the MIT License is included in this file. - * - * - * Terms of the MIT License: - * --------------------------------------------------- - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies or substantial portions of - * the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT - * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package com.tencent.devops.auth.refresh.event - -import com.tencent.devops.common.event.annotation.Event -import com.tencent.devops.common.stream.constants.StreamBinding - -@Event(destination = StreamBinding.AUTH_REFRESH_FANOUT) -data class IamCacheRefreshEvent( - override val refreshType: String, - override var retryCount: Int = 0, - override var delayMills: Int = 0, - val userId: String, - val resourceType: String -) : RefreshBroadCastEvent(refreshType, retryCount, delayMills) diff --git a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/refresh/event/ManagerOrganizationChangeEvent.kt b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/refresh/event/ManagerOrganizationChangeEvent.kt index 69d6ddc9bcd..bd3f85acbb5 100644 --- a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/refresh/event/ManagerOrganizationChangeEvent.kt +++ b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/refresh/event/ManagerOrganizationChangeEvent.kt @@ -31,7 +31,7 @@ import com.tencent.devops.auth.entity.ManagerChangeType import com.tencent.devops.common.event.annotation.Event import com.tencent.devops.common.stream.constants.StreamBinding -@Event(destination = StreamBinding.AUTH_REFRESH_FANOUT) +@Event(destination = StreamBinding.AUTH_MANGER_CHANGE_FANOUT) data class ManagerOrganizationChangeEvent( override val refreshType: String, override var retryCount: Int = 0, diff --git a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/refresh/event/ManagerUserChangeEvent.kt b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/refresh/event/ManagerUserChangeEvent.kt index 3a1bf736475..25b1fbaa97d 100644 --- a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/refresh/event/ManagerUserChangeEvent.kt +++ b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/refresh/event/ManagerUserChangeEvent.kt @@ -31,7 +31,7 @@ import com.tencent.devops.auth.entity.UserChangeType import com.tencent.devops.common.event.annotation.Event import com.tencent.devops.common.stream.constants.StreamBinding -@Event(destination = StreamBinding.AUTH_REFRESH_FANOUT) +@Event(destination = StreamBinding.AUTH_MANGER_USER_CHANGE_FANOUT) data class ManagerUserChangeEvent( override val refreshType: String, val userChangeType: UserChangeType, diff --git a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/refresh/event/RefreshBroadCastEvent.kt b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/refresh/event/RefreshBroadCastEvent.kt index 81783ed2ca8..62d10051bc8 100644 --- a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/refresh/event/RefreshBroadCastEvent.kt +++ b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/refresh/event/RefreshBroadCastEvent.kt @@ -27,13 +27,10 @@ package com.tencent.devops.auth.refresh.event -import com.tencent.devops.common.event.annotation.Event import com.tencent.devops.common.event.pojo.IEvent import com.tencent.devops.common.service.trace.TraceTag -import com.tencent.devops.common.stream.constants.StreamBinding import org.slf4j.MDC -@Event(StreamBinding.AUTH_REFRESH_FANOUT) open class RefreshBroadCastEvent( open val refreshType: String, open var retryCount: Int, diff --git a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/refresh/event/StrategyUpdateEvent.kt b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/refresh/event/StrategyUpdateEvent.kt index 8750d3d01b6..d4f5a47c7a7 100644 --- a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/refresh/event/StrategyUpdateEvent.kt +++ b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/refresh/event/StrategyUpdateEvent.kt @@ -31,7 +31,7 @@ import com.tencent.devops.auth.entity.StrategyChangeType import com.tencent.devops.common.event.annotation.Event import com.tencent.devops.common.stream.constants.StreamBinding -@Event(destination = StreamBinding.AUTH_REFRESH_FANOUT) +@Event(destination = StreamBinding.AUTH_STRATEGY_UPDATE_FANOUT) data class StrategyUpdateEvent( override val refreshType: String, override var retryCount: Int = 0, diff --git a/src/backend/ci/core/common/common-event/src/main/kotlin/com/tencent/devops/common/stream/constants/StreamBinding.kt b/src/backend/ci/core/common/common-event/src/main/kotlin/com/tencent/devops/common/stream/constants/StreamBinding.kt index c5faabdb712..2df7340eae3 100644 --- a/src/backend/ci/core/common/common-event/src/main/kotlin/com/tencent/devops/common/stream/constants/StreamBinding.kt +++ b/src/backend/ci/core/common/common-event/src/main/kotlin/com/tencent/devops/common/stream/constants/StreamBinding.kt @@ -168,7 +168,9 @@ object StreamBinding { const val GIT_WEBHOOK_UNLOCK_EVENT = "webhook.unlock.event" // 蓝盾管理员 - const val AUTH_REFRESH_FANOUT = "auth.refresh.exchange.fanout" + const val AUTH_MANGER_CHANGE_FANOUT = "auth.manager.change.fanout" + const val AUTH_MANGER_USER_CHANGE_FANOUT = "auth.manager.user.change.fanout" + const val AUTH_STRATEGY_UPDATE_FANOUT = "auth.strategy.update.fanout" // 流水线webhook commit记录 const val PIPELINE_BUILD_COMMIT_FINISH_FANOUT = "engine.pipeline.build.commits.finish.fanout" @@ -204,4 +206,4 @@ object StreamBinding { const val PIPELINE_YAML_LISTENER_ENABLE = "pipeline.yaml.listener.enable" const val PIPELINE_YAML_LISTENER_DISABLE = "pipeline.yaml.listener.disable" const val PIPELINE_YAML_LISTENER_TRIGGER = "pipeline.yaml.listener.trigger" -} \ No newline at end of file +}