You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
1.0 KiB

  1. # Copyright 2018 Therp BV <https://therp.nl>
  2. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  3. from .collection import Collection
  4. try:
  5. from radicale.rights.owner_only import Rights as OwnerOnlyRights
  6. from radicale.rights.authenticated import Rights as AuthenticatedRights
  7. from radicale.rights.owner_write import Rights as OwnerWriteRights
  8. except ImportError:
  9. AuthenticatedRights = OwnerOnlyRights = OwnerWriteRights = None
  10. class Rights(OwnerOnlyRights, OwnerWriteRights, AuthenticatedRights):
  11. def authorization(self, user, path):
  12. if path == '/':
  13. return True
  14. collection = Collection(path)
  15. if not collection.collection:
  16. return ""
  17. rights = collection.collection.sudo().rights
  18. cls = {
  19. "owner_only": OwnerOnlyRights,
  20. "owner_write_only": OwnerWriteRights,
  21. "authenticated": AuthenticatedRights,
  22. }.get(rights)
  23. if not cls:
  24. return False
  25. return cls.authorization(self, user, path)