소스 검색

调整ACL权限

develop
H Vs 5 달 전
부모
커밋
1fbfa894d7
3개의 변경된 파일19개의 추가작업 그리고 19개의 파일을 삭제
  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 파일 보기

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


+ 17
- 17
TelpoKafkaConsole.WebApi/Controllers/ScramAclsController.cs 파일 보기

@@ -30,28 +30,28 @@ namespace TelpoKafkaConsole.WebApi.Controllers
var topics = await _servicekafkaAdmin.DescribeTopicsAsync(new List<string> { consumer.Topic }); var topics = await _servicekafkaAdmin.DescribeTopicsAsync(new List<string> { consumer.Topic });
if (topics.Count.Equals(0)) 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 // 创建 alcs
List<AclBinding> aclBindings = new() 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() new AclBinding()
{ {
Pattern = new ResourcePattern Pattern = new ResourcePattern


+ 1
- 1
TelpoKafkaConsole.WebApi/Controllers/TopicController.cs 파일 보기

@@ -26,7 +26,7 @@ namespace TelpoKafkaConsole.WebApi.Controllers
[HttpPost] [HttpPost]
public async Task<ApiResponse<string>> Post([FromBody] TopicReq topic) 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} 成功"); return ApiResponse<string>.Success($"创建 Topic {topic} 成功");
} }




Loading…
취소
저장