mirror of
https://github.com/element-hq/synapse.git
synced 2026-11-04 15:37:49 +00:00
0f3e69f9c1ff08bb16cd53e92f195bd3061fdb69
MSC4430 identifies room members by a per-user, per-room Ed25519 "member key" rather than a user ID, and lets a member's `m.room.member` event carry the user ID it claims to be (`content.localpart`, `content.domain`), co-signed by the claimed domain's server signing key. This adds the two tables and the store behind that, with no callers: nothing in the server creates keys or learns links yet, and the member key room version cannot be used. `msc4430_member_keys` holds the keys we hold for our own users, one per (local user, room), with the private seed. `MemberKeysWorkerStore.create_local_member_key` is insert-if-absent and returns whichever key is stored, so a user's key in a room can never change once it exists, however many concurrent callers try (the earlier monolithic attempt raised `IntegrityError` here). The store derives the public form from the signing key it is given, so the two columns cannot disagree, and rejects any key ID other than `ed25519:1`. Every lookup by key takes the room the key was seen in: a key of ours from room A appearing in room B's events does not resolve there (the earlier attempt mapped keys without a room and gave users phantom memberships). Lookups are cached per (room, user), per (room, key), per user and per room, and `create_local_member_key` invalidates all four on the cache stream, so workers see new keys. `msc4430_member_links` holds what we have learned about keys we do not hold: the claimed domain (routing information, kept whether verified or not), the claimed localpart (NULL once the event that carried it is redacted, after which the key maps to no user), and whether the link is verified. A verified link always names the `m.room.member` event and the server signing key ID that proved it; the `MemberLink` type and a CHECK constraint both enforce this, so "verified" means exactly one thing. Our own keys get no link row: a link is a claim someone else made, and the keys we hold are already known to be ours. `upsert_member_link` is a plain replace that returns the previously stored link, so a caller can see what changed (the mapped user, the domain); which events may update a link is the caller's policy, not the store's, and `get_member_link_txn` plus `upsert_member_link_txn` let it read, decide and write in one transaction. `mark_links_unverified(domain, key_id)` downgrades every link a rotated or withdrawn server key vouched for, in one bulk cache invalidation, keeping the event and key ID so the links can be found again (`get_links_for_signing_key`) if the events are re-signed; a key ID alone does not identify a key, so re-checking a link means re-checking the co-signature on its event against the domain's current key material, which the schema says. `get_member_keys_for_domain_in_room(verified_only=...)` separates routing (claimed) from trust (verified), and answers for our own server name from the keys we hold, never from links: a link claiming our domain for a key we do not hold is somebody else's claim. `get_member_links_for_claimed_user` is the reverse mapping; it returns every claimant (verified first) rather than picking one, because an unverified claim is anyone's to make and that lookup is how a user ID in an invite, kick or power level change becomes a key. `clear_link_localpart_for_redacted_event_txn` is the erasure hook (it clears every link learned from the redacted event). Purging a room clears its links; the keys we hold deliberately survive a purge, since a user's key in a room must not change if the room is re-joined. The stored seed cannot be revoked (MSC4430 has no member key rotation; only rotating the server key helps), and the schema says so. The store is mixed into `RoomMemberWorkerStore` (so it is present on workers) rather than registered on `DataStore`, because the membership queries are the code that will need it. `LocalMemberKey` and `MemberLink` are frozen attrs types in `synapse/storage/member_keys.py`, next to the other storage return types; `SigningKey` is added to the mypy plugin's immutable types so a `LocalMemberKey` can be a cached value. `synapse_port_db` learns the boolean column. `MemberKeyHandler.is_local_identity` (and so `hs.is_mine_identity`) now answers for member keys by looking the key up in its room, instead of raising. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Reject
limit_profile_requests_to_users_who_share_rooms without require_auth_for_profile_requests (#20231)
add before and after filter to redact user method (/_synapse/admin/v1/user/$user_id/redact) (#19802)
This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
.. image:: https://github.com/element-hq/synapse/raw/develop/docs/element_logo_white_bg.svg :height: 60px **Element Synapse - Matrix homeserver implementation** |support| |development| |documentation| |license| |pypi| |python| Synapse is an open source `Matrix <https://matrix.org>`__ homeserver implementation, written and maintained by `Element <https://element.io>`_. `Matrix <https://github.com/matrix-org>`__ is the open standard for secure and interoperable real-time communications. You can directly run and manage the source code in this repository, available under an AGPL license (or alternatively under a commercial license from Element). There is no support provided by Element unless you have a subscription from Element. 🚀 Getting started ================== This component is developed and maintained by `Element <https://element.io>`_. It gets shipped as part of the **Element Server Suite (ESS)** which provides the official means of deployment. ESS is a Matrix distribution from Element with focus on quality and ease of use. It ships a full Matrix stack tailored to the respective use case. There are three editions of ESS: - `ESS Community <https://github.com/element-hq/ess-helm>`_ - the free Matrix distribution from Element tailored to small-/mid-scale, non-commercial community use cases - `ESS Pro <https://element.io/server-suite>`_ - the commercial Matrix distribution from Element for professional use - `ESS TI-M <https://element.io/server-suite/ti-messenger>`_ - a special version of ESS Pro focused on the requirements of TI-Messenger Pro and ePA as specified by the German National Digital Health Agency Gematik 🛠️ Standalone installation and configuration ============================================ The Synapse documentation describes `options for installing Synapse standalone <https://element-hq.github.io/synapse/latest/setup/installation.html>`_. See below for more useful documentation links. - `Synapse configuration options <https://element-hq.github.io/synapse/latest/usage/configuration/config_documentation.html>`_ - `Synapse configuration for federation <https://element-hq.github.io/synapse/latest/federate.html>`_ - `Using a reverse proxy with Synapse <https://element-hq.github.io/synapse/latest/reverse_proxy.html>`_ - `Upgrading Synapse <https://element-hq.github.io/synapse/develop/upgrade.html>`_ 🎯 Troubleshooting and support ============================== 🚀 Professional support ----------------------- Enterprise quality support for Synapse including SLAs is available as part of an `Element Server Suite (ESS) <https://element.io/pricing>`_ subscription. If you are an existing ESS subscriber then you can raise a `support request <https://customer.element.io/support>`_ and access the `Element product documentation <https://docs.element.io>`_. 🤝 Community support -------------------- The `Admin FAQ <https://element-hq.github.io/synapse/latest/usage/administration/admin_faq.html>`_ includes tips on dealing with some common problems. For more details, see `Synapse's wider documentation <https://element-hq.github.io/synapse/latest/>`_. For additional support installing or managing Synapse, please ask in the community support room |room|_ (from a matrix.org account if necessary). We do not use GitHub issues for support requests, only for bug reports and feature requests. .. |room| replace:: ``#synapse:matrix.org`` .. _room: https://matrix.to/#/#synapse:matrix.org .. |docs| replace:: ``docs`` .. _docs: docs 🛠️ Development ============== We welcome contributions to Synapse from the community! The best place to get started is our `guide for contributors <https://element-hq.github.io/synapse/latest/development/contributing_guide.html>`_. This is part of our broader `documentation <https://element-hq.github.io/synapse/latest>`_, which includes information for Synapse developers as well as Synapse administrators. Developers might be particularly interested in: * `Synapse's database schema <https://element-hq.github.io/synapse/latest/development/database_schema.html>`_, * `notes on Synapse's implementation details <https://element-hq.github.io/synapse/latest/development/internal_documentation/index.html>`_, and * `how we use git <https://element-hq.github.io/synapse/latest/development/git.html>`_. Alongside all that, join our developer community on Matrix: `#synapse-dev:matrix.org <https://matrix.to/#/#synapse-dev:matrix.org>`_, featuring real humans! Copyright and Licensing ======================= | Copyright 2014–2017 OpenMarket Ltd | Copyright 2017 Vector Creations Ltd | Copyright 2017–2025 New Vector Ltd | Copyright 2025 Element Creations Ltd This software is dual-licensed by Element Creations Ltd (Element). It can be used either: (1) for free under the terms of the GNU Affero General Public License (as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version); OR (2) under the terms of a paid-for Element Commercial License agreement between you and Element (the terms of which may vary depending on what you and Element have agreed to). Unless required by applicable law or agreed to in writing, software distributed under the Licenses is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the Licenses for the specific language governing permissions and limitations under the Licenses. Please contact `licensing@element.io <mailto:licensing@element.io>`_ to purchase an Element commercial license for this software. .. |support| image:: https://img.shields.io/badge/matrix-community%20support-success :alt: (get community support in #synapse:matrix.org) :target: https://matrix.to/#/#synapse:matrix.org .. |development| image:: https://img.shields.io/matrix/synapse-dev:matrix.org?label=development&logo=matrix :alt: (discuss development on #synapse-dev:matrix.org) :target: https://matrix.to/#/#synapse-dev:matrix.org .. |documentation| image:: https://img.shields.io/badge/documentation-%E2%9C%93-success :alt: (Rendered documentation on GitHub Pages) :target: https://element-hq.github.io/synapse/latest/ .. |license| image:: https://img.shields.io/github/license/element-hq/synapse :alt: (check license in LICENSE file) :target: LICENSE .. |pypi| image:: https://img.shields.io/pypi/v/matrix-synapse :alt: (latest version released on PyPi) :target: https://pypi.org/project/matrix-synapse .. |python| image:: https://img.shields.io/pypi/pyversions/matrix-synapse :alt: (supported python versions) :target: https://pypi.org/project/matrix-synapse
Languages
Python
95.2%
Rust
3.5%
HTML
0.4%
Shell
0.3%
Go
0.2%
Other
0.1%