confluentinc / kafka-rest

Confluent REST Proxy for Kafka
https://docs.confluent.io/current/kafka-rest/docs/index.html
Other
45 stars 646 forks source link

Deny to register new schema versions #782

Open e11it opened 3 years ago

e11it commented 3 years ago

Hello!

Im trying to configure kafka-rest to deny registration of new avro schema version and to allow to use already registered schema versions only. I have discovered option auto.register.schemas and set it to False in the rest-proxy properties. I use docker, so set env propertie: KAFKA_REST_AUTO_REGISTER_SCHEMAS=false

Kafka-rest startup docker logs :

kafka-rest-sro_1            | [2020-11-25 11:53:09,405] INFO KafkaAvroSerializerConfig values:
kafka-rest-sro_1            |   auto.register.schemas = false
...
kafka-rest-sro_1            |   schema.registry.url = [http://schema-registry:8081]
kafka-rest-sro_1            |   use.latest.version = true

Kafka version: 6.0.0-ce

I have send two messages. First schema has 1 field:

"value_schema": "{\"type\":\"record\",\"name\":\"Test\",\"fields\":[{\"name\": \"payload\",\"type\": \"string\"}]}",

-- successfully registered Second schema has 2 field(one is new field):

"value_schema": "{\"type\":\"record\",\"name\":\"Test\",\"fields\":[{\"name\": \"payload\",\"type\": \"string\"},{\"name\": \"payload2\",\"type\": \"string\"}]}",

-- also successfully send and new version are registered

Do option auto.register.schemas have to disable new version registration? Or I have misunderstand this option...

Thx!

MarkC0x commented 3 years ago

Hi @e11it,

Could you try with the parameter producer.auto.register.schemas=false in your kafka-rest.properties configuration file and see if that disables schema auto registration?

If that has the desired effect then for the Docker environment property you should use: KAFKA_REST_PRODUCER_AUTO_REGISTER_SCHEMAS=false

Cheers Mark