Skip to content

Community version #839 #997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions backend/src/graphDB_dataAccess.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,24 +160,33 @@ def update_KNN_graph(self):
logging.info("Vector index does not exist, So KNN graph not update")

def check_account_access(self, database):
query = """
SHOW USER PRIVILEGES
YIELD *
WHERE graph = $database AND action IN ['read']
RETURN COUNT(*) AS readAccessCount
"""
try:
logging.info(f"Checking access for database: {database}")
query_dbms_componenet = "call dbms.components() yield edition"
result_dbms_componenet = self.graph.query(query_dbms_componenet)

result = self.graph.query(query, params={"database": database})
read_access_count = result[0]["readAccessCount"] if result else 0
if result_dbms_componenet[0]["edition"] == "enterprise":
query = """
SHOW USER PRIVILEGES
YIELD *
WHERE graph = $database AND action IN ['read']
RETURN COUNT(*) AS readAccessCount
"""

logging.info(f"Checking access for database: {database}")

logging.info(f"Read access count: {read_access_count}")
result = self.graph.query(query, params={"database": database})
read_access_count = result[0]["readAccessCount"] if result else 0

if read_access_count > 0:
logging.info("The account has read access.")
return False
logging.info(f"Read access count: {read_access_count}")

if read_access_count > 0:
logging.info("The account has read access.")
return False
else:
logging.info("The account has write access.")
return True
else:
#Community version have no roles to execute admin command, so assuming write access as TRUE
logging.info("The account has write access.")
return True

Expand Down
Loading