about summary refs log tree commit diff
path: root/gn_auth/auth/authorisation/resources/common.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-07-31 16:15:01 -0500
committerFrederick Muriuki Muriithi2025-07-31 16:15:01 -0500
commitf275b3ab6172922cef97822804e54e6513937c2a (patch)
tree65400d5ae4629a5fedf78802b96f14d89fdc3315 /gn_auth/auth/authorisation/resources/common.py
parent56378b428b6bc50927fe226539c4d6ad8814b7d2 (diff)
downloadgn-auth-f275b3ab6172922cef97822804e54e6513937c2a.tar.gz
Prevent error in case sysadmin user already has access
In case any sysadmin user has access to the resource, we do not want
the query failing for other sysadmins.
Diffstat (limited to 'gn_auth/auth/authorisation/resources/common.py')
-rw-r--r--gn_auth/auth/authorisation/resources/common.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/gn_auth/auth/authorisation/resources/common.py b/gn_auth/auth/authorisation/resources/common.py
index 5a48704..fd358f1 100644
--- a/gn_auth/auth/authorisation/resources/common.py
+++ b/gn_auth/auth/authorisation/resources/common.py
@@ -42,6 +42,7 @@ def grant_access_to_sysadmins(
 
     cursor.executemany(
         "INSERT INTO user_roles(user_id, role_id, resource_id) "
-        "VALUES (?, ?, ?)",
+        "VALUES (?, ?, ?) "
+        "ON CONFLICT (user_id, role_id, resource_id) DO NOTHING",
         tuple((row["user_id"], sysadminroleid, str(resource_id))
               for row in cursor.fetchall()))