mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-28 09:56:22 +02:00
Add user and password auth for Cassandra (#301)
This commit is contained in:
parent
1000a9de8f
commit
41ccb6c976
4 changed files with 89 additions and 13 deletions
|
|
@ -26,6 +26,8 @@ class Processor(ConsumerProducer):
|
|||
output_queue = params.get("output_queue", default_output_queue)
|
||||
subscriber = params.get("subscriber", default_subscriber)
|
||||
graph_host = params.get("graph_host", default_graph_host)
|
||||
graph_username = params.get("graph_username", None)
|
||||
graph_password = params.get("graph_password", None)
|
||||
|
||||
super(Processor, self).__init__(
|
||||
**params | {
|
||||
|
|
@ -35,10 +37,14 @@ class Processor(ConsumerProducer):
|
|||
"input_schema": TriplesQueryRequest,
|
||||
"output_schema": TriplesQueryResponse,
|
||||
"graph_host": graph_host,
|
||||
"graph_username": graph_username,
|
||||
"graph_password": graph_password,
|
||||
}
|
||||
)
|
||||
|
||||
self.graph_host = [graph_host]
|
||||
self.username = graph_username
|
||||
self.password = graph_password
|
||||
self.table = None
|
||||
|
||||
def create_value(self, ent):
|
||||
|
|
@ -56,10 +62,17 @@ class Processor(ConsumerProducer):
|
|||
table = (v.user, v.collection)
|
||||
|
||||
if table != self.table:
|
||||
self.tg = TrustGraph(
|
||||
hosts=self.graph_host,
|
||||
keyspace=v.user, table=v.collection,
|
||||
)
|
||||
if self.username and self.password:
|
||||
self.tg = TrustGraph(
|
||||
hosts=self.graph_host,
|
||||
keyspace=v.user, table=v.collection,
|
||||
username=self.username, password=self.password
|
||||
)
|
||||
else:
|
||||
self.tg = TrustGraph(
|
||||
hosts=self.graph_host,
|
||||
keyspace=v.user, table=v.collection,
|
||||
)
|
||||
self.table = table
|
||||
|
||||
# Sender-produced ID
|
||||
|
|
@ -176,6 +189,19 @@ class Processor(ConsumerProducer):
|
|||
default="localhost",
|
||||
help=f'Graph host (default: localhost)'
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'--graph-username',
|
||||
default=None,
|
||||
help=f'Cassandra username'
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'--graph-password',
|
||||
default=None,
|
||||
help=f'Cassandra password'
|
||||
)
|
||||
|
||||
|
||||
def run():
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue