comparison sat/plugins/plugin_sec_pubsub_signing.py @ 3963:d105ead599b6

plugin pubsub signature: fix attachment setting + default signer: - attachment setting was crashing when `item_elt` was not specified due to argument typo - if `signer` is set to None in attachment data, client's bare jid will be used to sign the item rel 381
author Goffi <goffi@goffi.org>
date Sun, 30 Oct 2022 01:06:58 +0200
parents a15c171836bb
children 524856bd7b19
comparison
equal deleted inserted replaced
3962:2d9d0b77e82b 3963:d105ead599b6
253 service = jid.JID(attachments_data["service"]) 253 service = jid.JID(attachments_data["service"])
254 if item_elt is None: 254 if item_elt is None:
255 node = attachments_data["node"] 255 node = attachments_data["node"]
256 item_id = attachments_data["id"] 256 item_id = attachments_data["id"]
257 items, __ = await self._p.getItems( 257 items, __ = await self._p.getItems(
258 client, service, node, items_ids=[item_id] 258 client, service, node, item_ids=[item_id]
259 ) 259 )
260 if not items != 1: 260 if not items != 1:
261 raise exceptions.NotFound( 261 raise exceptions.NotFound(
262 f"target item not found for {item_id!r} at {node!r} for {service}" 262 f"target item not found for {item_id!r} at {node!r} for {service}"
263 ) 263 )
264 item_elt = items[0] 264 item_elt = items[0]
265 265
266 signer = signature_data["signer"] 266 signer = signature_data.get("signer") or client.jid.userhost()
267 timestamp = time.time() 267 timestamp = time.time()
268 timestamp_xmpp = utils.xmpp_date(timestamp) 268 timestamp_xmpp = utils.xmpp_date(timestamp)
269 to_sign = self.get_data_to_sign(item_elt, service, timestamp, signer) 269 to_sign = self.get_data_to_sign(item_elt, service, timestamp, signer)
270 270
271 signature_elt = domish.Element( 271 signature_elt = domish.Element(