about summary refs log tree commit diff
path: root/gn_auth/auth/authorisation/resources
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2026-08-27 10:51:16 -0500
committerFrederick Muriuki Muriithi2026-08-27 12:51:31 -0500
commit800913ddee45fcb0b0e3a9d8c3917d3cf9644ca4 (patch)
tree30b78dca5002899cce2d2f875bffe70a74933c87 /gn_auth/auth/authorisation/resources
parentc9d6594750ad7a01b1e23af77e4f847e23f26306 (diff)
downloadgn-auth-800913ddee45fcb0b0e3a9d8c3917d3cf9644ca4.tar.gz
Cleanup deprecation warnings: Switch to gn_libs.sqlite3
The gn_auth.auth.db.sqlite3 module is deprecated and should be
removed. This cleanup goes a ways towards that goal.
Diffstat (limited to 'gn_auth/auth/authorisation/resources')
-rw-r--r--gn_auth/auth/authorisation/resources/checks.py13
-rw-r--r--gn_auth/auth/authorisation/resources/groups/models.py2
2 files changed, 7 insertions, 8 deletions
diff --git a/gn_auth/auth/authorisation/resources/checks.py b/gn_auth/auth/authorisation/resources/checks.py
index 252df2f..6dfd388 100644
--- a/gn_auth/auth/authorisation/resources/checks.py
+++ b/gn_auth/auth/authorisation/resources/checks.py
@@ -11,7 +11,6 @@ from gn_libs.privileges import check
 from .base import Resource
 from .system.models import system_resource
 
-from ...db import sqlite3 as db
 from ...authentication.users import User
 
 from ..privileges.models import db_row_to_privilege
@@ -31,7 +30,7 @@ def __organise_privileges_by_resource_id__(rows):
     return reduce(__organise__, rows, {})
 
 
-def authorised_for(conn: db.DbConnection,
+def authorised_for(conn: authdb.DbConnection,
                    user: User,
                    privileges: tuple[str, ...],
                    resource_ids: Sequence[uuid.UUID]) -> dict[uuid.UUID, bool]:
@@ -42,7 +41,7 @@ def authorised_for(conn: db.DbConnection,
     warnings.warn(DeprecationWarning(
         f"The function `{__name__}.authorised_for` is deprecated. Please use "
         f"`{__name__}.authorised_for_spec`"))
-    with db.cursor(conn) as cursor:
+    with authdb.cursor(conn) as cursor:
         cursor.execute(
             ("SELECT ur.*, rp.privilege_id FROM "
              "user_roles AS ur "
@@ -66,7 +65,7 @@ def authorised_for(conn: db.DbConnection,
 
 
 def authorised_for2(
-        conn: db.DbConnection,
+        conn: authdb.DbConnection,
         user: User,
         resource: Resource,
         privileges: tuple[str, ...]
@@ -77,7 +76,7 @@ def authorised_for2(
     warnings.warn(DeprecationWarning(
         f"The function `{__name__}.authorised_for2` is deprecated. Please use "
         f"`{__name__}.authorised_for_spec`"))
-    with db.cursor(conn) as cursor:
+    with authdb.cursor(conn) as cursor:
         _query = (
             "SELECT resources.resource_id, user_roles.user_id, roles.role_id, "
             "privileges.* "
@@ -101,7 +100,7 @@ def authorised_for2(
 
 
 def authorised_for_spec(
-        conn: db.DbConnection,
+        conn: authdb.DbConnection,
         user_id: uuid.UUID,
         resource_id: uuid.UUID,
         auth_spec: str
@@ -110,7 +109,7 @@ def authorised_for_spec(
     Check that a user, identified with `user_id`, has a set of privileges that
     satisfy the `auth_spec` for the resource identified with `resource_id`.
     """
-    with db.cursor(conn) as cursor:
+    with authdb.cursor(conn) as cursor:
         _query = (
             "SELECT resources.resource_id, user_roles.user_id, roles.role_id, "
             "privileges.* "
diff --git a/gn_auth/auth/authorisation/resources/groups/models.py b/gn_auth/auth/authorisation/resources/groups/models.py
index 60d4634..79bead4 100644
--- a/gn_auth/auth/authorisation/resources/groups/models.py
+++ b/gn_auth/auth/authorisation/resources/groups/models.py
@@ -11,8 +11,8 @@ from flask import g
 from pymonad.maybe import Just, Maybe, Nothing
 from pymonad.either import Left, Right, Either
 from pymonad.tools import monad_from_none_or_value
+from gn_libs import sqlite3 as db
 
-from gn_auth.auth.db import sqlite3 as db
 from gn_auth.auth.authentication.users import User, user_by_id
 
 from gn_auth.auth.authorisation.checks import authorised_p