Add support for Cassandra auth with SSL check (#318)

Following recommended approach in Datastax documenation I've added the necessary TLS/SSL check

https://docs.datastax.com/en/developer/python-driver/3.17/security/index.html
This commit is contained in:
Tyler Oliver 2025-03-20 22:25:23 +00:00 committed by GitHub
parent 322725be04
commit fe422b2b95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 3 deletions

View file

@ -1,6 +1,7 @@
from cassandra.cluster import Cluster
from cassandra.auth import PlainTextAuthProvider
from ssl import SSLContext, PROTOCOL_TLSv1_2
class TrustGraph:
@ -17,8 +18,9 @@ class TrustGraph:
self.username = username
if username and password:
ssl_context = SSLContext(PROTOCOL_TLSv1_2)
auth_provider = PlainTextAuthProvider(username=username, password=password)
self.cluster = Cluster(hosts, auth_provider=auth_provider)
self.cluster = Cluster(hosts, auth_provider=auth_provider, ssl_context=ssl_context)
else:
self.cluster = Cluster(hosts)
self.session = self.cluster.connect()