Skip to content

Commit 273e64c

Browse files
BE: RBAC: Impl separate permissions for topic analysis (#513)
Co-authored-by: Roman Zabaluev <gpg@haarolean.dev>
1 parent 2bb9d5c commit 273e64c

File tree

5 files changed

+17
-9
lines changed

5 files changed

+17
-9
lines changed

api/src/main/java/io/kafbat/ui/controller/TopicsController.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package io.kafbat.ui.controller;
22

3+
import static io.kafbat.ui.model.rbac.permission.TopicAction.ANALYSIS_RUN;
4+
import static io.kafbat.ui.model.rbac.permission.TopicAction.ANALYSIS_VIEW;
35
import static io.kafbat.ui.model.rbac.permission.TopicAction.CREATE;
46
import static io.kafbat.ui.model.rbac.permission.TopicAction.DELETE;
57
import static io.kafbat.ui.model.rbac.permission.TopicAction.EDIT;
6-
import static io.kafbat.ui.model.rbac.permission.TopicAction.MESSAGES_READ;
78
import static io.kafbat.ui.model.rbac.permission.TopicAction.VIEW;
89
import static java.util.stream.Collectors.toList;
910

@@ -272,7 +273,7 @@ public Mono<ResponseEntity<Void>> analyzeTopic(String clusterName, String topicN
272273

273274
var context = AccessContext.builder()
274275
.cluster(clusterName)
275-
.topicActions(topicName, MESSAGES_READ)
276+
.topicActions(topicName, ANALYSIS_RUN)
276277
.operationName("analyzeTopic")
277278
.build();
278279

@@ -288,7 +289,7 @@ public Mono<ResponseEntity<Void>> cancelTopicAnalysis(String clusterName, String
288289
ServerWebExchange exchange) {
289290
var context = AccessContext.builder()
290291
.cluster(clusterName)
291-
.topicActions(topicName, MESSAGES_READ)
292+
.topicActions(topicName, ANALYSIS_RUN)
292293
.operationName("cancelTopicAnalysis")
293294
.build();
294295

@@ -306,7 +307,7 @@ public Mono<ResponseEntity<TopicAnalysisDTO>> getTopicAnalysis(String clusterNam
306307

307308
var context = AccessContext.builder()
308309
.cluster(clusterName)
309-
.topicActions(topicName, MESSAGES_READ)
310+
.topicActions(topicName, ANALYSIS_VIEW)
310311
.operationName("getTopicAnalysis")
311312
.build();
312313

api/src/main/java/io/kafbat/ui/model/rbac/permission/TopicAction.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ public enum TopicAction implements PermissibleAction {
1313
MESSAGES_READ(VIEW),
1414
MESSAGES_PRODUCE(VIEW),
1515
MESSAGES_DELETE(VIEW, EDIT),
16+
ANALYSIS_VIEW(VIEW),
17+
ANALYSIS_RUN(VIEW, ANALYSIS_VIEW),
1618

1719
;
1820

frontend/src/components/Topics/Topic/Statistics/Metrics.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const Metrics: React.FC = () => {
6060
buttonSize="M"
6161
permission={{
6262
resource: ResourceType.TOPIC,
63-
action: Action.MESSAGES_READ,
63+
action: Action.ANALYSIS_RUN,
6464
value: params.topicName,
6565
}}
6666
>
@@ -110,7 +110,7 @@ const Metrics: React.FC = () => {
110110
buttonSize="S"
111111
permission={{
112112
resource: ResourceType.TOPIC,
113-
action: Action.MESSAGES_READ,
113+
action: Action.ANALYSIS_RUN,
114114
value: params.topicName,
115115
}}
116116
>

frontend/src/components/Topics/Topic/Statistics/Statistics.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const Statistics: React.FC = () => {
3131
buttonSize="M"
3232
permission={{
3333
resource: ResourceType.TOPIC,
34-
action: Action.MESSAGES_READ,
34+
action: Action.ANALYSIS_RUN,
3535
value: params.topicName,
3636
}}
3737
>

frontend/src/components/Topics/Topic/Topic.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,17 @@ const Topic: React.FC = () => {
194194
>
195195
Settings
196196
</NavLink>
197-
<NavLink
197+
<ActionNavLink
198198
to={clusterTopicStatisticsRelativePath}
199199
className={({ isActive }) => (isActive ? 'is-active' : '')}
200+
permission={{
201+
resource: ResourceType.TOPIC,
202+
action: Action.ANALYSIS_VIEW,
203+
value: topicName,
204+
}}
200205
>
201206
Statistics
202-
</NavLink>
207+
</ActionNavLink>
203208
</Navbar>
204209
<Suspense fallback={<PageLoader />}>
205210
<Routes>

0 commit comments

Comments
 (0)