Added enum for ssl and auth (#11016)

This commit is contained in:
Onkar Ravgan 2023-04-12 16:27:31 +05:30 committed by GitHub
parent ae6683862f
commit 1b930fa6f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 31 additions and 11 deletions

View File

@ -44,7 +44,7 @@ def get_connection_url(connection: HiveConnection) -> str:
if (
connection.username
and connection.auth
and connection.auth in ("LDAP", "CUSTOM")
and connection.auth.value in ("LDAP", "CUSTOM")
):
url += quote_plus(connection.username)
if not connection.password:
@ -80,7 +80,7 @@ def get_connection(connection: HiveConnection) -> Engine:
if connection.auth:
if not connection.connectionArguments:
connection.connectionArguments = init_empty_connection_arguments()
connection.connectionArguments.__root__["auth"] = connection.auth
connection.connectionArguments.__root__["auth"] = connection.auth.value
if connection.kerberosServiceName:
if not connection.connectionArguments:

View File

@ -22,6 +22,7 @@ from metadata.generated.schema.entity.automations.workflow import (
)
from metadata.generated.schema.entity.services.connections.database.postgresConnection import (
PostgresConnection,
SslMode,
)
from metadata.ingestion.connections.builders import (
create_generic_db_connection,
@ -45,7 +46,11 @@ def get_connection(connection: PostgresConnection) -> Engine:
if connection.sslMode:
if not connection.connectionArguments:
connection.connectionArguments = init_empty_connection_arguments()
connection.connectionArguments.__root__["sslmode"] = connection.sslMode
connection.connectionArguments.__root__["sslmode"] = connection.sslMode.value
if connection.sslMode in (SslMode.verify_ca, SslMode.verify_full):
connection.connectionArguments.__root__[
"sslrootcert"
] = connection.sslConfig.__root__.certificatePath
return create_generic_db_connection(
connection=connection,
get_connection_url_fn=get_connection_url_common,

View File

@ -21,6 +21,7 @@ from metadata.generated.schema.entity.automations.workflow import (
)
from metadata.generated.schema.entity.services.connections.database.redshiftConnection import (
RedshiftConnection,
SslMode,
)
from metadata.ingestion.connections.builders import (
create_generic_db_connection,
@ -44,7 +45,11 @@ def get_connection(connection: RedshiftConnection) -> Engine:
if connection.sslMode:
if not connection.connectionArguments:
connection.connectionArguments = init_empty_connection_arguments()
connection.connectionArguments.__root__["sslmode"] = connection.sslMode
connection.connectionArguments.__root__["sslmode"] = connection.sslMode.value
if connection.sslMode in (SslMode.verify_ca, SslMode.verify_full):
connection.connectionArguments.__root__[
"sslrootcert"
] = connection.sslConfig.__root__.certificatePath
return create_generic_db_connection(
connection=connection,
get_connection_url_fn=get_connection_url_common,

View File

@ -50,8 +50,10 @@
},
"auth": {
"title": "Authentication Mode",
"description": "Authentication mode to connect to hive, E.g, LDAP, CUSTOM etc",
"type": "string"
"description": "Authentication mode to connect to hive.",
"type": "string",
"enum": ["NONE", "LDAP", "KERBEROS", "CUSTOM", "NOSASL", "BASIC"],
"default": "NONE"
},
"kerberosServiceName": {
"title": "Kerberos Service Name",

View File

@ -55,8 +55,12 @@
},
"sslMode": {
"title": "SSL Mode",
"description": "SSL Mode to connect to postgres database. E.g, prefer, verify-ca etc.",
"type": "string"
"description": "SSL Mode to connect to postgres database.",
"enum": ["disable", "allow", "prefer", "require", "verify-ca", "verify-full"],
"default": "disable"
},
"sslConfig": {
"$ref": "../../../../security/ssl/verifySSLConfig.json#/definitions/sslConfig"
},
"classificationName": {
"title": "Classification Name",

View File

@ -61,8 +61,12 @@
},
"sslMode": {
"title": "SSL Mode",
"description": "SSL Mode to connect to postgres database. E.g, prefer, verify-ca etc.",
"type": "string"
"description": "SSL Mode to connect to redshift database.",
"enum": ["disable", "allow", "prefer", "require", "verify-ca", "verify-full"],
"default": "disable"
},
"sslConfig": {
"$ref": "../../../../security/ssl/verifySSLConfig.json#/definitions/sslConfig"
},
"connectionOptions": {
"title": "Connection Options",

View File

@ -7,7 +7,7 @@
"javaType": "org.openmetadata.schema.security.ssl.ValidateSSLClientConfig",
"properties": {
"certificatePath": {
"description": "CA certificate path. E.g., /path/to/public.cert. Will be used if Verify SSL is set to `validate`.",
"description": "CA certificate path. E.g., /path/to/public.cert. Will be used if Verify SSL is set to `validate` or `verify`.",
"type": "string"
}
},