Skip to content

Commit

Permalink
Allow to display topic without any acls on configs
Browse files Browse the repository at this point in the history
  • Loading branch information
tchiotludo committed Apr 8, 2020
1 parent 117d914 commit acb9dcf
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 39 deletions.
5 changes: 3 additions & 2 deletions src/main/java/org/akhq/models/Topic.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ public Boolean canDeleteRecords(String clusterId, ConfigRepository configReposit
return false;
}

return configRepository
.findByTopic(clusterId, this.getName())
List<Config> configs = configRepository.findByTopic(clusterId, this.getName());

return configs != null && configs
.stream()
.filter(config -> config.getName().equals(TopicConfig.CLEANUP_POLICY_CONFIG))
.anyMatch(config -> config.getValue().contains(TopicConfig.CLEANUP_POLICY_COMPACT));
Expand Down
25 changes: 18 additions & 7 deletions src/main/java/org/akhq/modules/AbstractKafkaWrapper.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.akhq.modules;


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

if (list.size() > 0) {
Map<ConfigResource, Config> description = Logger.call(() -> kafkaModule.getAdminClient(clusterId)
.describeConfigs(names.stream()
.map(s -> new ConfigResource(type, s))
.collect(Collectors.toList())
)
.all()
.get(),
Map<ConfigResource, Config> description = Logger.call(
() -> {
try {
return kafkaModule.getAdminClient(clusterId)
.describeConfigs(names.stream()
.map(s -> new ConfigResource(type, s))
.collect(Collectors.toList())
)
.all()
.get();
} catch (ExecutionException e) {
if (e.getCause() instanceof SecurityDisabledException || e.getCause() instanceof ClusterAuthorizationException || e.getCause() instanceof TopicAuthorizationException) {
return ImmutableMap.of();
}
throw e;
}
},
"Describe Topic Config {}",
names
);
Expand Down
70 changes: 40 additions & 30 deletions src/main/resources/views/blocks/configs.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -22,39 +22,49 @@
</tr>
</thead>
<tbody>
<#list configs as config>
<tr>
<td>
<code>${config.getName()}</code>
<#if config.getDescription()?? >
<a class="text-secondary" data-toggle="tooltip" title="${config.getDescription()?replace('<[^>]+>','','r')}">
<i class="fa fa-question-circle" aria-hidden="true"></i>
</a>
</#if>
</td>
<td>
<input type="text"
class="form-control"
autocomplete="off"
name="configs[${config.getName()}]"
value="${config.getValue()!}"
${(config.isReadOnly())?then("readonly", "")}
/>
<small class="humanize form-text text-muted"></small>
</td>
<td>
<span
class="badge badge-${(config.getSource().name() == "DEFAULT_CONFIG")?then("secondary", "warning")}"
>
${config.getSource().name()}
</span>
<#if configs??>
<#list configs as config>
<tr>
<td>
<code>${config.getName()}</code>
<#if config.getDescription()?? >
<a class="text-secondary" data-toggle="tooltip" title="${config.getDescription()?replace('<[^>]+>','','r')}">
<i class="fa fa-question-circle" aria-hidden="true"></i>
</a>
</#if>
</td>
<td>
<input type="text"
class="form-control"
autocomplete="off"
name="configs[${config.getName()}]"
value="${config.getValue()!}"
${(config.isReadOnly())?then("readonly", "")}
/>
<small class="humanize form-text text-muted"></small>
</td>
<td>
<span
class="badge badge-${(config.getSource().name() == "DEFAULT_CONFIG")?then("secondary", "warning")}"
>
${config.getSource().name()}
</span>

<#if config.isSensitive() >
<i class="fa fa-exclamation-triangle text-danger" aria-hidden="true"></i>
</#if>
<#if config.isSensitive() >
<i class="fa fa-exclamation-triangle text-danger" aria-hidden="true"></i>
</#if>
</td>
</tr>
</#list>
<#else>
<tr>
<td colspan="3">
<div class="alert alert-warning mb-0" role="alert">
No acl for configs for current kafka user.
</div>
</td>
</tr>
</#list>
</#if>
</tbody>
</table>
</div>
Expand Down

0 comments on commit acb9dcf

Please sign in to comment.