From 83a8bf8e45951b771b476d2200ed1b69e4904975 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Tue, 31 Jan 2023 04:47:46 +0300 Subject: auth: Remove the @authenticated_p decorator The @authenticated_p decorator (and function), is an artifact of the original development ideas and should be removed from use. --- gn3/auth/authorisation/groups.py | 4 ---- gn3/auth/authorisation/resources.py | 2 +- gn3/auth/authorisation/roles.py | 2 -- 3 files changed, 1 insertion(+), 7 deletions(-) (limited to 'gn3/auth/authorisation') diff --git a/gn3/auth/authorisation/groups.py b/gn3/auth/authorisation/groups.py index c301ea4..0e022ee 100644 --- a/gn3/auth/authorisation/groups.py +++ b/gn3/auth/authorisation/groups.py @@ -9,7 +9,6 @@ from pymonad.maybe import Just, Maybe, Nothing from gn3.auth import db from gn3.auth.dictify import dictify from gn3.auth.authentication.users import User -from gn3.auth.authentication.checks import authenticated_p from .checks import authorised_p from .privileges import Privilege @@ -71,7 +70,6 @@ def user_membership(conn: db.DbConnection, user: User) -> Sequence[Group]: return groups -@authenticated_p def create_group( conn: db.DbConnection, group_name: str, group_leader: User, group_description: Optional[str] = None) -> Group: @@ -98,7 +96,6 @@ def create_group( return __create_group__() -@authenticated_p @authorised_p(("group:role:create-role",), error_message="Could not create the group role") def create_group_role( @@ -115,7 +112,6 @@ def create_group_role( return GroupRole(group_role_id, group, role) -@authenticated_p def authenticated_user_group(conn) -> Maybe: """ Returns the currently authenticated user's group. diff --git a/gn3/auth/authorisation/resources.py b/gn3/auth/authorisation/resources.py index 1e37d7a..fe096e8 100644 --- a/gn3/auth/authorisation/resources.py +++ b/gn3/auth/authorisation/resources.py @@ -52,7 +52,7 @@ def create_resource( resource_category: ResourceCategory) -> Resource: """Create a resource item.""" with db.cursor(conn) as cursor: - group = authenticated_user_group(conn).maybe(False, lambda val: val) + group = authenticated_user_group(conn).maybe(False, lambda val: val)# type: ignore[misc] if not group: raise MissingGroupError( "User with no group cannot create a resource.") diff --git a/gn3/auth/authorisation/roles.py b/gn3/auth/authorisation/roles.py index f3b2f90..e9f3fb0 100644 --- a/gn3/auth/authorisation/roles.py +++ b/gn3/auth/authorisation/roles.py @@ -9,7 +9,6 @@ from pymonad.either import Left, Right, Either from gn3.auth import db from gn3.auth.dictify import dictify from gn3.auth.authentication.users import User -from gn3.auth.authentication.checks import authenticated_p from .checks import authorised_p from .privileges import Privilege @@ -28,7 +27,6 @@ class Role(NamedTuple): "privileges": tuple(dictify(priv) for priv in self.privileges) } -@authenticated_p @authorised_p(("group:role:create-role",), error_message="Could not create role") def create_role( cursor: db.DbCursor, role_name: str, -- cgit v1.2.3