Software /
code /
prosody
Annotate
spec/scansion/pubsub_multi_items.scs @ 12642:9061f9621330
Switch to a new role-based authorization framework, removing is_admin()
We began moving away from simple "is this user an admin?" permission checks
before 0.12, with the introduction of mod_authz_internal and the ability to
dynamically change the roles of individual users.
The approach in 0.12 still had various limitations however, and apart from
the introduction of roles other than "admin" and the ability to pull that info
from storage, not much actually changed.
This new framework shakes things up a lot, though aims to maintain the same
functionality and behaviour on the surface for a default Prosody
configuration. That is, if you don't take advantage of any of the new
features, you shouldn't notice any change.
The biggest change visible to developers is that usermanager.is_admin() (and
the auth provider is_admin() method) have been removed. Gone. Completely.
Permission checks should now be performed using a new module API method:
module:may(action_name, context)
This method accepts an action name, followed by either a JID (string) or
(preferably) a table containing 'origin'/'session' and 'stanza' fields (e.g.
the standard object passed to most events). It will return true if the action
should be permitted, or false/nil otherwise.
Modules should no longer perform permission checks based on the role name.
E.g. a lot of code previously checked if the user's role was prosody:admin
before permitting some action. Since many roles might now exist with similar
permissions, and the permissions of prosody:admin may be redefined
dynamically, it is no longer suitable to use this method for permission
checks. Use module:may().
If you start an action name with ':' (recommended) then the current module's
name will automatically be used as a prefix.
To define a new permission, use the new module API:
module:default_permission(role_name, action_name)
module:default_permissions(role_name, { action_name[, action_name...] })
This grants the specified role permission to execute the named action(s) by
default. This may be overridden via other mechanisms external to your module.
The built-in roles that developers should use are:
- prosody:user (normal user)
- prosody:admin (host admin)
- prosody:operator (global admin)
The new prosody:operator role is intended for server-wide actions (such as
shutting down Prosody).
Finally, all usage of is_admin() in modules has been fixed by this commit.
Some of these changes were trickier than others, but no change is expected to
break existing deployments.
EXCEPT: mod_auth_ldap no longer supports the ldap_admin_filter option. It's
very possible nobody is using this, but if someone is then we can later update
it to pull roles from LDAP somehow.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 15 Jun 2022 12:15:01 +0100 |
parent | 11856:14a679588b7b |
child | 12966:7465d3c5679d |
rev | line source |
---|---|
9833 | 1 # Pubsub: Requesting multiple specific items from a node (#1322) |
2 | |
3 [Client] Alice | |
4 jid: admin@localhost | |
5 password: password | |
6 | |
7 --------- | |
8 | |
9 Alice connects | |
10 | |
11 Alice sends: | |
12 <presence xmlns:stream="http://etherx.jabber.org/streams" id=":7IoqYcT3191rfk_dZGo2"/> | |
13 | |
14 Alice receives: | |
15 <presence xmlns:stream="http://etherx.jabber.org/streams" from="${Alice's full JID}" id=":7IoqYcT3191rfk_dZGo2"/> | |
16 | |
17 Alice sends: | |
18 <iq xmlns:stream="http://etherx.jabber.org/streams" to="pubsub.localhost" id=":m0SM8Hn5JxP9BJJ_X4Mz" type="set"> | |
19 <pubsub xmlns="http://jabber.org/protocol/pubsub"> | |
20 <create node="e96caf12-264f-4e5a-988e-00ae191771b6"/> | |
21 </pubsub> | |
22 </iq> | |
23 | |
24 Alice receives: | |
25 <iq xmlns:stream="http://etherx.jabber.org/streams" to="${Alice's full JID}" from="pubsub.localhost" type="result" id=":m0SM8Hn5JxP9BJJ_X4Mz"/> | |
26 | |
27 Alice sends: | |
28 <iq xmlns:stream="http://etherx.jabber.org/streams" to="pubsub.localhost" id=":gwZgEQmzAHcQz-FZOxi-" type="get"> | |
29 <pubsub xmlns="http://jabber.org/protocol/pubsub#owner"> | |
30 <configure node="e96caf12-264f-4e5a-988e-00ae191771b6"/> | |
31 </pubsub> | |
32 </iq> | |
33 | |
34 Alice receives: | |
35 <iq xmlns:stream="http://etherx.jabber.org/streams" to="${Alice's full JID}" from="pubsub.localhost" type="result" id=":gwZgEQmzAHcQz-FZOxi-"> | |
36 <pubsub xmlns="http://jabber.org/protocol/pubsub#owner"> | |
37 <configure node="e96caf12-264f-4e5a-988e-00ae191771b6"> | |
38 <x xmlns="jabber:x:data" type="form"> | |
39 <field var="FORM_TYPE" type="hidden"> | |
40 <value>http://jabber.org/protocol/pubsub#node_config</value> | |
41 </field> | |
42 <field var="pubsub#title" label="Title" type="text-single"/> | |
43 <field var="pubsub#description" label="Description" type="text-single"/> | |
44 <field var="pubsub#type" label="The type of node data, usually specified by the namespace of the payload (if any)" type="text-single"/> | |
45 <field var="pubsub#max_items" label="Max # of items to persist" type="text-single"> | |
11855
8890eaa69446
mod_pubsub: Prevent max_items from being set to zero
Kim Alvefur <zash@zash.se>
parents:
11854
diff
changeset
|
46 <validate xmlns="http://jabber.org/protocol/xdata-validate" datatype="pubsub:integer-or-max"> |
11856
14a679588b7b
mod_pubsub,mod_pep: Advertise maximum number of items via XEP-0122
Kim Alvefur <zash@zash.se>
parents:
11855
diff
changeset
|
47 <range min="1" max="256"/> |
11855
8890eaa69446
mod_pubsub: Prevent max_items from being set to zero
Kim Alvefur <zash@zash.se>
parents:
11854
diff
changeset
|
48 </validate> |
9833 | 49 <value>20</value> |
50 </field> | |
51 <field var="pubsub#persist_items" label="Persist items to storage" type="boolean"> | |
11720
72512c0858b3
mod_pubsub: Explicitly enable persistence by default to preserve behavior
Kim Alvefur <zash@zash.se>
parents:
11714
diff
changeset
|
52 <value>1</value> |
9833 | 53 </field> |
54 <field var="pubsub#access_model" label="Specify the subscriber model" type="list-single"> | |
55 <option label="authorize"> | |
56 <value>authorize</value> | |
57 </option> | |
58 <option label="open"> | |
59 <value>open</value> | |
60 </option> | |
61 <option label="presence"> | |
62 <value>presence</value> | |
63 </option> | |
64 <option label="roster"> | |
65 <value>roster</value> | |
66 </option> | |
67 <option label="whitelist"> | |
68 <value>whitelist</value> | |
69 </option> | |
70 <value>open</value> | |
71 </field> | |
72 <field var="pubsub#publish_model" label="Specify the publisher model" type="list-single"> | |
73 <option label="publishers"> | |
74 <value>publishers</value> | |
75 </option> | |
76 <option label="subscribers"> | |
77 <value>subscribers</value> | |
78 </option> | |
79 <option label="open"> | |
80 <value>open</value> | |
81 </option> | |
82 <value>publishers</value> | |
83 </field> | |
11854
b605cbd5f13b
mod_pubsub,mod_pep: Implement 'send_last_published_item' option #1436
Kim Alvefur <zash@zash.se>
parents:
11720
diff
changeset
|
84 <field type='list-single' var='pubsub#send_last_published_item'> |
b605cbd5f13b
mod_pubsub,mod_pep: Implement 'send_last_published_item' option #1436
Kim Alvefur <zash@zash.se>
parents:
11720
diff
changeset
|
85 <option label='never'> |
b605cbd5f13b
mod_pubsub,mod_pep: Implement 'send_last_published_item' option #1436
Kim Alvefur <zash@zash.se>
parents:
11720
diff
changeset
|
86 <value>never</value> |
b605cbd5f13b
mod_pubsub,mod_pep: Implement 'send_last_published_item' option #1436
Kim Alvefur <zash@zash.se>
parents:
11720
diff
changeset
|
87 </option> |
b605cbd5f13b
mod_pubsub,mod_pep: Implement 'send_last_published_item' option #1436
Kim Alvefur <zash@zash.se>
parents:
11720
diff
changeset
|
88 <option label='on_sub'> |
b605cbd5f13b
mod_pubsub,mod_pep: Implement 'send_last_published_item' option #1436
Kim Alvefur <zash@zash.se>
parents:
11720
diff
changeset
|
89 <value>on_sub</value> |
b605cbd5f13b
mod_pubsub,mod_pep: Implement 'send_last_published_item' option #1436
Kim Alvefur <zash@zash.se>
parents:
11720
diff
changeset
|
90 </option> |
b605cbd5f13b
mod_pubsub,mod_pep: Implement 'send_last_published_item' option #1436
Kim Alvefur <zash@zash.se>
parents:
11720
diff
changeset
|
91 <option label='on_sub_and_presence'> |
b605cbd5f13b
mod_pubsub,mod_pep: Implement 'send_last_published_item' option #1436
Kim Alvefur <zash@zash.se>
parents:
11720
diff
changeset
|
92 <value>on_sub_and_presence</value> |
b605cbd5f13b
mod_pubsub,mod_pep: Implement 'send_last_published_item' option #1436
Kim Alvefur <zash@zash.se>
parents:
11720
diff
changeset
|
93 </option> |
b605cbd5f13b
mod_pubsub,mod_pep: Implement 'send_last_published_item' option #1436
Kim Alvefur <zash@zash.se>
parents:
11720
diff
changeset
|
94 <value>never</value> |
b605cbd5f13b
mod_pubsub,mod_pep: Implement 'send_last_published_item' option #1436
Kim Alvefur <zash@zash.se>
parents:
11720
diff
changeset
|
95 </field> |
9833 | 96 <field var="pubsub#deliver_notifications" label="Whether to deliver event notifications" type="boolean"> |
97 <value>1</value> | |
98 </field> | |
99 <field var="pubsub#deliver_payloads" label="Whether to deliver payloads with event notifications" type="boolean"> | |
100 <value>1</value> | |
101 </field> | |
102 <field var="pubsub#notification_type" label="Specify the delivery style for notifications" type="list-single"> | |
103 <option label="Messages of type normal"> | |
104 <value>normal</value> | |
105 </option> | |
106 <option label="Messages of type headline"> | |
107 <value>headline</value> | |
108 </option> | |
109 <value>headline</value> | |
110 </field> | |
111 <field var="pubsub#notify_delete" label="Whether to notify subscribers when the node is deleted" type="boolean"> | |
112 <value>1</value> | |
113 </field> | |
114 <field var="pubsub#notify_retract" label="Whether to notify subscribers when items are removed from the node" type="boolean"> | |
115 <value>1</value> | |
116 </field> | |
117 </x> | |
118 </configure> | |
119 </pubsub> | |
120 </iq> | |
121 | |
122 Alice sends: | |
123 <iq xmlns:stream="http://etherx.jabber.org/streams" to="pubsub.localhost" id=":pfWBQ2MNIq8ieul57Qp7" type="set"> | |
124 <pubsub xmlns="http://jabber.org/protocol/pubsub"> | |
125 <publish node="e96caf12-264f-4e5a-988e-00ae191771b6"> | |
126 <item id="20e9eb9e-8acb-436e-a486-40e80400faf1"> | |
127 <foo xmlns="https://zombofant.net/xmlns/aioxmpp#test">foo</foo> | |
128 </item> | |
129 </publish> | |
130 </pubsub> | |
131 </iq> | |
132 | |
133 Alice receives: | |
134 <iq xmlns:stream="http://etherx.jabber.org/streams" to="${Alice's full JID}" from="pubsub.localhost" type="result" id=":pfWBQ2MNIq8ieul57Qp7"> | |
135 <pubsub xmlns="http://jabber.org/protocol/pubsub"> | |
136 <publish node="e96caf12-264f-4e5a-988e-00ae191771b6"> | |
137 <item id="20e9eb9e-8acb-436e-a486-40e80400faf1"/> | |
138 </publish> | |
139 </pubsub> | |
140 </iq> | |
141 | |
142 Alice sends: | |
143 <iq xmlns:stream="http://etherx.jabber.org/streams" to="pubsub.localhost" id=":Q5TLT6nsW0HHdkDgrPPe" type="set"> | |
144 <pubsub xmlns="http://jabber.org/protocol/pubsub"> | |
145 <publish node="e96caf12-264f-4e5a-988e-00ae191771b6"> | |
146 <item id="4b94623d-1127-41c0-ac47-e283fd890557"> | |
147 <foo xmlns="https://zombofant.net/xmlns/aioxmpp#test">bar</foo> | |
148 </item> | |
149 </publish> | |
150 </pubsub> | |
151 </iq> | |
152 | |
153 Alice receives: | |
154 <iq xmlns:stream="http://etherx.jabber.org/streams" to="${Alice's full JID}" from="pubsub.localhost" type="result" id=":Q5TLT6nsW0HHdkDgrPPe"> | |
155 <pubsub xmlns="http://jabber.org/protocol/pubsub"> | |
156 <publish node="e96caf12-264f-4e5a-988e-00ae191771b6"> | |
157 <item id="4b94623d-1127-41c0-ac47-e283fd890557"/> | |
158 </publish> | |
159 </pubsub> | |
160 </iq> | |
161 | |
162 Alice sends: | |
163 <iq xmlns:stream="http://etherx.jabber.org/streams" to="pubsub.localhost" id=":3nvB2E20p1iuM6lOPaP6" type="get"> | |
164 <pubsub xmlns="http://jabber.org/protocol/pubsub"> | |
165 <items node="e96caf12-264f-4e5a-988e-00ae191771b6"> | |
166 <item id="20e9eb9e-8acb-436e-a486-40e80400faf1"/> | |
167 <item id="4b94623d-1127-41c0-ac47-e283fd890557"/> | |
168 </items> | |
169 </pubsub> | |
170 </iq> | |
171 | |
172 Alice receives: | |
173 <iq xmlns:stream="http://etherx.jabber.org/streams" to="${Alice's full JID}" from="pubsub.localhost" type="result" id=":3nvB2E20p1iuM6lOPaP6"> | |
174 <pubsub xmlns="http://jabber.org/protocol/pubsub"> | |
175 <items node="e96caf12-264f-4e5a-988e-00ae191771b6"> | |
11714
d783716103c1
mod_pubsub: Fix inclusion of publisher (fixes #1399)
Kim Alvefur <zash@zash.se>
parents:
11631
diff
changeset
|
176 <item publisher="${Alice's JID}" xmlns="http://jabber.org/protocol/pubsub" id="20e9eb9e-8acb-436e-a486-40e80400faf1"> |
9833 | 177 <foo xmlns="https://zombofant.net/xmlns/aioxmpp#test">foo</foo> |
178 </item> | |
11714
d783716103c1
mod_pubsub: Fix inclusion of publisher (fixes #1399)
Kim Alvefur <zash@zash.se>
parents:
11631
diff
changeset
|
179 <item publisher="${Alice's JID}" xmlns="http://jabber.org/protocol/pubsub" id="4b94623d-1127-41c0-ac47-e283fd890557"> |
9833 | 180 <foo xmlns="https://zombofant.net/xmlns/aioxmpp#test">bar</foo> |
181 </item> | |
182 </items> | |
183 </pubsub> | |
184 </iq> | |
185 | |
186 Alice sends: | |
187 <iq xmlns:stream="http://etherx.jabber.org/streams" to="pubsub.localhost" id=":XQdyK54iyOKiJvUoX9t_" type="get"> | |
188 <pubsub xmlns="http://jabber.org/protocol/pubsub"> | |
189 <items node="e96caf12-264f-4e5a-988e-00ae191771b6"/> | |
190 </pubsub> | |
191 </iq> | |
192 | |
193 Alice receives: | |
194 <iq xmlns:stream="http://etherx.jabber.org/streams" to="${Alice's full JID}" from="pubsub.localhost" type="result" id=":XQdyK54iyOKiJvUoX9t_"> | |
195 <pubsub xmlns="http://jabber.org/protocol/pubsub"> | |
196 <items node="e96caf12-264f-4e5a-988e-00ae191771b6"> | |
11714
d783716103c1
mod_pubsub: Fix inclusion of publisher (fixes #1399)
Kim Alvefur <zash@zash.se>
parents:
11631
diff
changeset
|
197 <item xmlns="http://jabber.org/protocol/pubsub" publisher="${Alice's JID}" id="20e9eb9e-8acb-436e-a486-40e80400faf1"> |
9833 | 198 <foo xmlns="https://zombofant.net/xmlns/aioxmpp#test">foo</foo> |
199 </item> | |
11714
d783716103c1
mod_pubsub: Fix inclusion of publisher (fixes #1399)
Kim Alvefur <zash@zash.se>
parents:
11631
diff
changeset
|
200 <item xmlns="http://jabber.org/protocol/pubsub" publisher="${Alice's JID}" id="4b94623d-1127-41c0-ac47-e283fd890557"> |
9833 | 201 <foo xmlns="https://zombofant.net/xmlns/aioxmpp#test">bar</foo> |
202 </item> | |
203 </items> | |
204 </pubsub> | |
205 </iq> | |
206 | |
207 Alice sends: | |
208 <iq xmlns:stream="http://etherx.jabber.org/streams" to="pubsub.localhost" id=":ySGQOz5tnyWT82idwJZP" type="set"> | |
209 <pubsub xmlns="http://jabber.org/protocol/pubsub#owner"> | |
210 <delete node="e96caf12-264f-4e5a-988e-00ae191771b6"/> | |
211 </pubsub> | |
212 </iq> | |
213 | |
214 Alice receives: | |
215 <iq xmlns:stream="http://etherx.jabber.org/streams" to="${Alice's full JID}" from="pubsub.localhost" type="result" id=":ySGQOz5tnyWT82idwJZP"/> | |
216 |