moduleapi: Distribute permissions set from global modules to all hosts

Roles and permissions will always happen in the context of a host.

Prevents error upon indexing since `hosts["*"] == nil`
This commit is contained in:
Kim Alvefur 2022-07-20 13:05:35 +02:00
parent a0f2f9ee19
commit 5f8e441449

View file

@ -604,6 +604,14 @@ end
function api:default_permission(role_name, permission)
permission = permission:gsub("^:", self.name..":");
if self.host == "*" then
for _, host in pairs(hosts) do
if host.authz then
host.authz.add_default_permission(role_name, permission);
end
end
return
end
hosts[self.host].authz.add_default_permission(role_name, permission);
end