__init__.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # -*- coding: utf-8 -*-
  2. #
  3. # This file is part of Radicale Server - Calendar Server
  4. # Copyright © 2008-2012 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 management.
  22. ACL is basically the wrong name here since this package deals with authenticating users.
  23. The authorization part is done in the package "authorization".
  24. This module loads a list of users with access rights, according to the acl
  25. configuration.
  26. """
  27. from radicale import config, log
  28. CONFIG_PREFIX = "acl"
  29. def _config_users(name):
  30. """Get an iterable of strings from the configuraton string [acl] ``name``.
  31. The values must be separated by a comma. The whitespace characters are
  32. stripped at the beginning and at the end of the values.
  33. """
  34. for user in config.get(CONFIG_PREFIX, name).split(","):
  35. user = user.strip()
  36. yield None if user == "None" else user
  37. def load():
  38. """Load list of available ACL managers."""
  39. acl_type = config.get(CONFIG_PREFIX, "type")
  40. log.LOGGER.debug("acl_type = " + acl_type)
  41. if acl_type == "None":
  42. return None
  43. else:
  44. module = __import__("acl.%s" % acl_type, globals=globals(), level=2)
  45. return getattr(module, acl_type)