Pārlūkot izejas kodu

调整ACL权限

develop
H Vs pirms 5 mēnešiem
vecāks
revīzija
1fbfa894d7
3 mainītis faili ar 19 papildinājumiem un 19 dzēšanām
  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 Parādīt failu

@@ -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 Parādīt failu

@@ -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 Parādīt failu

@@ -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} 成功");
}



Notiek ielāde…
Atcelt
Saglabāt