allow resources to decide for themselves if they want to be personal
authorchrysn <chrysn@fsfe.org>
Fri, 4 Apr 2014 11:49:19 +0000 (13:49 +0200)
committerJelmer Vernooij <jelmer@jelmer.uk>
Sun, 10 Apr 2016 11:43:29 +0000 (11:43 +0000)
calypso/acl/htpasswd.py
calypso/acl/pam.py
calypso/principal.py
calypso/webdav.py
collection-config

index fb5fea0dceeb8d394a5ff830ac5356a9f48db248..2b1dff1970b39b4280f70e1b3dea3d3c27e4da9f 100644 (file)
@@ -63,11 +63,10 @@ def has_right(entity, user, password):
     for line in open(FILENAME).readlines():
         if line.strip():
             login, hash_value = line.strip().split(":", 1)
-            if login == user and (not PERSONAL or user == entity.owner):
+            if login == user and (not entity.personal or user == entity.owner):
                 return CHECK_PASSWORD(hash_value, password)
     return False
 
 
 FILENAME = os.path.expanduser(config.get("acl", "filename"))
-PERSONAL = config.getboolean("acl", "personal")
 CHECK_PASSWORD = locals()["_%s" % config.get("acl", "encryption")]
index 50a98399924d2c42b90fac2fc52e6eefb5a11492..03ce041ae116ff4c0f27fa08470984cc2976958a 100644 (file)
@@ -31,12 +31,11 @@ from calypso import config
 
 LOG = logging.getLogger()
 SVC = config.get("acl", "pam_service")
-PERSONAL = config.getboolean("acl", "personal")
 
 def has_right(entity, user, password):
     """Check if ``user``/``password`` couple is valid."""
     LOG.debug("entity %s user %s", entity, user)
-    if entity.owner and entity.owner != user and PERSONAL:
+    if entity.owner and entity.owner != user and entity.personal:
         return False
     def pam_conv(auth, query_list, userData):
         result = []
index daed2fecce57b2779d04566e10488b625100913d..c952d0817531ad94306dcc37ef0567ee485baf6c 100644 (file)
@@ -23,6 +23,9 @@ class Resource(object):
 
     owner = None # implement the interface for acls
 
+    def is_personal(self):
+        return True
+
 class Principal(Resource):
     def __init__(self, username):
         self.username = username
index 2ddc38ce19cf80467aca2309df4c0d3032a1a4c5..b3ea38de242ff9315ab2d604f45f3244f544b5c5 100644 (file)
@@ -626,3 +626,9 @@ class Collection(object):
             return self.metadata.getboolean('collection', 'is-calendar')
         except (ConfigParser.NoSectionError, ConfigParser.NoOptionError, ValueError):
             return True
+
+    def is_personal(self):
+        try:
+            return self.metadata.getboolean('collection', 'personal')
+        except (ConfigParser.NoSectionError, ConfigParser.NoOptionError, ValueError):
+            return config.get('acl', 'personal')
index c1a2e24220f05d928b28974687f144b0d1a8e3a6..d725ceb70003802b7bce4e939dbbb9280de081de 100644 (file)
@@ -18,4 +18,8 @@ is-calendar = 1
 # is-calendar.
 is-addressbook = 0
 
+# Set this collection to personal, meaning that only its owner can access it.
+# Defaults to the personal setting in the Calypso configuration's acl section.
+personal = False
+
 # vim:ft=cfg