This is an automated email from the ASF dual-hosted git repository.
humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git
The following commit(s) were added to refs/heads/master by this push:
new 19ff973 Expand on AAA with basic logic, add type hints
19ff973 is described below
commit 19ff9733059db12e8e108f95b63885004f5dddef
Author: Daniel Gruno <[email protected]>
AuthorDate: Mon Sep 7 03:14:54 2020 +0200
Expand on AAA with basic logic, add type hints
---
server/plugins/aaa.py | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/server/plugins/aaa.py b/server/plugins/aaa.py
index d2722a2..7fb5038 100644
--- a/server/plugins/aaa.py
+++ b/server/plugins/aaa.py
@@ -20,10 +20,27 @@ This is the AAA library for Pony Mail codename Foal
It handles rights management for lists.
"""
+import plugins.session
-def can_access_email(session, email):
- return True
+def can_access_email(session: plugins.session.SessionObject, email) -> bool:
+ """Determine if an email can be accessed by the current user"""
+ # If public email, it can always be accessed
+ if not email.get('private'):
+ return True
+ else:
+ # If user can access the list, they can read the email
+ if can_access_list(session, email.get('list_raw')):
+ return True
+ # If no access to list and email is private, deny access to email.
+ else:
+ return False
-def can_access_list(session, listid):
- return False
+
+def can_access_list(session: plugins.session.SessionObject, listid) -> bool:
+ """Determine if a list can be accessed by the current user"""
+ # If logged in, we assume access for now...TO BE CHANGED
+ if session and session.credentials:
+ return True
+ else:
+ return False