1
0
Fork 0
mirror of https://github.com/Kozea/Radicale.git synced 2025-06-26 16:45:52 +00:00

Enhancement: add option to toggle debug log of right with doesn't match

This commit is contained in:
Peter Bieringer 2024-08-28 08:03:16 +02:00
parent 107fe1bc53
commit e852c887d7
5 changed files with 16 additions and 1 deletions

View file

@ -8,6 +8,7 @@
* Enhancement: Added 'max_freebusy_occurrences` setting to avoid potential DOS on reports * Enhancement: Added 'max_freebusy_occurrences` setting to avoid potential DOS on reports
* Enhancement: remove unexpected control codes from uploaded items * Enhancement: remove unexpected control codes from uploaded items
* Enhancement: add 'strip_domain' setting for username handling * Enhancement: add 'strip_domain' setting for username handling
* Enhancement: add option to toggle debug log of right with doesn't match
* Drop: remove unused requirement "typeguard" * Drop: remove unused requirement "typeguard"
* Improve: Refactored some date parsing code * Improve: Refactored some date parsing code

View file

@ -978,6 +978,12 @@ Log response on level=debug
Default: `False` Default: `False`
##### right_doesnt_match = True
Log right which doesn't match on level=debug
Default: `False`
#### headers #### headers
In this section additional HTTP headers that are sent to clients can be In this section additional HTTP headers that are sent to clients can be

2
config
View file

@ -158,6 +158,8 @@
# Log response content on level=debug # Log response content on level=debug
#response_content_on_debug = False #response_content_on_debug = False
# Log right which doesn't match
#right_doesnt_match = False
[headers] [headers]

View file

@ -292,6 +292,10 @@ DEFAULT_CONFIG_SCHEMA: types.CONFIG_SCHEMA = OrderedDict([
"value": "False", "value": "False",
"help": "log response content on level=debug", "help": "log response content on level=debug",
"type": bool}), "type": bool}),
("right_doesnt_match", {
"value": "False",
"help": "log rights which doesn't match on level=debug",
"type": bool}),
("mask_passwords", { ("mask_passwords", {
"value": "True", "value": "True",
"help": "mask passwords in logs", "help": "mask passwords in logs",

View file

@ -48,6 +48,7 @@ class Rights(rights.BaseRights):
def __init__(self, configuration: config.Configuration) -> None: def __init__(self, configuration: config.Configuration) -> None:
super().__init__(configuration) super().__init__(configuration)
self._filename = configuration.get("rights", "file") self._filename = configuration.get("rights", "file")
self._log_right_doesnt_match = configuration.get("logging", "right_doesnt_match")
def authorization(self, user: str, path: str) -> str: def authorization(self, user: str, path: str) -> str:
user = user or "" user = user or ""
@ -80,7 +81,8 @@ class Rights(rights.BaseRights):
user, sane_path, user_pattern, user, sane_path, user_pattern,
collection_pattern, section, permission) collection_pattern, section, permission)
return permission return permission
logger.debug("Rule %r:%r doesn't match %r:%r from section %r", if self._log_right_doesnt_match:
logger.debug("Rule %r:%r doesn't match %r:%r from section %r",
user, sane_path, user_pattern, collection_pattern, user, sane_path, user_pattern, collection_pattern,
section) section)
logger.info("Rights: %r:%r doesn't match any section", user, sane_path) logger.info("Rights: %r:%r doesn't match any section", user, sane_path)