Przeglądaj źródła

调整ACL权限

develop
H Vs 5 miesięcy temu
rodzic
commit
1fbfa894d7
3 zmienionych plików z 19 dodań i 19 usunięć
  1. +1
    -1
      TelpoKafkaConsole.Service/KafkaAdminService.cs
  2. +17
    -17
      TelpoKafkaConsole.WebApi/Controllers/ScramAclsController.cs
  3. +1
    -1
      TelpoKafkaConsole.WebApi/Controllers/TopicController.cs

+ 1
- 1
TelpoKafkaConsole.Service/KafkaAdminService.cs Wyświetl plik

@@ -324,7 +324,7 @@ namespace TelpoKafkaConsole.Service
new() {
Name = topicName,
ReplicationFactor = 1,
NumPartitions = numPartitions,
NumPartitions = numPartitions>3 ? 3 : numPartitions,
Configs = configEntries
}
});


+ 17
- 17
TelpoKafkaConsole.WebApi/Controllers/ScramAclsController.cs Wyświetl plik

@@ -30,28 +30,28 @@ namespace TelpoKafkaConsole.WebApi.Controllers
var topics = await _servicekafkaAdmin.DescribeTopicsAsync(new List<string> { consumer.Topic });
if (topics.Count.Equals(0))
{
await _servicekafkaAdmin.CreateTopic(consumer.Topic, TimeSpan.FromDays(3), consumer.NumPartitions);
await _servicekafkaAdmin.CreateTopic(consumer.Topic, TimeSpan.FromDays(3), consumer.NumPartitions>3 ? 3: consumer.NumPartitions);
}
// 创建 alcs
List<AclBinding> aclBindings = new()
{
new AclBinding()
{
Pattern = new ResourcePattern
{
Type = ResourceType.Broker,
Name = "kafka-cluster",
ResourcePatternType = ResourcePatternType.Literal
},
Entry = new AccessControlEntry
{
Principal = $"User:{consumer.Name}",
Host = "*",
Operation = AclOperation.All,
PermissionType = AclPermissionType.Deny
}
},
//new AclBinding()
//{
// Pattern = new ResourcePattern
// {
// Type = ResourceType.Broker,
// Name = "kafka-cluster",
// ResourcePatternType = ResourcePatternType.Literal
// },
// Entry = new AccessControlEntry
// {
// Principal = $"User:{consumer.Name}",
// Host = "*",
// Operation = AclOperation.All,
// PermissionType = AclPermissionType.Deny
// }
//},
new AclBinding()
{
Pattern = new ResourcePattern


+ 1
- 1
TelpoKafkaConsole.WebApi/Controllers/TopicController.cs Wyświetl plik

@@ -26,7 +26,7 @@ namespace TelpoKafkaConsole.WebApi.Controllers
[HttpPost]
public async Task<ApiResponse<string>> Post([FromBody] TopicReq topic)
{
await _servicekafkaAdmin.CreateTopic(topic.TopicName,TimeSpan.FromDays(3));
await _servicekafkaAdmin.CreateTopic(topic.TopicName,TimeSpan.FromDays(3), topic.NumPartitions);
return ApiResponse<string>.Success($"创建 Topic {topic} 成功");
}



Ładowanie…
Anuluj
Zapisz