eldar-eln-bigabid commented on code in PR #30418:
URL: https://github.com/apache/airflow/pull/30418#discussion_r1157658167
##########
airflow/providers/neo4j/hooks/neo4j.py:
##########
@@ -61,12 +61,29 @@ def get_conn(self) -> Driver:
is_encrypted = self.connection.extra_dejson.get("encrypted", False)
- self.client = GraphDatabase.driver(
- uri, auth=(self.connection.login, self.connection.password),
encrypted=is_encrypted
- )
+ self.client = self.get_client(self.connection, is_encrypted, uri)
return self.client
+ def get_client(self, conn: Connection, encrypted: bool, uri: str) ->
Driver:
+ """
+ Function to determine that relevant driver based on extras.
+ :param conn: Connection object.
+ :param encrypted: boolean if encrypted connection or not.
+ :return: Neo4jDriver
+ """
+ # Self signed certificates
+ ssc = conn.extra_dejson.get("certs_self_signed", False)
+
+ # Only certificates signed by CA.
+ trusted_ca = conn.extra_dejson.get("certs_trusted_ca", False)
+
+ if trusted_ca or ssc:
+ driver = GraphDatabase.driver(uri, auth=(conn.login,
conn.password))
+ else:
+ driver = GraphDatabase.driver(uri, auth=(conn.login,
conn.password), encrypted=encrypted)
Review Comment:
@hussein-awala That looks nice and elegant too, I will commit this
implementation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]