Software / code / prosody
Comparison
core/moduleapi.lua @ 12662:07424992d7fc
mod_authz_internal, and more: New iteration of role API
These changes to the API (hopefully the last) introduce a cleaner separation
between the user's primary (default) role, and their secondary (optional)
roles.
To keep the code sane and reduce complexity, a data migration is needed for
people using stored roles in 0.12. This can be performed with
prosodyctl mod_authz_internal migrate <host>
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Wed, 17 Aug 2022 16:38:53 +0100 |
| parent | 12652:30e2a0107217 |
| child | 12690:546c7e0f3f31 |
comparison
equal
deleted
inserted
replaced
| 12661:1c391c17a907 | 12662:07424992d7fc |
|---|---|
| 536 path = resolve_relative_path(self:get_directory(), path); | 536 path = resolve_relative_path(self:get_directory(), path); |
| 537 return io.open(path, mode); | 537 return io.open(path, mode); |
| 538 end | 538 end |
| 539 | 539 |
| 540 function api:open_store(name, store_type) | 540 function api:open_store(name, store_type) |
| 541 if self.host == "*" then return nil, "global-storage-not-supported"; end | |
| 541 return require"core.storagemanager".open(self.host, name or self.name, store_type); | 542 return require"core.storagemanager".open(self.host, name or self.name, store_type); |
| 542 end | 543 end |
| 543 | 544 |
| 544 function api:measure(name, stat_type, conf) | 545 function api:measure(name, stat_type, conf) |
| 545 local measure = require "core.statsmanager".measure; | 546 local measure = require "core.statsmanager".measure; |
| 627 end | 628 end |
| 628 if type(context) == "string" then -- check JID permissions | 629 if type(context) == "string" then -- check JID permissions |
| 629 local role; | 630 local role; |
| 630 local node, host = jid_split(context); | 631 local node, host = jid_split(context); |
| 631 if host == self.host then | 632 if host == self.host then |
| 632 role = hosts[host].authz.get_user_default_role(node); | 633 role = hosts[host].authz.get_user_role(node); |
| 633 else | 634 else |
| 634 role = hosts[self.host].authz.get_jid_role(context); | 635 role = hosts[self.host].authz.get_jid_role(context); |
| 635 end | 636 end |
| 636 if not role then | 637 if not role then |
| 637 self:log("debug", "Access denied: JID <%s> may not %s (no role found)", context, action); | 638 self:log("debug", "Access denied: JID <%s> may not %s (no role found)", context, action); |