def permissions_for_topics() -> Mapping[str, bool]: return { "global_settings": user.may("wato.global"), "folders": user.may("wato.hosts"), "hosts": user.may("wato.hosts"), "setup": user.may("wato.use"), }
def __init__(self) -> None: self._category_permissions = { "global_settings": user.may("wato.global") or user.may("wato.seeall"), "folders": user.may("wato.hosts"), "hosts": user.may("wato.hosts"), "event_console": user.may("mkeventd.edit") or user.may("wato.seeall"), "event_console_settings": user.may("mkeventd.config") or user.may("wato.seeall"), "logfile_pattern_analyzer": user.may("wato.pattern_editor") or user.may("wato.seeall"), } self._url_checker = URLChecker()
def permissions_for_items(self) -> Mapping[str, Callable[[str], bool]]: return { "rules": self._permissions_rule, "hosts": lambda url: (any( user.may(perm) for perm in ("wato.all_folders", "wato.see_all_folders")) or self._permissions_url(url)), "setup": self._permissions_url, }
def __init__(self): self._topic_permissions = { "global_settings": user.may("wato.global") or user.may("wato.seeall"), "folders": user.may("wato.hosts"), "hosts": user.may("wato.hosts"), "event_console": user.may("mkeventd.edit") or user.may("wato.seeall"), "event_console_settings": user.may("mkeventd.config") or user.may("wato.seeall") } self._url_checker = URLChecker()
def may_see_category(self, category: str) -> bool: return user.may("wato.use") and self._category_permissions.get( category, True)
def may_see_topic(self, topic: str) -> bool: return user.may("wato.use") and self._topic_permissions.get( topic, True)