mirror of
https://github.com/Kozea/Radicale.git
synced 2025-06-26 16:45:52 +00:00
Merge pull request #335 from Kozea/permissions
Use the first matching section for getting rights
This commit is contained in:
commit
b484d42547
1 changed files with 5 additions and 5 deletions
|
@ -55,8 +55,8 @@ else:
|
||||||
|
|
||||||
DEFINED_RIGHTS = {
|
DEFINED_RIGHTS = {
|
||||||
"authenticated": "[rw]\nuser:.+\ncollection:.*\npermission:rw",
|
"authenticated": "[rw]\nuser:.+\ncollection:.*\npermission:rw",
|
||||||
"owner_write": "[r]\nuser:.+\ncollection:.*\npermission:r\n"
|
"owner_write": "[w]\nuser:.+\ncollection:^%(login)s(/.*)?$\npermission:rw"
|
||||||
"[w]\nuser:.+\ncollection:^%(login)s(/.*)?$\npermission:w",
|
"[r]\nuser:.+\ncollection:.*\npermission:r\n",
|
||||||
"owner_only": "[rw]\nuser:.+\ncollection:^%(login)s(/.*)?$\npermission:rw",
|
"owner_only": "[rw]\nuser:.+\ncollection:^%(login)s(/.*)?$\npermission:rw",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,8 +92,7 @@ def _read_from_sections(user, collection_url, permission):
|
||||||
re_collection = re_collection.format(*user_match.groups())
|
re_collection = re_collection.format(*user_match.groups())
|
||||||
if re.match(re_collection, collection_url):
|
if re.match(re_collection, collection_url):
|
||||||
log.LOGGER.debug("Section '%s' matches" % section)
|
log.LOGGER.debug("Section '%s' matches" % section)
|
||||||
if permission in regex.get(section, "permission"):
|
return permission in regex.get(section, "permission")
|
||||||
return True
|
|
||||||
else:
|
else:
|
||||||
log.LOGGER.debug("Section '%s' does not match" % section)
|
log.LOGGER.debug("Section '%s' does not match" % section)
|
||||||
return False
|
return False
|
||||||
|
@ -102,7 +101,8 @@ def _read_from_sections(user, collection_url, permission):
|
||||||
def authorized(user, collection, permission):
|
def authorized(user, collection, permission):
|
||||||
"""Check if the user is allowed to read or write the collection.
|
"""Check if the user is allowed to read or write the collection.
|
||||||
|
|
||||||
If the user is empty it checks for anonymous rights
|
If the user is empty, check for anonymous rights.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
collection_url = collection.url.rstrip("/") or "/"
|
collection_url = collection.url.rstrip("/") or "/"
|
||||||
if collection_url in (".well-known/carddav", ".well-known/caldav"):
|
if collection_url in (".well-known/carddav", ".well-known/caldav"):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue