aboutsummaryrefslogtreecommitdiff
path: root/gn3
diff options
context:
space:
mode:
Diffstat (limited to 'gn3')
-rw-r--r--gn3/auth/authentication/checks.py14
-rw-r--r--gn3/auth/authorisation/groups.py4
-rw-r--r--gn3/auth/authorisation/resources.py2
-rw-r--r--gn3/auth/authorisation/roles.py2
4 files changed, 1 insertions, 21 deletions
diff --git a/gn3/auth/authentication/checks.py b/gn3/auth/authentication/checks.py
deleted file mode 100644
index 63b0752..0000000
--- a/gn3/auth/authentication/checks.py
+++ /dev/null
@@ -1,14 +0,0 @@
-"""Functions to check for user authentication."""
-
-from flask import g
-
-from .exceptions import AuthenticationError
-
-def authenticated_p(func):
- """Decorator for functions requiring authentication."""
- def __authenticated__(*args, **kwargs):
- user = g.user if hasattr(g, "user") else False
- if user:
- return func(*args, **kwargs)
- raise AuthenticationError("You need to be authenticated")
- return __authenticated__
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,