Changeset

5686:a1d22d6efb3d

mod_push2: Need to include the public key with the JWT
author Stephen Paul Weber <singpolyma@singpolyma.net>
date Wed, 20 Sep 2023 23:05:29 -0500
parents 5685:81f1c617f4c7
children 5687:4b052598e435
files mod_push2/mod_push2.lua mod_push2/push2.markdown
diffstat 2 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mod_push2/mod_push2.lua	Tue Sep 19 21:39:14 2023 -0500
+++ b/mod_push2/mod_push2.lua	Wed Sep 20 23:05:29 2023 -0500
@@ -285,13 +285,14 @@
 		key = "-----BEGIN PRIVATE KEY-----\n"..key.."\n-----END PRIVATE KEY-----"
 	end
 
+	local public_key = pkey.new(key):getParameters().pub_key:toBinary()
 	local signer = jwt.new_signer(match.jwt_alg, key)
 	local payload = {}
 	for k, v in pairs(match.jwt_claims or {}) do
 		payload[k] = v
 	end
 	payload.sub = contact_uri
-	push_notification_payload:text_tag("jwt", signer(payload))
+	push_notification_payload:text_tag("jwt", signer(payload), { key = base64.encode(public_key) })
 end
 
 local function handle_notify_request(stanza, node, user_push_services, log_push_decline)
--- a/mod_push2/push2.markdown	Tue Sep 19 21:39:14 2023 -0500
+++ b/mod_push2/push2.markdown	Wed Sep 20 23:05:29 2023 -0500
@@ -105,7 +105,7 @@
         <encrypted xmlns="urn:xmpp:sce:rfc8291:0">
             <payload>Base64 encoded ciphertext</payload>
         </encrypted>
-        <jwt>the signed JWT, if present</jwt>
+        <jwt key="base64 encoded raw public key">the signed JWT, if present</jwt>
     </notification>
 </message>
 ```