Set calendars always personal with authentication activated

This commit is contained in:
Guillaume Ayoub 2011-05-17 00:10:36 +02:00
parent 7c0e9686a8
commit ca9c148705
5 changed files with 3 additions and 12 deletions

3
config
View File

@ -36,9 +36,6 @@ stock = utf-8
# Access method # Access method
# Value: None | htpasswd | LDAP # Value: None | htpasswd | LDAP
type = None type = None
# Personal calendars only available for logged in users
# If True, /alice/calendar will only be available for alice
personal = True
# Htpasswd filename # Htpasswd filename
htpasswd_filename = /etc/radicale/users htpasswd_filename = /etc/radicale/users
# Htpasswd encryption method # Htpasswd encryption method

View File

@ -169,9 +169,6 @@ class Application(object):
if not calendar or not self.acl: if not calendar or not self.acl:
# No calendar or no acl, don't check rights # No calendar or no acl, don't check rights
status, headers, answer = function(environ, calendar, content) status, headers, answer = function(environ, calendar, content)
elif calendar.owner is None and config.getboolean("acl", "personal"):
# No owner and personal calendars, don't check rights
status, headers, answer = function(environ, calendar, content)
else: else:
# Ask authentication backend to check rights # Ask authentication backend to check rights
log.LOGGER.info( log.LOGGER.info(

View File

@ -32,15 +32,14 @@ from radicale import config, log
BASE = config.get("acl", "ldap_base") BASE = config.get("acl", "ldap_base")
ATTRIBUTE = config.get("acl", "ldap_attribute") ATTRIBUTE = config.get("acl", "ldap_attribute")
CONNEXION = ldap.initialize(config.get("acl", "ldap_url")) CONNEXION = ldap.initialize(config.get("acl", "ldap_url"))
PERSONAL = config.getboolean("acl", "personal")
BINDDN = config.get("acl", "ldap_binddn") BINDDN = config.get("acl", "ldap_binddn")
PASSWORD = config.get("acl", "ldap_password") PASSWORD = config.get("acl", "ldap_password")
def has_right(owner, user, password): def has_right(owner, user, password):
"""Check if ``user``/``password`` couple is valid.""" """Check if ``user``/``password`` couple is valid."""
if (user != owner and PERSONAL) or not user: if not user or (owner and user != owner):
# User is not owner and personal calendars, or no user given, forbidden # No user given, or owner is set and is not user, forbidden
return False return False
if BINDDN and PASSWORD: if BINDDN and PASSWORD:

View File

@ -34,7 +34,6 @@ from radicale import config
FILENAME = config.get("acl", "htpasswd_filename") FILENAME = config.get("acl", "htpasswd_filename")
PERSONAL = config.getboolean("acl", "personal")
ENCRYPTION = config.get("acl", "htpasswd_encryption") ENCRYPTION = config.get("acl", "htpasswd_encryption")
@ -64,6 +63,6 @@ def has_right(owner, user, password):
for line in open(FILENAME).readlines(): for line in open(FILENAME).readlines():
if line.strip(): if line.strip():
login, hash_value = line.strip().split(":") login, hash_value = line.strip().split(":")
if login == user and (not PERSONAL or user == owner): if login == user and (not owner or owner == user):
return globals()["_%s" % ENCRYPTION](hash_value, password) return globals()["_%s" % ENCRYPTION](hash_value, password)
return False return False

View File

@ -50,7 +50,6 @@ INITIAL_CONFIG = {
"stock": "utf-8"}, "stock": "utf-8"},
"acl": { "acl": {
"type": "None", "type": "None",
"personal": "True",
"httpasswd_filename": "/etc/radicale/users", "httpasswd_filename": "/etc/radicale/users",
"httpasswd_encryption": "crypt", "httpasswd_encryption": "crypt",
"ldap_url": "ldap://localhost:389/", "ldap_url": "ldap://localhost:389/",