Mercurial > prosody-modules
annotate mod_pubsub_post/README.md @ 6257:fa45ae704b79
mod_cloud_notify: Update Readme
diff --git a/mod_cloud_notify/README.md b/mod_cloud_notify/README.md
--- a/mod_cloud_notify/README.md
+++ b/mod_cloud_notify/README.md
@@ -1,109 +1,106 @@
----
-labels:
-- 'Stage-Beta'
-summary: 'XEP-0357: Cloud push notifications'
----
+# Introduction
-Introduction
-============
+This module enables support for sending "push notifications" to clients
+that need it, typically those running on certain mobile devices.
-This module enables support for sending "push notifications" to clients that
-need it, typically those running on certain mobile devices.
+As well as this module, your client must support push notifications (the
+apps that need it generally do, of course) and the app developer's push
+gateway must be reachable from your Prosody server (this happens over a
+normal XMPP server-to-server 's2s' connection).
-As well as this module, your client must support push notifications (the apps
-that need it generally do, of course) and the app developer's push gateway
-must be reachable from your Prosody server (this happens over a normal XMPP
-server-to-server 's2s' connection).
-
-Details
-=======
+# Details
Some platforms, notably Apple's iOS and many versions of Android, impose
-limits that prevent applications from running or accessing the network in the
-background. This makes it difficult or impossible for an XMPP application to
-remain reliably connected to a server to receive messages.
-
-In order for messaging and other apps to receive notifications, the OS vendors
-run proprietary servers that their OS maintains a permanent connection to in
-the background. Then they provide APIs to application developers that allow
-sending notifications to specific devices via those servers.
+limits that prevent applications from running or accessing the network
+in the background. This makes it difficult or impossible for an XMPP
+application to remain reliably connected to a server to receive
+messages.
-When you connect to your server with an app that requires push notifications,
-it will use this module to set up a "push registration". When you receive
-a message but your device is not connected to the server, this module will
-generate a notification and send it to the push gateway operated by your
-application's developers). Their gateway will then connect to your device's
-OS vendor and ask them to forward the notification to your device. When your
-device receives the notification, it will display it or wake up the app so it
-can connect to XMPP and receive any pending messages.
+In order for messaging and other apps to receive notifications, the OS
+vendors run proprietary servers that their OS maintains a permanent
+connection to in the background. Then they provide APIs to application
+developers that allow sending notifications to specific devices via
+those servers.
-This protocol is described for developers in [XEP-0357: Push Notifications].
+When you connect to your server with an app that requires push
+notifications, it will use this module to set up a "push registration".
+When you receive a message but your device is not connected to the
+server, this module will generate a notification and send it to the push
+gateway operated by your application's developers). Their gateway will
+then connect to your device's OS vendor and ask them to forward the
+notification to your device. When your device receives the notification,
+it will display it or wake up the app so it can connect to XMPP and
+receive any pending messages.
-For this module to work reliably, you must have [mod_smacks], [mod_mam] and
-[mod_carbons] also enabled on your server.
+This protocol is described for developers in \[XEP-0357: Push
+Notifications\].
+
+For this module to work reliably, you must have \[mod_smacks\],
+\[mod_mam\] and \[mod_carbons\] also enabled on your server.
-Some clients, notably Siskin and Snikket iOS need some additional extensions
-that are not currently defined in a standard XEP. To support these clients,
-see [mod_cloud_notify_extensions].
+Some clients, notably Siskin and Snikket iOS need some additional
+extensions that are not currently defined in a standard XEP. To support
+these clients, see \[mod_cloud_notify_extensions\].
-Configuration
-=============
+# Configuration
- Option Default Description
- ------------------------------------ ----------------- -------------------------------------------------------------------------------------------------------------------
- `push_notification_important_body` `New Message!` The body text to use when the stanza is important (see above), no message body is sent if this is empty
- `push_max_errors` `16` How much persistent push errors are tolerated before notifications for the identifier in question are disabled
- `push_max_devices` `5` The number of allowed devices per user (the oldest devices are automatically removed if this threshold is reached)
- `push_max_hibernation_timeout` `259200` (72h) Number of seconds to extend the smacks timeout if no push was triggered yet (default: 72 hours)
- `push_notification_with_body` (\*) `false` Whether or not to send the real message body to remote pubsub node. Without end-to-end encryption, enabling this may expose your message contents to your client developers and OS vendor. Not recommended.
- `push_notification_with_sender` (\*) `false` Whether or not to send the real message sender to remote pubsub node. Enabling this may expose your contacts to your client developers and OS vendor. Not recommended.
+ Option Default Description
+ -------------------------------------- ---------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ `push_notification_important_body` `New Message!` The body text to use when the stanza is important (see above), no message body is sent if this is empty
+ `push_max_errors` `16` How much persistent push errors are tolerated before notifications for the identifier in question are disabled
+ `push_max_devices` `5` The number of allowed devices per user (the oldest devices are automatically removed if this threshold is reached)
+ `push_max_hibernation_timeout` `259200` (72h) Number of seconds to extend the smacks timeout if no push was triggered yet (default: 72 hours)
+ `push_notification_with_body` (\*) `false` Whether or not to send the real message body to remote pubsub node. Without end-to-end encryption, enabling this may expose your message contents to your client developers and OS vendor. Not recommended.
+ `push_notification_with_sender` (\*) `false` Whether or not to send the real message sender to remote pubsub node. Enabling this may expose your contacts to your client developers and OS vendor. Not recommended.
-(\*) There are privacy implications for enabling these options.
+(\*) There are privacy implications for enabling these options.[^1]
-Internal design notes
-=====================
+# Internal design notes
-App servers are notified about offline messages, messages stored by [mod_mam]
-or messages waiting in the smacks queue.
-The business rules outlined [here](//mail.jabber.org/pipermail/standards/2016-February/030925.html) are all honored[^2].
+App servers are notified about offline messages, messages stored by
+\[mod_mam\] or messages waiting in the smacks queue. The business rules
+outlined
+[here](//mail.jabber.org/pipermail/standards/2016-February/030925.html)
+are all honored[^2].
-To cooperate with [mod_smacks] this module consumes some events:
-`smacks-ack-delayed`, `smacks-hibernation-start` and `smacks-hibernation-end`.
-These events allow this module to send out notifications for messages received
-while the session is hibernated by [mod_smacks] or even when smacks
-acknowledgements for messages are delayed by a certain amount of seconds
-configurable with the [mod_smacks] setting `smacks_max_ack_delay`.
+To cooperate with \[mod_smacks\] this module consumes some events:
+`smacks-ack-delayed`, `smacks-hibernation-start` and
+`smacks-hibernation-end`. These events allow this module to send out
+notifications for messages received while the session is hibernated by
+\[mod_smacks\] or even when smacks acknowledgements for messages are
+delayed by a certain amount of seconds configurable with the
+\[mod_smacks\] setting `smacks_max_ack_delay`.
-The `smacks_max_ack_delay` setting allows to send out notifications to clients
-which aren't already in smacks hibernation state (because the read timeout or
-connection close didn't already happen) but also aren't responding to acknowledgement
-request in a timely manner. This setting thus allows conversations to be smoother
-under such circumstances.
+The `smacks_max_ack_delay` setting allows to send out notifications to
+clients which aren't already in smacks hibernation state (because the
+read timeout or connection close didn't already happen) but also aren't
+responding to acknowledgement request in a timely manner. This setting
+thus allows conversations to be smoother under such circumstances.
-The new event `cloud-notify-ping` can be used by any module to send out a cloud
-notification to either all registered endpoints for the given user or only the endpoints
-given in the event data.
+The new event `cloud-notify-ping` can be used by any module to send out
+a cloud notification to either all registered endpoints for the given
+user or only the endpoints given in the event data.
-The config setting `push_notification_important_body` can be used to specify an alternative
-body text to send to the remote pubsub node if the stanza is encrypted or has a body.
-This way the real contents of the message aren't revealed to the push appserver but it
-can still see that the push is important.
-This is used by Chatsecure on iOS to send out high priority pushes in those cases for example.
+The config setting `push_notification_important_body` can be used to
+specify an alternative body text to send to the remote pubsub node if
+the stanza is encrypted or has a body. This way the real contents of the
+message aren't revealed to the push appserver but it can still see that
+the push is important. This is used by Chatsecure on iOS to send out
+high priority pushes in those cases for example.
-Compatibility
-=============
-
-**Note:** This module should be used with Lua 5.2 and higher. Using it with
-Lua 5.1 may cause push notifications to not be sent to some clients.
+# Compatibility
------- -----------------------------------------------------------------------------
- trunk Works
- 0.12 Works
- 0.11 Works
- 0.10 Works
- 0.9 Support dropped, use last supported version [675726ab06d3](//hg.prosody.im/prosody-modules/raw-file/675726ab06d3/mod_cloud_notify/mod_cloud_notify.lua)
------- -----------------------------------------------------------------------------
+**Note:** This module should be used with Lua 5.2 and higher. Using it
+with Lua 5.1 may cause push notifications to not be sent to some
+clients.
+ ------- -----------------------------------------------------------------
+ trunk Works as of 25-06-13
+ 13 Works
+ 0.12 Works
+ ------- -----------------------------------------------------------------
-[^1]: The service which is expected to forward notifications to something like Google Cloud Messaging or Apple Notification Service
-[^2]: [business_rules.markdown](//hg.prosody.im/prosody-modules/file/tip/mod_cloud_notify/business_rules.markdown)
+[^1]: The service which is expected to forward notifications to
+ something like Google Cloud Messaging or Apple Notification Service
+
+[^2]: [business_rules.md](//hg.prosody.im/prosody-modules/file/tip/mod_cloud_notify/business_rules.md)
| author | Menel <menel@snikket.de> |
|---|---|
| date | Fri, 13 Jun 2025 10:36:52 +0200 |
| parents | fe081789f7b5 |
| children |
| rev | line source |
|---|---|
|
3505
106b4ae4469b
mod_pubsub_post/README: Mention use as a webhook receiver
Kim Alvefur <zash@zash.se>
parents:
3503
diff
changeset
|
1 --- |
|
3506
7b1eede1a840
mod_pubsub_post/README: Set stage label to stable
Kim Alvefur <zash@zash.se>
parents:
3505
diff
changeset
|
2 labels: |
|
7b1eede1a840
mod_pubsub_post/README: Set stage label to stable
Kim Alvefur <zash@zash.se>
parents:
3505
diff
changeset
|
3 - 'Stage-Stable' |
|
3505
106b4ae4469b
mod_pubsub_post/README: Mention use as a webhook receiver
Kim Alvefur <zash@zash.se>
parents:
3503
diff
changeset
|
4 summary: Publish to PubSub nodes from via HTTP POST/WebHooks |
|
106b4ae4469b
mod_pubsub_post/README: Mention use as a webhook receiver
Kim Alvefur <zash@zash.se>
parents:
3503
diff
changeset
|
5 --- |
|
106b4ae4469b
mod_pubsub_post/README: Mention use as a webhook receiver
Kim Alvefur <zash@zash.se>
parents:
3503
diff
changeset
|
6 |
| 3100 | 7 # Introduction |
| 8 | |
|
3505
106b4ae4469b
mod_pubsub_post/README: Mention use as a webhook receiver
Kim Alvefur <zash@zash.se>
parents:
3503
diff
changeset
|
9 This module is a fairly generic WebHook receiver that lets you easily |
|
106b4ae4469b
mod_pubsub_post/README: Mention use as a webhook receiver
Kim Alvefur <zash@zash.se>
parents:
3503
diff
changeset
|
10 publish data to PubSub using a HTTP POST request. The payload can be |
|
106b4ae4469b
mod_pubsub_post/README: Mention use as a webhook receiver
Kim Alvefur <zash@zash.se>
parents:
3503
diff
changeset
|
11 Atom feeds, arbitrary XML, or arbitrary JSON. The type should be |
|
106b4ae4469b
mod_pubsub_post/README: Mention use as a webhook receiver
Kim Alvefur <zash@zash.se>
parents:
3503
diff
changeset
|
12 indicated via the `Content-Type` header. |
| 3100 | 13 |
|
3719
a6db99c1420a
mod_pubsub_post/README: Add an example of curl-ing Atom data
Kim Alvefur <zash@zash.se>
parents:
3506
diff
changeset
|
14 - JSON data is wrapped in a [XEP-0335] container. |
|
a6db99c1420a
mod_pubsub_post/README: Add an example of curl-ing Atom data
Kim Alvefur <zash@zash.se>
parents:
3506
diff
changeset
|
15 - An Atom feed may have many `<entry>` and each one is published as |
|
a6db99c1420a
mod_pubsub_post/README: Add an example of curl-ing Atom data
Kim Alvefur <zash@zash.se>
parents:
3506
diff
changeset
|
16 its own PubSub item. |
|
4636
6bcccc63b542
mod_pubsub_post: fix incorrect claim
Jonas Schäfer <jonas@wielicki.name>
parents:
4552
diff
changeset
|
17 - Other XML is simply published to the item with ID `current`. |
|
3719
a6db99c1420a
mod_pubsub_post/README: Add an example of curl-ing Atom data
Kim Alvefur <zash@zash.se>
parents:
3506
diff
changeset
|
18 |
|
a6db99c1420a
mod_pubsub_post/README: Add an example of curl-ing Atom data
Kim Alvefur <zash@zash.se>
parents:
3506
diff
changeset
|
19 ## JSON example |
|
a6db99c1420a
mod_pubsub_post/README: Add an example of curl-ing Atom data
Kim Alvefur <zash@zash.se>
parents:
3506
diff
changeset
|
20 |
| 3100 | 21 ``` {.bash} |
| 22 curl http://localhost:5280/pubsub_post/princely_musings \ | |
| 23 -H "Content-Type: application/json" \ | |
| 24 --data-binary '{"musing":"To be, or not to be: that is the question"}' | |
| 25 ``` | |
| 26 | |
|
3719
a6db99c1420a
mod_pubsub_post/README: Add an example of curl-ing Atom data
Kim Alvefur <zash@zash.se>
parents:
3506
diff
changeset
|
27 ## Atom example |
|
a6db99c1420a
mod_pubsub_post/README: Add an example of curl-ing Atom data
Kim Alvefur <zash@zash.se>
parents:
3506
diff
changeset
|
28 |
|
a6db99c1420a
mod_pubsub_post/README: Add an example of curl-ing Atom data
Kim Alvefur <zash@zash.se>
parents:
3506
diff
changeset
|
29 ``` {.bash} |
|
a6db99c1420a
mod_pubsub_post/README: Add an example of curl-ing Atom data
Kim Alvefur <zash@zash.se>
parents:
3506
diff
changeset
|
30 curl http://localhost:5280/pubsub_post/princely_musings \ |
|
a6db99c1420a
mod_pubsub_post/README: Add an example of curl-ing Atom data
Kim Alvefur <zash@zash.se>
parents:
3506
diff
changeset
|
31 -H "Content-Type: application/xml" \ |
|
a6db99c1420a
mod_pubsub_post/README: Add an example of curl-ing Atom data
Kim Alvefur <zash@zash.se>
parents:
3506
diff
changeset
|
32 --data-binary '<feed xmlns="http://www.w3.org/2005/Atom"> |
|
a6db99c1420a
mod_pubsub_post/README: Add an example of curl-ing Atom data
Kim Alvefur <zash@zash.se>
parents:
3506
diff
changeset
|
33 <entry><title>Hello</title></entry></feed>' |
|
4552
c87181a98f29
mod_pubsub_post: Add support for urlencoded form-data
Kim Alvefur <zash@zash.se>
parents:
3719
diff
changeset
|
34 ``` |
|
3719
a6db99c1420a
mod_pubsub_post/README: Add an example of curl-ing Atom data
Kim Alvefur <zash@zash.se>
parents:
3506
diff
changeset
|
35 |
|
4552
c87181a98f29
mod_pubsub_post: Add support for urlencoded form-data
Kim Alvefur <zash@zash.se>
parents:
3719
diff
changeset
|
36 ## Simple form-data |
|
c87181a98f29
mod_pubsub_post: Add support for urlencoded form-data
Kim Alvefur <zash@zash.se>
parents:
3719
diff
changeset
|
37 |
|
c87181a98f29
mod_pubsub_post: Add support for urlencoded form-data
Kim Alvefur <zash@zash.se>
parents:
3719
diff
changeset
|
38 ``` {.bash} |
|
c87181a98f29
mod_pubsub_post: Add support for urlencoded form-data
Kim Alvefur <zash@zash.se>
parents:
3719
diff
changeset
|
39 curl http://localhost:5280/pubsub_post/princely_musings \ |
|
c87181a98f29
mod_pubsub_post: Add support for urlencoded form-data
Kim Alvefur <zash@zash.se>
parents:
3719
diff
changeset
|
40 --data musing="To be, or not to be: that is the question" |
|
3719
a6db99c1420a
mod_pubsub_post/README: Add an example of curl-ing Atom data
Kim Alvefur <zash@zash.se>
parents:
3506
diff
changeset
|
41 ``` |
|
3153
e0de1fdbc80a
mod_pubsub_post/README: Describe what happens to different data types
Kim Alvefur <zash@zash.se>
parents:
3152
diff
changeset
|
42 |
| 3100 | 43 # Configuration |
| 44 | |
|
3503
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
45 All settings are optional. |
| 3100 | 46 |
|
3503
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
47 ## Actor identification |
| 3100 | 48 |
|
3503
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
49 First we have to figure out who is making the request. |
|
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
50 This is configured on a per-node basis like this: |
|
3501
1df139b157fb
mod_pubsub_post: Add support for WebSub authentication
Kim Alvefur <zash@zash.se>
parents:
3256
diff
changeset
|
51 |
|
1df139b157fb
mod_pubsub_post: Add support for WebSub authentication
Kim Alvefur <zash@zash.se>
parents:
3256
diff
changeset
|
52 ``` {.lua} |
|
1df139b157fb
mod_pubsub_post: Add support for WebSub authentication
Kim Alvefur <zash@zash.se>
parents:
3256
diff
changeset
|
53 -- Per node secrets |
|
3503
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
54 pubsub_post_actors = { |
|
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
55 princely_musings = "hamlet@denmark.lit" |
|
3501
1df139b157fb
mod_pubsub_post: Add support for WebSub authentication
Kim Alvefur <zash@zash.se>
parents:
3256
diff
changeset
|
56 } |
|
3503
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
57 pubsub_post_default_actor = "nobody@nowhere.invalid" |
|
3501
1df139b157fb
mod_pubsub_post: Add support for WebSub authentication
Kim Alvefur <zash@zash.se>
parents:
3256
diff
changeset
|
58 ``` |
|
1df139b157fb
mod_pubsub_post: Add support for WebSub authentication
Kim Alvefur <zash@zash.se>
parents:
3256
diff
changeset
|
59 |
|
3503
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
60 `pubsub_post_default_actor` is used when trying to publish to a node |
|
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
61 that is not listed in `pubsub_post_actors`. Otherwise the IP address |
|
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
62 of the connection is used. |
|
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
63 |
|
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
64 ## Authentication |
|
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
65 |
|
3501
1df139b157fb
mod_pubsub_post: Add support for WebSub authentication
Kim Alvefur <zash@zash.se>
parents:
3256
diff
changeset
|
66 [WebSub](https://www.w3.org/TR/2018/REC-websub-20180123/) [Authenticated |
|
1df139b157fb
mod_pubsub_post: Add support for WebSub authentication
Kim Alvefur <zash@zash.se>
parents:
3256
diff
changeset
|
67 Content |
|
1df139b157fb
mod_pubsub_post: Add support for WebSub authentication
Kim Alvefur <zash@zash.se>
parents:
3256
diff
changeset
|
68 Distribution](https://www.w3.org/TR/2018/REC-websub-20180123/#authenticated-content-distribution) |
|
3503
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
69 authentication is used. |
|
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
70 |
|
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
71 ``` {.lua} |
|
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
72 pubsub_post_secrets = { |
|
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
73 princely_musings = "shared secret" |
|
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
74 } |
|
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
75 pubsub_post_default_secret = "default secret" |
|
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
76 ``` |
|
3501
1df139b157fb
mod_pubsub_post: Add support for WebSub authentication
Kim Alvefur <zash@zash.se>
parents:
3256
diff
changeset
|
77 |
|
3503
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
78 `pubsub_post_default_secret` is used when trying to publish to a node |
|
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
79 that is not listed in `pubsub_post_secrets`. Otherwise the request |
|
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
80 proceeds with the previously identified actor. |
|
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
81 |
|
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
82 ::: {.alert .alert-danger} |
|
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
83 If configured without a secret and a default actor that has permission |
|
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
84 to create nodes the service becomes wide open. |
|
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
85 ::: |
|
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
86 |
|
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
87 ## Authorization |
|
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
88 |
|
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
89 Authorization is handled via pubsub affiliations. Publishing requires an |
|
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
90 affiliation with the _publish_ capability, usually `"publisher"`. |
|
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
91 |
|
882180b459a0
mod_pubsub_post: Restructure authentication and authorization (BC)
Kim Alvefur <zash@zash.se>
parents:
3502
diff
changeset
|
92 ### Setting up affiliations |
|
3256
0992c0398783
mod_pubsub_post/README: Add a heading for affiliation related text
Kim Alvefur <zash@zash.se>
parents:
3153
diff
changeset
|
93 |
|
3152
882f7d5c3ce8
mod_pubsub_post/README: Affiliation management in trunk now
Kim Alvefur <zash@zash.se>
parents:
3151
diff
changeset
|
94 Prosodys PubSub module supports [setting affiliations via |
|
4961
18774cc621d6
mod_pubsub_post/README: Update references to trunk with release numbers
Kim Alvefur <zash@zash.se>
parents:
4842
diff
changeset
|
95 XMPP](https://xmpp.org/extensions/xep-0060.html#owner-affiliations), |
|
18774cc621d6
mod_pubsub_post/README: Update references to trunk with release numbers
Kim Alvefur <zash@zash.se>
parents:
4842
diff
changeset
|
96 since 0.11.0, so affiliations can be configured with a capable client. |
| 3100 | 97 |
| 98 It can however be done from another plugin: | |
| 99 | |
| 100 ``` {.lua} | |
| 101 local mod_pubsub = module:depends("pubsub"); | |
| 102 local pubsub = mod_pubsub.service; | |
| 103 | |
| 104 pubsub:create("princely_musings", true); | |
| 105 pubsub:set_affiliation("princely_musings", true, "127.0.0.1", "publisher"); | |
| 106 ``` | |
|
4842
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
107 |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
108 ## Data mappings |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
109 |
|
4961
18774cc621d6
mod_pubsub_post/README: Update references to trunk with release numbers
Kim Alvefur <zash@zash.se>
parents:
4842
diff
changeset
|
110 The datamapper library added in 0.12.0 allows posting JSON and having it |
|
4842
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
111 converted to XML based on a special JSON Schema. |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
112 |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
113 ``` json |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
114 { |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
115 "properties" : { |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
116 "content" : { |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
117 "type" : "string" |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
118 }, |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
119 "title" : { |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
120 "type" : "string" |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
121 } |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
122 }, |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
123 "type" : "object", |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
124 "xml" : { |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
125 "name" : "musings", |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
126 "namespace" : "urn:example:princely" |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
127 } |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
128 } |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
129 ``` |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
130 |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
131 And in the Prosody config file: |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
132 |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
133 ``` lua |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
134 pubsub_post_mappings = { |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
135 princely_musings = "musings.json"; |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
136 } |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
137 ``` |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
138 |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
139 Then, POSTing a JSON payload like |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
140 |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
141 ``` json |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
142 { |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
143 "content" : "To be, or not to be: that is the question", |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
144 "title" : "Soliloquy" |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
145 } |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
146 ``` |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
147 |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
148 results in a payload like |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
149 |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
150 ``` xml |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
151 <musings xmlns="urn:example:princely"> |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
152 <title>Soliloquy</title> |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
153 <content>To be, or not to be: that is the question</content> |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
154 </musings> |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
155 ``` |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
156 |
|
8d4b91a703af
mod_pubsub_post: Document JSON to XML mapping capability
Kim Alvefur <zash@zash.se>
parents:
4636
diff
changeset
|
157 being published to the node. |
