Software / code / prosody-modules
File
mod_auth_token/README.md @ 6302:06fbbd45ba75
mod_cloud_notify: Readme: fix links and labels that were removed in the last commit
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,3 +1,9 @@
+----
+-labels:
+-- 'Stage-Beta'
+-summary: 'XEP-0357: Cloud push notifications'
+----
+
# Introduction
This module enables support for sending "push notifications" to clients
@@ -32,15 +38,15 @@ notification to your device. When your d
it will display it or wake up the app so it can connect to XMPP and
receive any pending messages.
-This protocol is described for developers in \[XEP-0357: Push
-Notifications\].
+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.
+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\].
+these clients, see [mod_cloud_notify_extensions].
# Configuration
@@ -58,18 +64,18 @@ these clients, see \[mod_cloud_notify_ex
# 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
+[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:
+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
+[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`.
+[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
| author | Menel <menel@snikket.de> |
|---|---|
| date | Fri, 13 Jun 2025 10:44:37 +0200 |
| parent | 6003:fe081789f7b5 |
line wrap: on
line source
# mod_auth_token This module enables Prosody to authenticate time-based one-time-pin (TOTP) HMAC tokens. This is an alternative to "external authentication" which avoids the need to make a blocking HTTP call to the external authentication service (usually a web application backend). Instead, the application generates the HMAC token, which is then sent to Prosody via the XMPP client and Prosody verifies the authenticity of this token. If the token is verified, then the user is authenticated. ## Luarocks dependencies You'll need to install the following luarocks otp 0.1-5 luatz 0.3-1 ## How to generate the TOTP seed and shared signing secret You'll need a shared OTP_SEED value for generating time-based one-time-pin (TOTP) values and a shared private key for signing the HMAC token. You can generate the OTP_SEED value with Python, like so: >>> import pyotp >>> pyotp.random_base32() u'XVGR73KMZH2M4XMY' and the shared secret key as follows: >>> import pyotp >>> pyotp.random_base32(length=32) u'JYXEX4IQOEYFYQ2S3MC5P4ZT4SDHYEA7' ## Configuration Firest you need to enable the relevant modules to your Prosody.cfg file. Look for the line `modules_enabled` (either globally or for your particular `VirtualHost`), and then add the following to tokens: modules_enabled = { -- Token authentication "auth_token"; "sasl_token"; } The previously generated token values also need to go into your Prosody.cfg file: authentication = "token"; token_secret = "JYXEX4IQOEYFYQ2S3MC5P4ZT4SDHYEA7"; otp_seed = "XVGR73KMZH2M4XMY"; The application that generates the tokens also needs access to these values. For an example on how to generate a token, take a look at the `generate_token` function in the `test_token_auth.lua` file inside this directory. ## Custom SASL auth This module depends on a custom SASL auth mechanism called X-TOKEN and which is provided by the file `mod_sasl_token.lua`. Prosody doesn't automatically pick up this file, so you'll need to update your configuration file's `plugin_paths` to link to this subdirectory (for example to `/usr/lib/prosody-modules/mod_auth_token/`). ## Generating the token Here's a Python snippet showing how you can generate the token that Prosody will then verify: import base64 import pyotp import random # Constants OTP_INTERVAL = 30 OTP_DIGITS = 8 jid = '{}@{}'.format(username, domain) otp_service = pyotp.TOTP( OTP_SEED, # OTP_SEED must be set to the value generated previously (see above) digits=OTP_DIGITS, interval=OTP_INTERVAL ) otp = otp_service.generate_otp(otp_service.timecode(datetime.utcnow())) nonce = ''.join([str(random.randint(0, 9)) for i in range(32)]) string_to_sign = otp + nonce + jid signature = hmac.new(token_secret, string_to_sign, hashlib.sha256).digest() token = u"{} {}".format(otp+nonce, base64.b64encode(signature))