__init__.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # -*- coding: utf-8 -*-
  2. #
  3. # This file is part of Radicale Server - Calendar Server
  4. # Copyright © 2008-2011 Guillaume Ayoub
  5. # Copyright © 2008 Nicolas Kandel
  6. # Copyright © 2008 Pascal Halter
  7. #
  8. # This library is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation, either version 3 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # This library is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with Radicale. If not, see <http://www.gnu.org/licenses/>.
  20. """
  21. Users and rights management.
  22. This module loads a list of users with access rights, according to the acl
  23. configuration.
  24. """
  25. from radicale import config
  26. PUBLIC_USERS = []
  27. PRIVATE_USERS = []
  28. def _config_users(name):
  29. """Get an iterable of strings from the configuraton string [acl] ``name``.
  30. The values must be separated by a comma. The whitespace characters are
  31. stripped at the beginning and at the end of the values.
  32. """
  33. for user in config.get("acl", name).split(","):
  34. user = user.strip()
  35. yield None if user == "None" else user
  36. def load():
  37. """Load list of available ACL managers."""
  38. acl_type = config.get("acl", "type")
  39. if acl_type == "None":
  40. return None
  41. else:
  42. PUBLIC_USERS.extend(_config_users("public_users"))
  43. PRIVATE_USERS.extend(_config_users("private_users"))
  44. module = __import__("radicale.acl", fromlist=[acl_type])
  45. return getattr(module, acl_type)