aboutsummaryrefslogtreecommitdiff
path: root/gn_auth
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-06-17 14:25:47 -0500
committerFrederick Muriuki Muriithi2024-06-17 14:25:47 -0500
commit4b0eed1a90a200a4283778b10d116f4f76ad9455 (patch)
tree87025b94c31a50fed3ff7ae83aa26dcdd9407257 /gn_auth
parent1776582ab9d44758793cab70978b353c00be51bc (diff)
downloadgn-auth-4b0eed1a90a200a4283778b10d116f4f76ad9455.tar.gz
Fix linting errors.
Diffstat (limited to 'gn_auth')
-rw-r--r--gn_auth/auth/authorisation/privileges/__init__.py1
-rw-r--r--gn_auth/auth/authorisation/privileges/views.py2
-rw-r--r--gn_auth/auth/authorisation/resources/groups/views.py1
-rw-r--r--gn_auth/auth/authorisation/resources/views.py16
-rw-r--r--gn_auth/auth/authorisation/roles/models.py2
5 files changed, 11 insertions, 11 deletions
diff --git a/gn_auth/auth/authorisation/privileges/__init__.py b/gn_auth/auth/authorisation/privileges/__init__.py
index 18c7f5d..c99031d 100644
--- a/gn_auth/auth/authorisation/privileges/__init__.py
+++ b/gn_auth/auth/authorisation/privileges/__init__.py
@@ -1,5 +1,6 @@
"""Package for Privileges."""
from .models import (Privilege,
user_privileges,
+ privilege_by_id,
privileges_by_ids,
db_row_to_privilege)
diff --git a/gn_auth/auth/authorisation/privileges/views.py b/gn_auth/auth/authorisation/privileges/views.py
index d50e5cb..75ac8e3 100644
--- a/gn_auth/auth/authorisation/privileges/views.py
+++ b/gn_auth/auth/authorisation/privileges/views.py
@@ -1,6 +1,4 @@
"""Routes for privileges."""
-from dataclasses import asdict
-
from werkzeug.exceptions import NotFound
from flask import jsonify, Blueprint, current_app as app
diff --git a/gn_auth/auth/authorisation/resources/groups/views.py b/gn_auth/auth/authorisation/resources/groups/views.py
index beb2b42..f22e15d 100644
--- a/gn_auth/auth/authorisation/resources/groups/views.py
+++ b/gn_auth/auth/authorisation/resources/groups/views.py
@@ -15,7 +15,6 @@ from gn_auth.auth.db import sqlite3 as db
from gn_auth.auth.db import mariadb as gn3db
from gn_auth.auth.db.sqlite3 import with_db_connection
-from gn_auth.auth.authorisation.roles.models import Role
from gn_auth.auth.authorisation.roles.models import user_roles
from gn_auth.auth.authorisation.checks import authorised_p
diff --git a/gn_auth/auth/authorisation/resources/views.py b/gn_auth/auth/authorisation/resources/views.py
index 736b315..0849466 100644
--- a/gn_auth/auth/authorisation/resources/views.py
+++ b/gn_auth/auth/authorisation/resources/views.py
@@ -19,13 +19,16 @@ from gn_auth.auth.db.sqlite3 import with_db_connection
from gn_auth.auth.authorisation.roles import Role
from gn_auth.auth.authorisation.roles.models import create_role
-from gn_auth.auth.authorisation.privileges import Privilege
-from gn_auth.auth.authorisation.privileges.models import privileges_by_ids
-from gn_auth.auth.errors import InvalidData, InconsistencyError, AuthorisationError
+from gn_auth.auth.errors import (
+ InvalidData,
+ InconsistencyError,
+ AuthorisationError)
+from gn_auth.auth.authorisation.privileges import (
+ privilege_by_id,
+ privileges_by_ids)
from gn_auth.auth.authorisation.roles.models import (
role_by_id,
db_rows_to_roles,
- check_user_editable,
delete_privilege_from_resource_role)
from gn_auth.auth.authentication.oauth2.resource_server import require_oauth
@@ -510,7 +513,7 @@ def resource_role(resource_id: UUID, role_id: UUID):
_roles = db_rows_to_roles(results)
if len(_roles) > 1:
- msg = f"There is data corruption in the database."
+ msg = "There is data corruption in the database."
return jsonify({
"error": "RoleNotFound",
"error_description": msg,
@@ -530,7 +533,6 @@ def unassign_resource_role_privilege(resource_id: UUID, role_id: UUID):
db.connection(app.config["AUTH_DB"]) as conn,
db.cursor(conn) as cursor):
_role = role_by_id(conn, role_id)
- # check_user_editable(_role) # Check whether role is user editable
_authorised = authorised_for(
conn,
@@ -549,7 +551,7 @@ def unassign_resource_role_privilege(resource_id: UUID, role_id: UUID):
delete_privilege_from_resource_role(cursor,
_role,
- privilege_by_id(privilege_id))
+ privilege_by_id(conn, privilege_id))
return jsonify({
"status": "Success",
diff --git a/gn_auth/auth/authorisation/roles/models.py b/gn_auth/auth/authorisation/roles/models.py
index d58c4a1..f0e9745 100644
--- a/gn_auth/auth/authorisation/roles/models.py
+++ b/gn_auth/auth/authorisation/roles/models.py
@@ -247,7 +247,7 @@ def role_by_id(conn: db.DbConnection, role_id: UUID) -> Optional[Role]:
def delete_privilege_from_resource_role(
cursor: db.DbCursor,
role: Role,
- privilege_id: str
+ privilege: Privilege
):
"""Delete a privilege from a resource role."""
cursor.execute(