File

spec/scansion/pubsub_max_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
line wrap: on
line source

# Pubsub: Requesting the Most Recent Items (#1608)

[Client] Alice
	jid: admin@localhost
	password: password

---------

Alice connects

Alice sends:
	<presence xmlns:stream="http://etherx.jabber.org/streams" id=":7IoqYcT3191rfk_dZGo2"/>

Alice receives:
	<presence xmlns:stream="http://etherx.jabber.org/streams" from="${Alice's full JID}" id=":7IoqYcT3191rfk_dZGo2"/>

Alice sends:
	<iq xmlns:stream="http://etherx.jabber.org/streams" to="pubsub.localhost" id=":m0SM8Hn5JxP9BJJ_X4Mz" type="set">
	  <pubsub xmlns="http://jabber.org/protocol/pubsub">
	    <create node="5549ea47-ea53-4cc1-9e7c-37842fe4bc06"/>
	  </pubsub>
	</iq>

Alice receives:
	<iq xmlns:stream="http://etherx.jabber.org/streams" to="${Alice's full JID}" from="pubsub.localhost" type="result" id=":m0SM8Hn5JxP9BJJ_X4Mz"/>

Alice sends:
	<iq xmlns:stream="http://etherx.jabber.org/streams" to="pubsub.localhost" id=":gwZgEQmzAHcQz-FZOxi-" type="get">
	  <pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
	    <configure node="5549ea47-ea53-4cc1-9e7c-37842fe4bc06"/>
	  </pubsub>
	</iq>

Alice receives:
	<iq xmlns:stream="http://etherx.jabber.org/streams" to="${Alice's full JID}" from="pubsub.localhost" type="result" id=":gwZgEQmzAHcQz-FZOxi-">
	  <pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
	    <configure node="5549ea47-ea53-4cc1-9e7c-37842fe4bc06">
	      <x xmlns="jabber:x:data" type="form">
		<field var="FORM_TYPE" type="hidden">
		  <value>http://jabber.org/protocol/pubsub#node_config</value>
		</field>
		<field var="pubsub#title" label="Title" type="text-single"/>
		<field var="pubsub#description" label="Description" type="text-single"/>
		<field var="pubsub#type" label="The type of node data, usually specified by the namespace of the payload (if any)" type="text-single"/>
		<field var="pubsub#max_items" label="Max # of items to persist" type="text-single">
			<validate xmlns="http://jabber.org/protocol/xdata-validate" datatype="pubsub:integer-or-max">
				<range min="1" max="256"/>
			</validate>
		  <value>20</value>
		</field>
		<field var="pubsub#persist_items" label="Persist items to storage" type="boolean">
		  <value>1</value>
		</field>
		<field var="pubsub#access_model" label="Specify the subscriber model" type="list-single">
		  <option label="authorize">
		    <value>authorize</value>
		  </option>
		  <option label="open">
		    <value>open</value>
		  </option>
		  <option label="presence">
		    <value>presence</value>
		  </option>
		  <option label="roster">
		    <value>roster</value>
		  </option>
		  <option label="whitelist">
		    <value>whitelist</value>
		  </option>
		  <value>open</value>
		</field>
		<field var="pubsub#publish_model" label="Specify the publisher model" type="list-single">
		  <option label="publishers">
		    <value>publishers</value>
		  </option>
		  <option label="subscribers">
		    <value>subscribers</value>
		  </option>
		  <option label="open">
		    <value>open</value>
		  </option>
		  <value>publishers</value>
		</field>
		<field type='list-single' var='pubsub#send_last_published_item'>
			<option label='never'>
				<value>never</value>
			</option>
			<option label='on_sub'>
				<value>on_sub</value>
			</option>
			<option label='on_sub_and_presence'>
				<value>on_sub_and_presence</value>
			</option>
			<value>never</value>
		</field>
		<field var="pubsub#deliver_notifications" label="Whether to deliver event notifications" type="boolean">
		  <value>1</value>
		</field>
		<field var="pubsub#deliver_payloads" label="Whether to deliver payloads with event notifications" type="boolean">
		  <value>1</value>
		</field>
		<field var="pubsub#notification_type" label="Specify the delivery style for notifications" type="list-single">
		  <option label="Messages of type normal">
		    <value>normal</value>
		  </option>
		  <option label="Messages of type headline">
		    <value>headline</value>
		  </option>
		  <value>headline</value>
		</field>
		<field var="pubsub#notify_delete" label="Whether to notify subscribers when the node is deleted" type="boolean">
		  <value>1</value>
		</field>
		<field var="pubsub#notify_retract" label="Whether to notify subscribers when items are removed from the node" type="boolean">
		  <value>1</value>
		</field>
	      </x>
	    </configure>
	  </pubsub>
	</iq>

Alice sends:
	<iq xmlns:stream="http://etherx.jabber.org/streams" to="pubsub.localhost" id=":pfWBQ2MNIq8ieul57Qp7" type="set">
	  <pubsub xmlns="http://jabber.org/protocol/pubsub">
	    <publish node="5549ea47-ea53-4cc1-9e7c-37842fe4bc06">
	      <item id="20e9eb9e-8acb-436e-a486-40e80400faf1">
		<foo xmlns="https://zombofant.net/xmlns/aioxmpp#test">foo</foo>
	      </item>
	    </publish>
	  </pubsub>
	</iq>

Alice receives:
	<iq xmlns:stream="http://etherx.jabber.org/streams" to="${Alice's full JID}" from="pubsub.localhost" type="result" id=":pfWBQ2MNIq8ieul57Qp7">
	  <pubsub xmlns="http://jabber.org/protocol/pubsub">
	    <publish node="5549ea47-ea53-4cc1-9e7c-37842fe4bc06">
	      <item id="20e9eb9e-8acb-436e-a486-40e80400faf1"/>
	    </publish>
	  </pubsub>
	</iq>

Alice sends:
	<iq xmlns:stream="http://etherx.jabber.org/streams" to="pubsub.localhost" id=":Q5TLT6nsW0HHdkDgrPPe" type="set">
	  <pubsub xmlns="http://jabber.org/protocol/pubsub">
	    <publish node="5549ea47-ea53-4cc1-9e7c-37842fe4bc06">
	      <item id="4b94623d-1127-41c0-ac47-e283fd890557">
		<foo xmlns="https://zombofant.net/xmlns/aioxmpp#test">bar</foo>
	      </item>
	    </publish>
	  </pubsub>
	</iq>

Alice receives:
	<iq xmlns:stream="http://etherx.jabber.org/streams" to="${Alice's full JID}" from="pubsub.localhost" type="result" id=":Q5TLT6nsW0HHdkDgrPPe">
	  <pubsub xmlns="http://jabber.org/protocol/pubsub">
	    <publish node="5549ea47-ea53-4cc1-9e7c-37842fe4bc06">
	      <item id="4b94623d-1127-41c0-ac47-e283fd890557"/>
	    </publish>
	  </pubsub>
	</iq>

Alice sends:
	<iq xmlns:stream="http://etherx.jabber.org/streams" to="pubsub.localhost" id=":3nvB2E20p1iuM6lOPaP6" type="get">
	  <pubsub xmlns="http://jabber.org/protocol/pubsub">
			<items node="5549ea47-ea53-4cc1-9e7c-37842fe4bc06" max_items="1"/>
	  </pubsub>
	</iq>

Alice receives:
	<iq xmlns:stream="http://etherx.jabber.org/streams" to="${Alice's full JID}" from="pubsub.localhost" type="result" id=":3nvB2E20p1iuM6lOPaP6">
	  <pubsub xmlns="http://jabber.org/protocol/pubsub">
	    <items node="5549ea47-ea53-4cc1-9e7c-37842fe4bc06">
	      <item publisher="${Alice's JID}" xmlns="http://jabber.org/protocol/pubsub" id="4b94623d-1127-41c0-ac47-e283fd890557">
		<foo xmlns="https://zombofant.net/xmlns/aioxmpp#test">bar</foo>
	      </item>
	    </items>
	  </pubsub>
	</iq>

Alice sends:
	<iq xmlns:stream="http://etherx.jabber.org/streams" to="pubsub.localhost" id=":XQdyK54iyOKiJvUoX9t_" type="get">
	  <pubsub xmlns="http://jabber.org/protocol/pubsub">
	    <items node="5549ea47-ea53-4cc1-9e7c-37842fe4bc06"/>
	  </pubsub>
	</iq>

Alice receives:
	<iq xmlns:stream="http://etherx.jabber.org/streams" to="${Alice's full JID}" from="pubsub.localhost" type="result" id=":XQdyK54iyOKiJvUoX9t_">
	  <pubsub xmlns="http://jabber.org/protocol/pubsub">
	    <items node="5549ea47-ea53-4cc1-9e7c-37842fe4bc06">
	      <item xmlns="http://jabber.org/protocol/pubsub" publisher="${Alice's JID}" id="20e9eb9e-8acb-436e-a486-40e80400faf1">
		<foo xmlns="https://zombofant.net/xmlns/aioxmpp#test">foo</foo>
	      </item>
	      <item xmlns="http://jabber.org/protocol/pubsub" publisher="${Alice's JID}" id="4b94623d-1127-41c0-ac47-e283fd890557">
		<foo xmlns="https://zombofant.net/xmlns/aioxmpp#test">bar</foo>
	      </item>
	    </items>
	  </pubsub>
	</iq>

Alice sends:
	<iq xmlns:stream="http://etherx.jabber.org/streams" to="pubsub.localhost" id=":ySGQOz5tnyWT82idwJZP" type="set">
	  <pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
	    <delete node="5549ea47-ea53-4cc1-9e7c-37842fe4bc06"/>
	  </pubsub>
	</iq>

Alice receives:
	<iq xmlns:stream="http://etherx.jabber.org/streams" to="${Alice's full JID}" from="pubsub.localhost" type="result" id=":ySGQOz5tnyWT82idwJZP"/>