Fix#11216: Use Enum for SASL Mechanism for Kafka and Redpanda connections (#11385)

* Fix#11216: Use ENUM for SASL Mechanism for Kafka and Redpanda connections

* Minor change

* Address PR comments

* Fix postgres migration
This commit is contained in:
Nahuel 2023-05-08 09:35:49 +02:00 committed by GitHub
parent 27637119dd
commit b22192575d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 3 deletions

View File

@ -0,0 +1,6 @@
-- Updating the value of SASL Mechanism for Kafka and Redpanda connections
UPDATE messaging_service_entity
SET json = JSON_REPLACE(json, '$.connection.config.saslMechanism', 'PLAIN')
WHERE (serviceType = 'Kafka' OR serviceType = 'Redpanda')
AND JSON_EXTRACT(json, '$.connection.config.saslMechanism') IS NOT NULL
AND JSON_EXTRACT(json, '$.connection.config.saslMechanism') NOT IN ('GSSAPI', 'PLAIN', 'SCRAM-SHA-256', 'SCRAM-SHA-512', 'OAUTHBEARER');

View File

@ -0,0 +1,6 @@
-- Updating the value of SASL Mechanism for Kafka and Redpanda connections
UPDATE messaging_service_entity
SET json = JSONB_SET(json::jsonb, '{connection,config,saslMechanism}', '"PLAIN"')
WHERE (servicetype = 'Kafka' OR serviceType = 'Redpanda')
AND json#>'{connection,config,saslMechanism}' IS NOT NULL
AND json#>'{connection,config,saslMechanism}' NOT IN ('"GSSAPI"', '"PLAIN"', '"SCRAM-SHA-256"', '"SCRAM-SHA-512"', '"OAUTHBEARER"');

View File

@ -58,7 +58,7 @@ def get_connection(
"sasl.password"
] = connection.saslPassword.get_secret_value()
if connection.saslMechanism:
connection.consumerConfig["sasl.mechanism"] = connection.saslMechanism
connection.consumerConfig["sasl.mechanism"] = connection.saslMechanism.value
if connection.basicAuthUserInfo:
connection.schemaRegistryConfig = connection.schemaRegistryConfig or {}

View File

@ -45,7 +45,8 @@
"saslMechanism": {
"title": "SASL Mechanism",
"description": "sasl.mechanism Consumer Config property",
"type": "string"
"$ref": "saslMechanismType.json",
"default": "PLAIN"
},
"basicAuthUserInfo": {
"title": "Basic Auth User Info",

View File

@ -45,7 +45,8 @@
"saslMechanism": {
"title": "SASL Mechanism",
"description": "sasl.mechanism Consumer Config property",
"type": "string"
"$ref": "saslMechanismType.json",
"default": "PLAIN"
},
"basicAuthUserInfo": {
"title": "Basic Auth User Info",

View File

@ -0,0 +1,12 @@
{
"$id": "https://open-metadata.org/schema/entity/services/connections/messaging/saslMechanismType.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "SaslMechanismType",
"javaType": "org.openmetadata.schema.services.connections.messaging.SaslMechanismType",
"description": "SASL Mechanism consumer config property",
"type": "string",
"enum": ["PLAIN", "GSSAPI", "SCRAM-SHA-256", "SCRAM-SHA-512", "OAUTHBEARER"],
"default": "PLAIN"
}