Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/openwrt/luci.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-11-02 12:09:05 +0300
committerJo-Philipp Wich <jo@mein.io>2022-11-02 12:13:41 +0300
commitc99602e4ac72f4f6410449dd7175d52b974de9cc (patch)
tree53284ee44874600012565786e5769bb257080577 /modules
parentd967bbaa92ae56692ab449f57ca74f120943e799 (diff)
luci-base: dispatcher.uc: apply ACLs to menu tree JSON
Add menu tree annotations for node readonly and dependency satisfied state in order to ensure that unreachable menu nodes are hidden from view. Fixes: ded8ccf93e ("luci-base-ucode: add initial ucode based LuCI runtime") Ref: https://forum.openwrt.org/t/x/141426/10 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules')
-rw-r--r--modules/luci-base/ucode/dispatcher.uc15
1 files changed, 15 insertions, 0 deletions
diff --git a/modules/luci-base/ucode/dispatcher.uc b/modules/luci-base/ucode/dispatcher.uc
index 805abc4ce0..86cab9b88f 100644
--- a/modules/luci-base/ucode/dispatcher.uc
+++ b/modules/luci-base/ucode/dispatcher.uc
@@ -423,9 +423,24 @@ function build_pagetree() {
return tree;
}
+function apply_tree_acls(node, acl) {
+ for (let name, spec in node?.children)
+ apply_tree_acls(spec, acl);
+
+ if (node?.depends?.acl) {
+ switch (check_acl_depends(node.depends.acl, acl["access-group"])) {
+ case null: node.satisfied = false; break;
+ case false: node.readonly = true; break;
+ }
+ }
+}
+
function menu_json(acl) {
tree ??= build_pagetree();
+ if (acl)
+ apply_tree_acls(tree, acl);
+
return tree;
}