Skip to content

Commit acb9dcf

Browse files
committed
Allow to display topic without any acls on configs
1 parent 117d914 commit acb9dcf

File tree

3 files changed

+61
-39
lines changed

3 files changed

+61
-39
lines changed

src/main/java/org/akhq/models/Topic.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,9 @@ public Boolean canDeleteRecords(String clusterId, ConfigRepository configReposit
130130
return false;
131131
}
132132

133-
return configRepository
134-
.findByTopic(clusterId, this.getName())
133+
List<Config> configs = configRepository.findByTopic(clusterId, this.getName());
134+
135+
return configs != null && configs
135136
.stream()
136137
.filter(config -> config.getName().equals(TopicConfig.CLEANUP_POLICY_CONFIG))
137138
.anyMatch(config -> config.getValue().contains(TopicConfig.CLEANUP_POLICY_COMPACT));

src/main/java/org/akhq/modules/AbstractKafkaWrapper.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.akhq.modules;
22

33

4+
import com.google.common.collect.ImmutableMap;
45
import org.apache.kafka.clients.admin.*;
56
import org.apache.kafka.clients.consumer.KafkaConsumer;
67
import org.apache.kafka.clients.consumer.OffsetAndMetadata;
@@ -281,13 +282,23 @@ public Map<ConfigResource, Config> describeConfigs(String clusterId, ConfigResou
281282
);
282283

283284
if (list.size() > 0) {
284-
Map<ConfigResource, Config> description = Logger.call(() -> kafkaModule.getAdminClient(clusterId)
285-
.describeConfigs(names.stream()
286-
.map(s -> new ConfigResource(type, s))
287-
.collect(Collectors.toList())
288-
)
289-
.all()
290-
.get(),
285+
Map<ConfigResource, Config> description = Logger.call(
286+
() -> {
287+
try {
288+
return kafkaModule.getAdminClient(clusterId)
289+
.describeConfigs(names.stream()
290+
.map(s -> new ConfigResource(type, s))
291+
.collect(Collectors.toList())
292+
)
293+
.all()
294+
.get();
295+
} catch (ExecutionException e) {
296+
if (e.getCause() instanceof SecurityDisabledException || e.getCause() instanceof ClusterAuthorizationException || e.getCause() instanceof TopicAuthorizationException) {
297+
return ImmutableMap.of();
298+
}
299+
throw e;
300+
}
301+
},
291302
"Describe Topic Config {}",
292303
names
293304
);

src/main/resources/views/blocks/configs.ftl

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,39 +22,49 @@
2222
</tr>
2323
</thead>
2424
<tbody>
25-
<#list configs as config>
26-
<tr>
27-
<td>
28-
<code>${config.getName()}</code>
29-
<#if config.getDescription()?? >
30-
<a class="text-secondary" data-toggle="tooltip" title="${config.getDescription()?replace('<[^>]+>','','r')}">
31-
<i class="fa fa-question-circle" aria-hidden="true"></i>
32-
</a>
33-
</#if>
34-
</td>
35-
<td>
36-
<input type="text"
37-
class="form-control"
38-
autocomplete="off"
39-
name="configs[${config.getName()}]"
40-
value="${config.getValue()!}"
41-
${(config.isReadOnly())?then("readonly", "")}
42-
/>
43-
<small class="humanize form-text text-muted"></small>
44-
</td>
45-
<td>
46-
<span
47-
class="badge badge-${(config.getSource().name() == "DEFAULT_CONFIG")?then("secondary", "warning")}"
48-
>
49-
${config.getSource().name()}
50-
</span>
25+
<#if configs??>
26+
<#list configs as config>
27+
<tr>
28+
<td>
29+
<code>${config.getName()}</code>
30+
<#if config.getDescription()?? >
31+
<a class="text-secondary" data-toggle="tooltip" title="${config.getDescription()?replace('<[^>]+>','','r')}">
32+
<i class="fa fa-question-circle" aria-hidden="true"></i>
33+
</a>
34+
</#if>
35+
</td>
36+
<td>
37+
<input type="text"
38+
class="form-control"
39+
autocomplete="off"
40+
name="configs[${config.getName()}]"
41+
value="${config.getValue()!}"
42+
${(config.isReadOnly())?then("readonly", "")}
43+
/>
44+
<small class="humanize form-text text-muted"></small>
45+
</td>
46+
<td>
47+
<span
48+
class="badge badge-${(config.getSource().name() == "DEFAULT_CONFIG")?then("secondary", "warning")}"
49+
>
50+
${config.getSource().name()}
51+
</span>
5152

52-
<#if config.isSensitive() >
53-
<i class="fa fa-exclamation-triangle text-danger" aria-hidden="true"></i>
54-
</#if>
53+
<#if config.isSensitive() >
54+
<i class="fa fa-exclamation-triangle text-danger" aria-hidden="true"></i>
55+
</#if>
56+
</td>
57+
</tr>
58+
</#list>
59+
<#else>
60+
<tr>
61+
<td colspan="3">
62+
<div class="alert alert-warning mb-0" role="alert">
63+
No acl for configs for current kafka user.
64+
</div>
5565
</td>
5666
</tr>
57-
</#list>
67+
</#if>
5868
</tbody>
5969
</table>
6070
</div>

0 commit comments

Comments
 (0)