2010-01-15 00:15:41 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2008-12-30 16:25:42 +00:00
|
|
|
#
|
|
|
|
# This file is part of Radicale Server - Calendar Server
|
2011-01-09 17:46:22 +01:00
|
|
|
# Copyright © 2008-2011 Guillaume Ayoub
|
2009-07-27 15:04:54 +00:00
|
|
|
# Copyright © 2008 Nicolas Kandel
|
|
|
|
# Copyright © 2008 Pascal Halter
|
2008-12-30 16:25:42 +00:00
|
|
|
#
|
|
|
|
# This library is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with Radicale. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2009-07-27 15:04:54 +00:00
|
|
|
"""
|
|
|
|
Users and rights management.
|
|
|
|
|
|
|
|
This module loads a list of users with access rights, according to the acl
|
|
|
|
configuration.
|
2010-02-10 18:57:21 +01:00
|
|
|
|
2009-07-27 15:04:54 +00:00
|
|
|
"""
|
|
|
|
|
2010-01-15 16:04:03 +01:00
|
|
|
from radicale import config
|
2008-12-30 16:25:42 +00:00
|
|
|
|
2010-02-10 18:57:21 +01:00
|
|
|
|
2011-06-13 22:15:52 +02:00
|
|
|
PUBLIC_USERS = []
|
|
|
|
PRIVATE_USERS = [None]
|
|
|
|
|
|
|
|
|
|
|
|
def _config_users(name):
|
|
|
|
"""Get an iterable of strings from the configuraton string [acl] ``name``.
|
|
|
|
|
|
|
|
The values must be separated by a comma. The whitespace characters are
|
|
|
|
stripped at the beginning and at the end of the values.
|
|
|
|
|
|
|
|
"""
|
|
|
|
return (user.strip() for user in config.get("acl", name).split(","))
|
|
|
|
|
|
|
|
|
2010-01-21 18:52:53 +01:00
|
|
|
def load():
|
2010-02-10 18:57:21 +01:00
|
|
|
"""Load list of available ACL managers."""
|
2011-04-10 18:17:06 +02:00
|
|
|
acl_type = config.get("acl", "type")
|
|
|
|
if acl_type == "None":
|
|
|
|
return None
|
|
|
|
else:
|
2011-06-13 22:15:52 +02:00
|
|
|
PUBLIC_USERS.extend(_config_users("public_users"))
|
|
|
|
PRIVATE_USERS.extend(_config_users("private_users"))
|
2011-04-10 18:17:06 +02:00
|
|
|
module = __import__("radicale.acl", fromlist=[acl_type])
|
|
|
|
return getattr(module, acl_type)
|