0

Now I'm making a kafka service broker and want to create a new user when provisioning by using golang. I've checked all kafka library of Go, But didn't find any way to create a user(principal). It seems that two method below from Shopify/Sarama may be possible way, but I have no idea how to use it and could not find a sample code.

//AlterConfigsRequest is an alter config request type
type AlterConfigsRequest struct {
    Resources    []*AlterConfigsResource
    ValidateOnly bool
}
//AlterConfigsResource is an alter config resource type
type AlterConfigsResource struct {
    Type          ConfigResourceType
    Name          string
    ConfigEntries map[string]*string
}

What I want to do is: bin/kafka-configs.sh --zookeeper localhost:2181 --alter --add-config 'SCRAM-SHA-256=[iterations=8192,password=myusername-secret],SCRAM-SHA-512=[password=myusername-secret]' --entity-type users --entity-name myusername

Is it possible to call kafka-rest-api to create a user? what is the best solution?

Tiya Jose
  • 1,359
  • 14
  • 24
LittleY
  • 17
  • 4
  • What do you mean by "kafka rest api"? Have you tried looking at the unit tests for that function? – OneCricketeer Nov 26 '19 at 14:58
  • 1.This is what i mean by "kafka rest api": https://docs.confluent.io/current/kafka-rest/quickstart.html 2.Yes, check: https://github.com/Shopify/sarama/blob/master/alter_configs_request_test.go – LittleY Nov 27 '19 at 02:13
  • REST *Proxy* only maintains consumers and producers, not Zookeeper or external ACLs – OneCricketeer Nov 27 '19 at 07:18
  • And I think you missed this one https://github.com/Shopify/sarama/blob/master/acl_create_request_test.go – OneCricketeer Nov 27 '19 at 07:22
  • Note that a `UserResourceType` is not available to map to `--entity-type users` https://github.com/Shopify/sarama/blob/master/config_resource_type.go#L9-L21 so I think the only alternative is to use a Zookeeper golang library and add that data "manually" – OneCricketeer Nov 27 '19 at 07:26

0 Answers0