Commit graph

5670 commits

Author SHA1 Message Date
Kim Alvefur
7976f21e3e mod_s2s: Deal with OpenSSL changing spelling in strings
ade08735f9
2025-04-01 18:15:34 +02:00
Matthew Wild
c914afdc49 mod_tls: Enable Prosody's certificate checking for incoming s2s connections (fixes #1916) (thanks Damian, Zash)
Various options in Prosody allow control over the behaviour of the certificate
verification process For example, some deployments choose to allow falling
back to traditional "dialback" authentication (XEP-0220), while others verify
via DANE, hard-coded fingerprints, or other custom plugins.

Implementing this flexibility requires us to override OpenSSL's default
certificate verification, to allow Prosody to verify the certificate itself,
apply custom policies and make decisions based on the outcome.

To enable our custom logic, we have to suppress OpenSSL's default behaviour of
aborting the connection with a TLS alert message. With LuaSec, this can be
achieved by using the verifyext "lsec_continue" flag.

We also need to use the lsec_ignore_purpose flag, because XMPP s2s uses server
certificates as "client" certificates (for mutual TLS verification in outgoing
s2s connections).

Commit 99d2100d2918 moved these settings out of the defaults and into mod_s2s,
because we only really need these changes for s2s, and they should be opt-in,
rather than automatically applied to all TLS services we offer.

That commit was incomplete, because it only added the flags for incoming
direct TLS connections. StartTLS connections are handled by mod_tls, which was
not applying the lsec_* flags. It previously worked because they were already
in the defaults.

This resulted in incoming s2s connections with "invalid" certificates being
aborted early by OpenSSL, even if settings such as `s2s_secure_auth = false`
or DANE were present in the config.

Outgoing s2s connections inherit verify "none" from the defaults, which means
OpenSSL will receive the cert but will not terminate the connection when it is
deemed invalid. This means we don't need lsec_continue there, and we also
don't need lsec_ignore_purpose (because the remote peer is a "server").

Wondering why we can't just use verify "none" for incoming s2s? It's because
in that mode, OpenSSL won't request a certificate from the peer for incoming
connections. Setting verify "peer" is how you ask OpenSSL to request a
certificate from the client, but also what triggers its built-in verification.
2025-04-01 17:26:56 +01:00
Kim Alvefur
f0c6467af8 mod_roster: Fix shell commands when a component is involved (fixes #1908)
Prevent attempt to load rosters on Components since they do not have
users or rosters.
2025-03-31 21:19:14 +02:00
Matthew Wild
f0042849ba mod_admin_shell, prosodyctl shell: Report command failure when no password entered (fixes #1907) 2025-03-31 17:30:50 +01:00
Kim Alvefur
be51e54c68 doap: Add XEP-0333 2025-03-23 19:59:45 +01:00
Kim Alvefur
780b392d25 doap: Add XEP-0334 2025-03-23 19:57:06 +01:00
Kim Alvefur
faed304d55 mod_http_file_share: Explicitly reject all unsupported ranges
Fail fast. Otherwise it sends the whole file.
2025-03-23 12:36:47 +01:00
Kim Alvefur
afd99708d6 mod_http_file_share: Fix off by one in Range response
See #1914
2025-03-23 12:21:19 +01:00
Kim Alvefur
b9d4cc24df mod_storage_sql: Drop legacy index without confirmation to ease upgrades
Deleting one index should be safe enough to do without requiring a
explicitly upgrading during downtime. People had trouble with this.
2025-03-23 12:15:16 +01:00
Kim Alvefur
eacf72504c mod_storage_sql: Fix indentation
Off-by-one in autoindent after `if not success then` since 3ec48555b773
2025-03-19 16:13:32 +01:00
Kim Alvefur
780fd208bc mod_http_file_share: Improve error reporting by using util.error more
This should pass back the error message as well as the status code to
the client.
2025-03-16 15:20:45 +01:00
Matthew Wild
57d168dd5e prosodyctl shell: More reliable detection of REPL/interactive mode (fixes #1895) 2025-03-13 11:37:11 +00:00
Matthew Wild
384e3dbea2 mod_admin_shell: Remove outdated help text (fixes #1898)
The ! commands have been broken for some time, and we're not going to
implement them right now. If we want fancier editing, we can now do that on
the client side (with readline and stuff).

Also removes mention of telnet!
2025-03-13 11:35:39 +00:00
Matthew Wild
8005ac825f mod_websocket: Merge session close handling changes from mod_c2s (bug fixes)
This should bring some fixes and general robustness that mod_websocket had
missed out on. The duplicated code here is not at all ideal. To prevent this
happening again, we should figure out how to have the common logic in a single
place, while still being able to do the websocket-specific parts that we need.

The main known bug that this fixes is that it's possible for a session to get
into a non-destroyable state. For example, if we try to session:close() a
hibernating session, then session.conn is nil and the function will simply
return without doing anything. In the mod_c2s code we already handle this, and
just destroy the session. But if a hibernating websocket session is never
resumed or becomes non-resumable, it will become immortal!

By merging the fix from mod_c2s, the session should now be correctly
destroyed.
2025-03-11 18:44:40 +00:00
Matthew Wild
5b4624137d mod_c2s: Code formatting change
Although we do sometimes use single-line if blocks, I'm expanding this one to
make it easier to compare with the duplicated (but modified) code in
mod_websocket that we plan to de-duplicate one day.
2025-03-11 18:37:16 +00:00
Matthew Wild
afb9bc34a0 mod_storage_internal: Use UUIDv7 for message ids
This matches what we use for SQL already, so provides some consistency.

Client developers prefer sortable ids.
2025-03-10 11:54:52 +00:00
Matthew Wild
830f3e122c mod_external_services: Also use TURN REST credential algo for 'turns' (thanks moreroid) 2025-03-01 16:19:43 +00:00
Kim Alvefur
e52cc0126d mod_component: Don't return error reply for errors, fixes #1897 2025-02-22 21:48:07 +01:00
Kim Alvefur
68296b6a8e mod_bosh,mod_websocket: Don't load mod_http_altconnect in global context
It blocked loading on VirtualHosts since it was already loaded globally

Thanks eTaurus
2025-02-22 21:45:34 +01:00
Matthew Wild
13dc010593 mod_invites: Hide --group flag unless mod_invites_groups is enabled
The WIP groups support is not complete yet, and won't work without extra
modules (which are not yet a part of Prosody). For now we hide --group support
unless mod_invites_groups (community module) is specified in modules_enabled.
2025-02-17 23:06:06 +00:00
Matthew Wild
edc68f5407 mod_invites: Fix traceback when no flags passed 2025-02-17 22:57:58 +00:00
Matthew Wild
764c388d38 mod_invites: Deprecate 'mod_invites generate' in favour of new shell commands 2025-02-17 19:12:40 +00:00
Matthew Wild
6855f5c8c3 mod_admin_shell: Improve help listing in non-REPL mode 2025-02-17 19:10:48 +00:00
Matthew Wild
75b8824b00 mod_admin_shell: Fix simple command execution (e.g. help) 2025-02-17 19:10:26 +00:00
Matthew Wild
efc31d66ef mod_admin_shell: Set flag on session when in REPL mode 2025-02-17 19:09:11 +00:00
Matthew Wild
c8cf32b614 mod_admin_shell: Improved error handling for shell-invoked commands 2025-02-17 18:25:52 +00:00
Matthew Wild
79381510cf mod_admin_shell, util.prosodyctl.shell: Process command-line args on server-side, with argparse support
This allow a shell-command to provide a 'flags' field, which will automatically
cause the parameters to be fed through argparse.

The rationale is to make it easier for more complex commands to be invoked
from the command line (`prosodyctl shell foo bar ...`). Until now they were
limited to accepting a list of strings, and any complex argument processing
was non-standard and awkward to implement.
2025-02-17 17:02:35 +00:00
Kim Alvefur
f21ea48481 mod_invites: Fix storing --group (thanks lissine)
This made it ignore `--group` completely, but if you incorrectly used
`--group foo` it would store `groups=true`.

Introduced in 9ba11ef91ce4
2025-02-17 00:55:27 +01:00
Matthew Wild
573e9f2716 mod_bosh, mod_websocket: Add soft dependency on mod_http_altconnect 2025-02-16 13:32:59 +00:00
Matthew Wild
83e4560a6c mod_http_altconnect: Imported from prosody-modules 6d5a19bdd718 w/changes
Changes from community version:

  - Add options to allow explicit control over whether BOSH/WS is advertised
  - Always serve XML at /host-meta (no guessing based on Accept), least surprising
2025-02-16 13:19:05 +00:00
Matthew Wild
9bae17a0bb mod_http_file_share: Persist total storage usage when it increases (fixes #1891) 2025-02-15 17:10:30 +00:00
Kim Alvefur
346f58c9d9 core.certmanager: Move LuaSec verification tweaks to mod_s2s
These two settings are only really needed for XMPP server-to-server
connections.
2025-02-15 00:19:01 +01:00
Matthew Wild
f5f2755b63 mod_cloud_notify, mod_cron, mod_invites: Add 'prosody.' prefix to requires 2025-02-15 10:31:37 +00:00
Matthew Wild
d71473df3b MUC: Use new XEP namespace for hats by default
Revert with muc_hats_compat = true in the config if necessary.
2025-02-14 13:08:45 +00:00
Matthew Wild
df63482b96 mod_admin_shell: Remove duplicated line 2025-02-13 17:05:36 +00:00
Matthew Wild
56dc05885e mod_admin_shell: Rename user:setrole to user:set_roles
This is more readable and accessible, and it will only be harder to change
after release.
2025-02-13 16:20:42 +00:00
Matthew Wild
f8a9943d17 mod_admin_shell: Hide secondary role commands, focus on primary roles
Secondary roles are an advanced feature without any strong use cases
currently. Having multiple ways to manage roles is confusing.

Now the 'user:role' command will just show the primary role if that is all
there is, but will list secondary roles too if there are any (which in 99.9%
of cases there won't be).
2025-02-13 16:18:59 +00:00
Matthew Wild
009996c9e8 mod_admin_shell: Support for hiding certain commands from default help listing
Useful for e.g. deprecated commands.
2025-02-13 16:16:19 +00:00
Matthew Wild
4cc122bdc0 mod_account_activity: Fix error when no duration specified in shell command 2025-02-13 16:15:16 +00:00
Matthew Wild
b07c1436e7 mod_admin_shell: Fix result handling of user addrole/delrole commands 2025-02-13 15:54:39 +00:00
Matthew Wild
d384d98c11 mod_authz_internal: Fix error messages 2025-02-13 15:31:14 +00:00
Matthew Wild
dc810fea2d mod_authz_internal: Fix return values of secondary role management methods
usermanager expects (role, err) and (ok, err)
2025-02-13 15:30:23 +00:00
Matthew Wild
3cdaf29bf8 mod_presence: Fix traceback if origin gets disconnected during processing
Fixes #1887
2025-02-13 14:00:08 +00:00
Matthew Wild
91e846ee71 mod_invites: Add shell commands to list, show and delete pending invitations 2025-02-13 13:04:37 +00:00
Matthew Wild
94385af697 mod_invites: Shell command to create reset links 2025-02-13 12:21:16 +00:00
Matthew Wild
85b82fdb3d mod_account_activity: Add shell command to list inactive accounts
Including accounts which may never have logged in.
2025-02-12 17:15:29 +00:00
Matthew Wild
6b6707efe5 mod_account_activity: Fix required module names 2025-02-12 17:15:00 +00:00
Matthew Wild
54b77fd3ca mod_account_activity: Record an account's last activity timestamp
This is similar to mod_lastlog/mod_lastlog2.

Some functionality was dropped, compared to mod_lastlog2. These features
(recording the IP address, or tracking the timestamp of multiple events) are
handled better by the mod_audit family of modules. For example, those
correctly handle multiple logins, IP address truncation, and data retention
policies.

The "registered" timestamp from mod_lastlog2 was also dropped, as this has
been stored in account_details by Prosody itself since at least 0.12 already.
2025-02-12 12:33:45 +00:00
Kim Alvefur
c1655a181f mod_storage_sql: Fix tests for SQLite3
Tests does not run the code that initializes `sqlite_version`
2025-02-08 12:55:40 +01:00
Matthew Wild
d6f8c4fe18 MUC: Don't inform people about the avatar hash when there is none 2025-02-07 10:19:36 +00:00