summary refs log tree commit diff
path: root/tests (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Merge commit '23d701864' into anoa/dinsic_release_1_31_0Andrew Morgan2021-04-218-36/+259
|\
| * Improve the performance of calculating ignored users in large rooms (#9024)Patrick Cloke2021-01-071-0/+120
| | | | | | | | | | | | This allows for efficiently finding which users ignore a particular user. Co-authored-by: Erik Johnston <erik@matrix.org>
| * Skip unit tests which require optional dependencies (#9031)Richard van der Hoff2021-01-076-13/+89
| | | | | | If we are lacking an optional dependency, skip the tests that rely on it.
| * Empty iterables should count towards cache usage. (#9028)Patrick Cloke2021-01-061-23/+50
| |
* | Merge commit '0312266ee' into anoa/dinsic_release_1_31_0Andrew Morgan2021-04-212-22/+165
|\|
| * Implement MSC2176: Updated redaction rules (#8984)Patrick Cloke2021-01-051-21/+164
| | | | | | | | An experimental room version ("org.matrix.msc2176") contains the new redaction rules for testing.
| * Combine the SSO Redirect Servlets (#9015)Richard van der Hoff2021-01-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Implement CasHandler.handle_redirect_request ... to make it match OidcHandler and SamlHandler * Clean up interface for OidcHandler.handle_redirect_request Make it accept `client_redirect_url=None`. * Clean up interface for `SamlHandler.handle_redirect_request` ... bring it into line with CAS and OIDC by making it take a Request parameter, move the magic for `client_redirect_url` for UIA into the handler, and fix the return type to be a `str` rather than a `bytes`. * Define a common protocol for SSO auth provider impls * Give SsoIdentityProvider an ID and register them * Combine the SSO Redirect servlets Now that the SsoHandler knows about the identity providers, we can combine the various *RedirectServlets into a single implementation which delegates to the right IdP. * changelog
* | Merge commit '1c9a85056' into anoa/dinsic_release_1_31_0Andrew Morgan2021-04-214-26/+144
|\|
| * Add type hints to the crypto module. (#8999)Patrick Cloke2021-01-041-5/+5
| |
| * Use the SSO handler helpers for CAS registration/login. (#8856)Patrick Cloke2021-01-031-0/+121
| |
| * Fix RoomDirectoryFederationTests and make them actually run (#8998)Andrew Morgan2020-12-302-21/+18
| | | | | | | | | | | | | | | | | | | | The `RoomDirectoryFederationTests` tests were not being run unless explicitly called as an `__init__.py` file was not present in `tests/federation/transport/`. Thus the folder was not a python module, and `trial` did not look inside for any test cases to run. This was found while working on #6739. This PR adds a `__init__.py` and also fixes the test in a couple ways: - Switch to subclassing `unittest.FederatingHomeserverTestCase` instead, which sets up federation endpoints for us. - Supply a `federation_auth_origin` to `make_request` in order to more act like the request is coming from another server, instead of just an unauthenicated client requesting a federation endpoint. I found that the second point makes no difference to the test passing, but felt like the right thing to do if we're testing over federation.
* | Merge commit '9999eb2d0' into anoa/dinsic_release_1_31_0Andrew Morgan2021-04-211-1/+0
|\|
| * Drop the unused local_invites table. (#8979)Patrick Cloke2020-12-291-1/+0
| | | | | | This table has been unused since Synapse v1.17.0.
| * Support PyJWT v2.0.0. (#8986)Patrick Cloke2020-12-221-4/+12
| | | | | | | | Tests were broken due to an API changing. The code used in Synapse proper should be compatible with both versions already.
* | Merge commit '4218473f9' into anoa/dinsic_release_1_31_0Andrew Morgan2021-04-212-1/+194
|\|
| * Allow server admin to get admin bit in rooms where local user is an admin ↵Erik Johnston2020-12-181-0/+138
| | | | | | | | | | | | | | (#8756) This adds an admin API that allows a server admin to get power in a room if a local user has power in a room. Will also invite the user if they're not in the room and its a private room. Can specify another user (rather than the admin user) to be granted power. Co-authored-by: Matthew Hodgson <matthew@matrix.org>
| * Fix mainline ordering in state res v2 (#8971)Erik Johnston2020-12-181-1/+56
| | | | | | | | | | | | This had two effects 1) it'd give the wrong answer and b) would iterate *all* power levels in the auth chain of each event. The latter of which can be *very* expensive for certain types of IRC bridge rooms that have large numbers of power level changes.
* | Merge commit '28877fade' into anoa/dinsic_release_1_31_0Andrew Morgan2021-04-213-33/+212
|\|
| * Implement a username picker for synapse (#8942)Richard van der Hoff2020-12-182-2/+149
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The final part (for now) of my work to implement a username picker in synapse itself. The idea is that we allow `UsernameMappingProvider`s to return `localpart=None`, in which case, rather than redirecting the browser back to the client, we redirect to a username-picker resource, which allows the user to enter a username. We *then* complete the SSO flow (including doing the client permission checks). The static resources for the username picker itself (in https://github.com/matrix-org/synapse/tree/rav/username_picker/synapse/res/username_picker) are essentially lifted wholesale from https://github.com/matrix-org/matrix-synapse-saml-mozilla/tree/master/matrix_synapse_saml_mozilla/res. As the comment says, we might want to think about making them customisable, but that can be a follow-up. Fixes #8876.
| * Allow re-using a UI auth validation for a period of time (#8970)Patrick Cloke2020-12-181-31/+63
| |
* | Merge commit 'a7a913918' into anoa/dinsic_release_1_31_0Andrew Morgan2021-04-202-2/+378
|\|
| * Merge remote-tracking branch 'origin/erikj/as_mau_block' into developErik Johnston2020-12-181-2/+44
| |\
| | * Update tests/test_mau.pyErik Johnston2020-12-171-1/+2
| | | | | | | | | Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
| | * Correctly handle AS registerations and add testErik Johnston2020-12-171-2/+43
| | |
| * | Try and drop stale extremities. (#8929)Erik Johnston2020-12-181-0/+334
| | | | | | | | | | | | If we see stale extremities while persisting events, and notice that they don't change the result of state resolution, we drop them.
* | | Merge commit 'c9c1c9d82' into anoa/dinsic_release_1_31_0Andrew Morgan2021-04-205-5/+221
|\| |
| * | Fix `UsersListTestCase` (#8964)Richard van der Hoff2020-12-171-6/+4
| | |
| * | Use the simple dictionary in full text search for the user directory (#8959)Brendan Abolivier2020-12-171-0/+23
| | | | | | | | | | | | | | | * Use the simple dictionary in fts for the user directory * Clarify naming
| * | Fix a bug that deactivated users appear in the directory (#8933)Dirk Klimpel2020-12-172-2/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes a bug that deactivated users appear in the directory when their profile information was updated. To change profile information of deactivated users is neccesary for example you will remove displayname or avatar. But they should not appear in directory. They are deactivated. Co-authored-by: Erik Johnston <erikj@jki.re>
| * | Make search statement in List Room and User Admin API case-insensitive (#8931)Dirk Klimpel2020-12-173-3/+112
| | |
* | | Merge commit 'ff5c4da12' into anoa/dinsic_release_1_31_0Andrew Morgan2021-04-202-4/+31
|\| |
| * | Add a maximum size for well-known lookups. (#8950)Patrick Cloke2020-12-161-0/+27
| | |
| * | Push login completion down into SsoHandler (#8941)Richard van der Hoff2020-12-161-4/+4
| | | | | | | | | This is another part of my work towards fixing #8876. It moves some of the logic currently in the SAML and OIDC handlers - in particular the call to `AuthHandler.complete_sso_login` down into the `SsoHandler`.
* | | Fix old-style uses of self.make_request in dinum test codeAndrew Morgan2021-04-168-73/+43
| | |
* | | Merge commit 'bd30cfe86' into anoa/dinsic_release_1_31_0Andrew Morgan2021-04-1660-1036/+783
|\| |
| * | Convert internal pusher dicts to attrs classes. (#8940)Patrick Cloke2020-12-163-9/+9
| | | | | | | | | This improves type hinting and should use less memory.
| * | Merge pull request #8951 from matrix-org/rav/username_picker_2Richard van der Hoff2020-12-162-82/+105
| |\ \ | | | | | | | | More preparatory refactoring of the OidcHandler tests
| * | | lintRichard van der Hoff2020-12-155-7/+3
| | | |
| * | | Remove spurious "SynapseRequest" result from `make_request"Richard van der Hoff2020-12-1559-983/+742
| | | | | | | | | | | | | | | | This was never used, so let's get rid of it.
| * | | Remove redundant reading of SynapseRequest.argsRichard van der Hoff2020-12-151-9/+1
| | | | | | | | | | | | | | | | this didn't seem to be doing a lot, so remove it.
| * | | Skip redundant check on `request.args`Richard van der Hoff2020-12-151-2/+1
| | | |
| * | | remove 'response' result from `_get_shared_rooms`Richard van der Hoff2020-12-151-8/+9
| | | |
| * | | Replace `request.code` with `channel.code`Richard van der Hoff2020-12-158-22/+22
| | | | | | | | | | | | | | | | | | | | | | | | The two are equivalent, but really we want to check the HTTP result that got returned to the channel, not the code that the Request object *intended* to return to the channel.
* | | | Merge commit '8388a7fb3' into anoa/dinsic_release_1_31_0Andrew Morgan2021-04-162-82/+105
|\ \ \ \ | | |/ / | |/| |
| * | | Make `_make_callback_with_userinfo` asyncRichard van der Hoff2020-12-151-68/+83
| | | | | | | | | | | | | | | | | | | | | | | | ... so that we can test its behaviour when it raises. Also pull it out to the top level so that I can use it from other test classes.
| * | | Remove spurious mocking of complete_sso_loginRichard van der Hoff2020-12-151-2/+0
| | | | | | | | | | | | | | | | The tests that need this all do it already.
| * | | Test `get_extra_attributes` fallbackRichard van der Hoff2020-12-152-12/+22
| |/ / | | | | | | | | | | | | despite the warnings saying "don't implement get_extra_attributes", we had implemented it, so the tests weren't doing what we thought they were.
* | | Merge commit '01333681b' into anoa/dinsic_release_1_31_0Andrew Morgan2021-04-168-204/+276
|\| |
| * | Preparatory refactoring of the SamlHandlerTestCase (#8938)Richard van der Hoff2020-12-153-54/+102
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * move simple_async_mock to test_utils ... so that it can be re-used * Remove references to `SamlHandler._map_saml_response_to_user` from tests This method is going away, so we can no longer use it as a test point. Instead, factor out a higher-level method which takes a SAML object, and verify correct behaviour by mocking out `AuthHandler.complete_sso_login`. * changelog
| * | Fix startup failure with localdb_enabled: False (#8937)Richard van der Hoff2020-12-141-0/+23
| | |
| * | Various clean-ups to the logging context code (#8935)Patrick Cloke2020-12-144-10/+7
| | |
| * | Preparatory refactoring of the OidcHandlerTestCase (#8911)Richard van der Hoff2020-12-141-141/+145
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Remove references to handler._auth_handler (and replace them with hs.get_auth_handler) * Factor out a utility function for building Requests * Remove mocks of `OidcHandler._map_userinfo_to_user` This method is going away, so mocking it out is no longer a valid approach. Instead, we mock out lower-level methods (eg _remote_id_from_userinfo), or simply allow the regular implementation to proceed and update the expectations accordingly. * Remove references to `OidcHandler._map_userinfo_to_user` from tests This method is going away, so we can no longer use it as a test point. Instead we build mock "callback" requests which we pass into `handle_oidc_callback`, and verify correct behaviour by mocking out `AuthHandler.complete_sso_login`.
* | | lintAndrew Morgan2021-04-161-1/+3
| | |
* | | Merge commit 'f14428b25' into anoa/dinsic_release_1_31_0Andrew Morgan2021-04-165-29/+124
|\| |
| * | Allow spam-checker modules to be provide async methods. (#8890)David Teller2020-12-111-2/+2
| | | | | | | | | | | | Spam checker modules can now provide async methods. This is implemented in a backwards-compatible manner.
| * | Improve tests for structured logging. (#8916)Patrick Cloke2020-12-111-27/+46
| | |
| * | Add number of local devices to Room Details Admin API (#8886)Dirk Klimpel2020-12-112-0/+60
| | |
| * | Don't ratelimit autojoining of rooms (#8921)Erik Johnston2020-12-111-0/+16
| | | | | | | | | Fixes #8866
* | | Merge commit 'c64002e1c' into anoa/dinsic_release_1_31_0Andrew Morgan2021-04-161-1/+1
|\| |
| * | Default to blacklisting reserved IP ranges and add a whitelist. (#8870)Patrick Cloke2020-12-091-1/+1
| | | | | | | | | | | | This defaults `ip_range_blacklist` to reserved IP ranges and also adds an `ip_range_whitelist` setting to override it.
* | | Merge commit '6ff34e00d' into anoa/dinsic_release_1_31_0Andrew Morgan2021-04-161-0/+23
|\| |
| * | Skip the SAML tests if xmlsec1 isn't available. (#8905)Patrick Cloke2020-12-091-0/+23
| | |
* | | Merge commit 'cf7d3c90d' into dinsicAndrew Morgan2021-04-1625-281/+679
|\| |
| * | Add X-Robots-Tag header to stop crawlers from indexing media (#8887)Aaron Raimist2020-12-081-0/+13
| | | | | | | | | | | | | | | | | | | | | Fixes / related to: https://github.com/matrix-org/synapse/issues/6533 This should do essentially the same thing as a robots.txt file telling robots to not index the media repo. https://developers.google.com/search/reference/robots_meta_tag Signed-off-by: Aaron Raimist <aaron@raim.ist>
| * | Call set_avatar_url with target_user, not user_id (#8872)Will Hunt2020-12-071-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Call set_avatar_url with target_user, not user_id Fixes https://github.com/matrix-org/synapse/issues/8871 * Create 8872.bugfix * Update synapse/rest/admin/users.py Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com> * Testing * Update changelog.d/8872.bugfix Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com> Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
| * | Do not raise a 500 exception when previewing empty media. (#8883)Patrick Cloke2020-12-071-11/+16
| | |
| * | Add authentication to replication endpoints. (#8853)Patrick Cloke2020-12-042-8/+120
| | | | | | | | | | | | Authentication is done by checking a shared secret provided in the Synapse configuration file.
| * | Pass room_id to get_auth_chain_difference (#8879)Erik Johnston2020-12-042-12/+20
| | | | | | | | | | | | | | | This is so that we can choose which algorithm to use based on the room ID.
| * | Add additional validation to pusher URLs. (#8865)Patrick Cloke2020-12-043-27/+89
| | | | | | | | | | | | Pusher URLs now must end in `/_matrix/push/v1/notify` per the specification.
| * | Merge tag 'v1.24.0rc2' into developPatrick Cloke2020-12-042-2/+29
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Synapse 1.24.0rc2 (2020-12-04) ============================== Bugfixes -------- - Fix a regression in v1.24.0rc1 which failed to allow SAML mapping providers which were unable to redirect users to an additional page. ([\#8878](https://github.com/matrix-org/synapse/issues/8878)) Internal Changes ---------------- - Add support for the `prometheus_client` newer than 0.9.0. Contributed by Jordan Bancino. ([\#8875](https://github.com/matrix-org/synapse/issues/8875))
| * | Fix errorcode for disabled registration (#8867)Richard van der Hoff2020-12-031-0/+1
| | | | | | | | | | | | The spec says we should return `M_FORBIDDEN` when someone tries to register and registration is disabled.
| * | Merge remote-tracking branch 'origin/develop' into rav/remove_unused_mocksRichard van der Hoff2020-12-029-95/+279
| |\ \
| | * \ Merge pull request #8858 from matrix-org/rav/sso_uiaRichard van der Hoff2020-12-028-57/+279
| | |\ \ | | | | | | | | | | UIA: offer only available auth flows
| | | * | UIA: offer only available auth flowsRichard van der Hoff2020-12-023-18/+193
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During user-interactive auth, do not offer password auth to users with no password, nor SSO auth to users with no SSO. Fixes #7559.
| | | * | Factor out FakeResponse from test_oidcRichard van der Hoff2020-12-022-16/+28
| | | | |
| | | * | fix up various test casesRichard van der Hoff2020-12-024-16/+37
| | | | | | | | | | | | | | | | | | | | | | | | | A few test cases were relying on being able to mount non-client servlets on the test resource. it's better to give them their own Resources.
| | | * | Add `create_resource_dict` method to HomeserverTestCaseRichard van der Hoff2020-12-021-7/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rather than using a single JsonResource, construct a resource tree, as we do in the prod code, and allow testcases to add extra resources by overriding `create_resource_dict`.
| | * | | remove unused FakeResponse (#8864)Richard van der Hoff2020-12-021-26/+0
| | | | |
| * | | | remove unused DeferredMockCallableRichard van der Hoff2020-12-021-90/+1
| | | | |
| * | | | remove unused `resource_for_federation`Richard van der Hoff2020-12-022-18/+13
| | | | | | | | | | | | | | | | | | | | This is now only used in `test_typing`, so move it there.
| * | | | Remove redundant mockingRichard van der Hoff2020-12-025-36/+5
| |/ / /
| * | | Apply an IP range blacklist to push and key revocation requests. (#8821)Patrick Cloke2020-12-0228-40/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replaces the `federation_ip_range_blacklist` configuration setting with an `ip_range_blacklist` setting with wider scope. It now applies to: * Federation * Identity servers * Push notifications * Checking key validitity for third-party invite events The old `federation_ip_range_blacklist` setting is still honored if present, but with reduced scope (it only applies to federation and identity servers).
| * | | Correctly handle unpersisted events when calculating auth chain difference. ↵Erik Johnston2020-12-022-1/+132
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | (#8827) We do state res with unpersisted events when calculating the new current state of the room, so that should be the only thing impacted. I don't think this is tooooo big of a deal as: 1. the next time a state event happens in the room the current state should correct itself; 2. in the common case all the unpersisted events' auth events will be pulled in by other state, so will still return the correct result (or one which is sufficiently close to not affect the result); and 3. we mostly use the state at an event to do important operations, which isn't affected by this.
* | | Port "Allow providing credentials to HTTPS_PROXY (#9657)" from mainline (#95)Andrew Morgan2021-03-231-0/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Allow providing credentials to HTTPS_PROXY (#9657) Addresses https://github.com/matrix-org/synapse-dinsic/issues/70 This PR causes `ProxyAgent` to attempt to extract credentials from an `HTTPS_PROXY` env var. If credentials are found, a `Proxy-Authorization` header ([details](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Proxy-Authorization)) is sent to the proxy server to authenticate against it. The headers are *not* passed to the remote server. Also added some type hints. * lint
* | | Stabilise all knock-related unstable identifiers that would be in state (#96)Andrew Morgan2021-03-231-3/+8
| | |
* | | Port "Add support for no_proxy and case insensitive env variables" from ↵Andrew Morgan2021-03-2229-59/+224
| | | | | | | | | | | | | | | | | | | | | mainline to dinsic (#93) This PR is simply porting https://github.com/matrix-org/synapse/pull/9372 to dinsic. I also had to bring in https://github.com/matrix-org/synapse/pull/8821 and https://github.com/matrix-org/synapse/pull/9084 for this code to work properly - a sign that we should merge mainline into dinsic again soon.
* | | Change knock room version to v7 (#88)Andrew Morgan2021-03-182-6/+7
| | |
* | | Add a config option to prioritise local users in user directory search ↵Andrew Morgan2021-02-191-0/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | results (#84) * Add a config option to prioritise local users in user directory search results (#9383) This PR adds a homeserver config option, `user_directory.prefer_local_users`, that when enabled will show local users higher in user directory search results than remote users. This option is off by default. Note that turning this on doesn't necessarily mean that remote users will always be put below local users, but they should be assuming all other ranking factors (search query match, profile information present etc) are identical. This is useful for, say, University networks that are openly federating, but want to prioritise local students and staff in the user directory over other random users. * Don't mix simple and english psql query types
* | | Send a ver query parameter for make_knock (#83)Andrew Morgan2021-02-171-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | This informs the remote server of the room versions we support. If the room we're trying to knock on has a version that is not one of our supported room versions, the remote server will return an unsupported room version error. Noticed in https://github.com/matrix-org/matrix-doc/pull/2403#discussion_r577042144 Ported from https://github.com/matrix-org/synapse/pull/6739
* | | Add knocking support (#81)Andrew Morgan2021-02-092-2/+370
| | | | | | | | | | | | | | | | | | | | | | | | | | | Implement knocking as defined by https://github.com/matrix-org/matrix-doc/pull/2403 This is the base knocking stuff, taken from https://github.com/matrix-org/synapse/pull/6739 and does not include any public room directory changes. While knocking hasn't merged yet on mainline due to waiting on getting Complement into Synapse's CI, the code has been well-tested.
* | | Add a parameter to enable/disable freeze feature (#78)Mathieu Velten2021-01-211-0/+1
| | |
* | | Ensure we read account validity templates from custom template dir if ↵Andrew Morgan2021-01-191-0/+51
| | | | | | | | | | | | provided (#77)
* | | Merge commit '693dab487' into anoa/dinsic_release_1_23_1Andrew Morgan2020-12-312-2/+29
|\ \ \ | | |/ | |/|
| * | Fix a regression that mapping providers should be able to redirect users. ↵Patrick Cloke2020-12-042-2/+29
| |/ | | | | | | | | (#8878) This was broken in #8801.
* | Merge commit '53b12688d' into anoa/dinsic_release_1_23_1Andrew Morgan2020-12-312-17/+193
|\|
| * Fix a regression when grandfathering SAML users. (#8855)Patrick Cloke2020-12-022-1/+41
| | | | | | | | | | | | This was broken in #8801 when abstracting code shared with OIDC. After this change both SAML and OIDC have a concept of grandfathering users, but with different implementations.
| * Add basic SAML tests for mapping users. (#8800)Patrick Cloke2020-12-022-17/+153
| |
* | Merge commit 'd3ed93504' into anoa/dinsic_release_1_23_1Andrew Morgan2020-12-313-10/+630
|\|
| * Create a `PasswordProvider` wrapper object (#8849)Richard van der Hoff2020-12-021-2/+3
| | | | | | | | The idea here is to abstract out all the conditional code which tests which methods a given password provider has, to provide a consistent interface.
| * Allow specifying room version in 'RestHelper.create_room_as' and add typing ↵Andrew Morgan2020-12-021-2/+25
| | | | | | | | | | (#8854) This PR adds a `room_version` argument to the `RestHelper`'s `create_room_as` function for tests. I plan to use this for testing knocking, which currently uses an unstable room version.
| * Support "identifier" dicts in UIA (#8848)Richard van der Hoff2020-12-012-18/+26
| | | | | | | | | | | | | | | | | | | | The spec requires synapse to support `identifier` dicts for `m.login.password` user-interactive auth, which it did not (instead, it required an undocumented `user` parameter.) To fix this properly, we need to pull the code that interprets `identifier` into `AuthHandler.validate_login` so that it can be called from the UIA code. Fixes #5665.
| * Don't offer password login when it is disabled (#8835)Richard van der Hoff2020-12-011-3/+105
| | | | | | Fix a minor bug where we would offer "m.login.password" login if a custom auth provider supported it, even if password login was disabled.
| * Add some tests for `password_auth_providers` (#8819)Richard van der Hoff2020-12-011-0/+486
| | | | | | | | These things seemed to be completely untested, so I added a load of tests for them.
* | Merge commit '09ac0569f' into anoa/dinsic_release_1_23_1Andrew Morgan2020-12-317-17/+178
|\|
| * Fix broken testcase (#8851)Richard van der Hoff2020-12-011-1/+0
| | | | | | | | This test was broken by #8565. It doesn't need to set set `self.clock` here anyway - that is done by `setUp`.
| * Add a config option to change whether unread push notification counts are ↵Andrew Morgan2020-11-301-2/+161
| | | | | | | | | | | | | | | | per-message or per-room (#8820) This PR adds a new config option to the `push` section of the homeserver config, `group_unread_count_by_room`. By default Synapse will group push notifications by room (so if you have 1000 unread messages, if they lie in 55 rooms, you'll see an unread count on your phone of 55). However, it is also useful to be able to send out the true count of unread messages if desired. If `group_unread_count_by_room` is set to `false`, then with the above example, one would see an unread count of 1000 (email anyone?).
| * Simplify the way the `HomeServer` object caches its internal attributes. ↵Jonathan de Jong2020-11-305-14/+17
| | | | | | | | | | (#8565) Changes `@cache_in_self` to use underscore-prefixed attributes.
* | Merge commit '7c4344747' into anoa/dinsic_release_1_23_1Andrew Morgan2020-12-318-15/+209
|\|
| * Remove deprecated `/_matrix/client/*/admin` endpoints (#8785)Dirk Klimpel2020-11-256-10/+118
| | | | | | These are now only available via `/_synapse/admin/v1`.
| * Support trying multiple localparts for OpenID Connect. (#8801)Patrick Cloke2020-11-251-1/+87
| | | | | | | | Abstracts the SAML and OpenID Connect code which attempts to regenerate the localpart of a matrix ID if it is already in use.
* | Merge commit '8ca120df7' into anoa/dinsic_release_1_23_1Andrew Morgan2020-12-312-21/+69
|\|
| * Improve error checking for OIDC/SAML mapping providers (#8774)Patrick Cloke2020-11-191-20/+69
| | | | | | | | | | | | Checks that the localpart returned by mapping providers for SAML and OIDC are valid before registering new users. Extends the OIDC tests for existing users and invalid data.
| * Consistently use room_id from federation request body (#8776)Richard van der Hoff2020-11-191-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | * Consistently use room_id from federation request body Some federation APIs have a redundant `room_id` path param (see https://github.com/matrix-org/matrix-doc/issues/2330). We should make sure we consistently use either the path param or the body param, and the body param is easier. * Kill off some references to "context" Once upon a time, "rooms" were known as "contexts". I think this kills of the last references to "contexts".
| * Fix tests on develop (#8777)Erik Johnston2020-11-181-16/+0
| | | | | | This was broken due to #8617 and #8761.
| * Merge pull request #8761 from matrix-org/rav/test_request_renderingRichard van der Hoff2020-11-1758-813/+102
| |\ | | | | | | Make `make_request` actually render the request
| * | Abstract shared SSO code. (#8765)Patrick Cloke2020-11-171-7/+7
| | | | | | | | | De-duplicates code between the SAML and OIDC implementations.
| * | Add admin API for logging in as a user (#8617)Erik Johnston2020-11-176-42/+265
| | |
* | | Merged commit 'deff8f628' into anoa/dinsic_release_1_23_1Andrew Morgan2020-12-319-74/+261
| | |
* | | Merge commit 'acfe3b306' into anoa/dinsic_release_1_23_1Andrew Morgan2020-12-3158-765/+44
|\ \ \ | | |/ | |/|
| * | Remove redundant `HomeserverTestCase.render`Richard van der Hoff2020-11-1644-629/+0
| | |
| * | Remove redundant calls to `render()`Richard van der Hoff2020-11-1613-106/+32
| | |
* | | Merge commit '129ae841e' into anoa/dinsic_release_1_23_1Andrew Morgan2020-12-3115-141/+226
|\| |
| * | Make `make_request` actually render the requestRichard van der Hoff2020-11-169-68/+57
| | | | | | | | | | | | | | | | | | remove the stubbing out of `request.process`, so that `requestReceived` also renders the request via the appropriate resource. Replace render() with a stub for now.
| * | Fix the URL in the URL preview testsRichard van der Hoff2020-11-161-19/+22
| |/ | | | | | | the preview resource is mointed at preview_url, not url_preview
| * Merge pull request #8757 from matrix-org/rav/pass_site_to_make_requestRichard van der Hoff2020-11-1616-88/+227
| |\ | | | | | | Pass a Site into `make_request`
| | * fixup testRichard van der Hoff2020-11-161-0/+1
| | |
| | * Merge branch 'develop' into rav/pass_site_to_make_requestRichard van der Hoff2020-11-169-33/+33
| | |\
| | * | use global make_request() directly where we have a custom ResourceRichard van der Hoff2020-11-1511-60/+154
| | | | | | | | | | | | | | | | | | | | | | | | Where we want to render a request against a specific Resource, call the global make_request() function rather than the one in HomeserverTestCase, allowing us to pass in an appropriate `Site`.
| | * | fix dict handling for make_request()Richard van der Hoff2020-11-152-3/+2
| | | |
* | | | Merge commit 'f12589547' into anoa/dinsic_release_1_23_1Andrew Morgan2020-12-3110-58/+58
|\| | |
| * | | Move `wait_until_result` into `FakeChannel` (#8758)Richard van der Hoff2020-11-162-25/+23
| | |/ | |/| | | | | | | FakeChannel has everything we need, and this more accurately models the real flow.
| * | Rename `create_test_json_resource` to `create_test_resource` (#8759)Richard van der Hoff2020-11-166-23/+15
| | | | | | | | | | | | | | | The root resource isn't necessarily a JsonResource, so rename this method accordingly, and update a couple of test classes to use the method rather than directly manipulating self.resource.
| * | Add a `custom_headers` param to `make_request` (#8760)Richard van der Hoff2020-11-163-11/+23
| | | | | | | | | | | | Some tests want to set some custom HTTP request headers, so provide a way to do that before calling requestReceived().
* | | Merge commit '9debe657a' into anoa/dinsic_release_1_23_1Andrew Morgan2020-12-314-26/+75
|\ \ \ | | |/ | |/|
| * | pass a Site into make_requestRichard van der Hoff2020-11-154-20/+68
| | |
| * | pass a Site into RestHelperRichard van der Hoff2020-11-152-6/+7
| |/
* | Merge commit 'c3119d153' into anoa/dinsic_release_1_23_1Andrew Morgan2020-12-315-75/+712
|\|
| * Add an admin API for users' media statistics (#8700)Dirk Klimpel2020-11-051-0/+485
| | | | | | | | | | | | | | | | Add `GET /_synapse/admin/v1/statistics/users/media` to get statisics about local media usage by users. Related to #6094 It is the first API for statistics. Goal is to avoid/reduce usage of sql queries like [Wiki analyzing Synapse](https://github.com/matrix-org/synapse/wiki/SQL-for-analyzing-Synapse-PostgreSQL-database-stats) Signed-off-by: Dirk Klimpel dirk@klimpel.org
| * Add `displayname` to Shared-Secret Registration for admins (#8722)Dirk Klimpel2020-11-052-8/+132
| | | | | | Add `displayname` to Shared-Secret Registration for admins to `POST /_synapse/admin/v1/register`
| * Consolidate purge table lists to prevent desyncronisation (#8713)Andrew Morgan2020-11-041-67/+38
| | | | | | I idly noticed that these lists were out of sync with each other, causing us to miss a table in a test case (`local_invites`). Let's consolidate this list instead to prevent this from happening in the future.
| * Block clients from sending server ACLs that lock the local server out. (#8708)Erik Johnston2020-11-031-0/+57
| | | | | | Fixes #4042
* | Merge commit 'f27a78969' into anoa/dinsic_release_1_23_1Andrew Morgan2020-12-315-4/+375
|\|
| * Implement and use an @lru_cache decorator (#8595)Richard van der Hoff2020-10-301-1/+59
| | | | | | We don't always need the full power of a DeferredCache.
| * Fail test cases if they fail to await all awaitables (#8690)Patrick Cloke2020-10-302-2/+38
| |
| * Fix race for concurrent downloads of remote media. (#8682)Erik Johnston2020-10-302-1/+278
| | | | | | Fixes #6755
* | Merge commit 'ef2d62701' into anoa/dinsic_release_1_23_1Andrew Morgan2020-12-3117-435/+315
|\|
| * Fix unit tests (#8689)Erik Johnston2020-10-291-1/+1
| | | | | | | | | | * Fix unit tests * Newsfile
| * Gracefully handle a pending logging connection during shutdown. (#8685)Patrick Cloke2020-10-291-0/+16
| |
| * Add ability for access tokens to belong to one user but grant access to ↵Erik Johnston2020-10-2910-33/+30
| | | | | | | | | | | | | | | | | | | | another user. (#8616) We do it this way round so that only the "owner" can delete the access token (i.e. `/logout/all` by the "owner" also deletes that token, but `/logout/all` by the "target user" doesn't). A future PR will add an API for creating such a token. When the target user and authenticated entity are different the `Processed request` log line will be logged with a: `{@admin:server as @bob:server} ...`. I'm not convinced by that format (especially since it adds spaces in there, making it harder to use `cut -d ' '` to chop off the start of log lines). Suggestions welcome.
| * Support generating structured logs in addition to standard logs. (#8607)Patrick Cloke2020-10-295-400/+258
| | | | | | | | | | | | | | This modifies the configuration of structured logging to be usable from the standard Python logging configuration. This also separates the formatting of logs from the transport allowing JSON logs to files or standard logs to sockets.
| * Don't require hiredis to run unit tests (#8680)Erik Johnston2020-10-291-1/+10
| |
* | Merge commit 'c97da1e45' into anoa/dinsic_release_1_23_1Andrew Morgan2020-12-316-6/+130
|\|
| * Add an admin APIs to allow server admins to list users' pushers (#8610)Dirk Klimpel2020-10-281-0/+124
| | | | | | Add an admin API `GET /_synapse/admin/v1/users/<user_id>/pushers` like https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-pushers
| * Tell Black to format code for Python 3.5 (#8664)Dan Callahan2020-10-275-6/+6
| | | | | | | | | | | | | | | | This allows trailing commas in multi-line arg lists. Minor, but we might as well keep our formatting current with regard to our minimum supported Python version. Signed-off-by: Dan Callahan <danc@element.io>
* | Merge commit '88e1d0c52' into anoa/dinsic_release_1_23_1Andrew Morgan2020-12-311-0/+282
|\|
| * Add admin API to list users' local media (#8647)Dirk Klimpel2020-10-271-0/+282
| | | | | | Add admin API `GET /_synapse/admin/v1/users/<user_id>/media` to get information of users' uploaded files.
* | Merge commit '24229fac0' into anoa/dinsic_release_1_23_1Andrew Morgan2020-12-314-14/+783
|\|
| * Split admin API for reported events into a detail and a list view (#8539)Dirk Klimpel2020-10-261-13/+183
| | | | | | | | | | | | | | | | | | | | | | | | Split admin API for reported events in detail und list view. API was introduced with #8217 in synapse v.1.21.0. It makes the list (`GET /_synapse/admin/v1/event_reports`) less complex and provides a better overview. The details can be queried with: `GET /_synapse/admin/v1/event_reports/<report_id>`. It is similar to room and users API. It is a kind of regression in `GET /_synapse/admin/v1/event_reports`. `event_json` was removed. But the api was introduced one version before and it is an admin API (not under spec). Signed-off-by: Dirk Klimpel dirk@klimpel.org
| * Add an admin api to delete local media. (#8519)Dirk Klimpel2020-10-261-0/+568
| | | | | | | | | | | | Related to: #6459, #3479 Add `DELETE /_synapse/admin/v1/media/<server_name>/<media_id>` to delete a single file from server.
| * Fix a bug in the joined_rooms admin API (#8643)Dirk Klimpel2020-10-261-1/+15
| | | | | | | | If the user was not in any rooms then the API returned the same error as if the user did not exist.
| * Fix get|set_type_stream_id_for_appservice store functions (#8648)Will Hunt2020-10-261-0/+56
| |
| * Add field `total` to device list in admin API (#8644)Dirk Klimpel2020-10-261-0/+17
| |
* | Merge commit '7a3adbd7a' into anoa/dinsic_release_1_23_1Andrew Morgan2020-12-311-0/+56
|\ \
| * | Fix get|set_type_stream_id_for_appservice store functions (#8648)Will Hunt2020-10-261-0/+56
| | |
* | | Merge commit '2b7c18087' into anoa/dinsic_release_1_23_1Andrew Morgan2020-12-313-18/+55
|\ \ \ | | |/ | |/|
| * | Start fewer opentracing spans (#8640)Erik Johnston2020-10-261-12/+8
| | | | | | | | | | | | | | | | | | | | | #8567 started a span for every background process. This is good as it means all Synapse code that gets run should be in a span (unless in the sentinel logging context), but it means we generate about 15x the number of spans as we did previously. This PR attempts to reduce that number by a) not starting one for send commands to Redis, and b) deferring starting background processes until after we're sure they're necessary. I don't really know how much this will help.
| * | Fix handling of User-Agent headers with bad utf-8. (#8632)Erik Johnston2020-10-231-6/+18
| | |
| * | Fix email notifications for invites without local state. (#8627)Erik Johnston2020-10-231-0/+29
| | | | | | | | | | | | This can happen if e.g. the room invited into is no longer on the server (or if all users left the room).
* | | Merge commit 'b19b63e6b' into anoa/dinsic_release_1_23_1Andrew Morgan2020-12-315-11/+11
|\| |
| * | Don't instansiate Requester directly (#8614)Erik Johnston2020-10-225-11/+11
| |/
* | Merge commit '9146a8a69' into dinsicAndrew Morgan2020-12-313-237/+385
|\|
| * Merge pull request #8572 from matrix-org/rav/cache_hacking/2Richard van der Hoff2020-10-213-237/+385
| |\ | | | | | | Push some deferred wrangling down into DeferredCache
| | * Add some more testsRichard van der Hoff2020-10-212-0/+147
| | |
| | * Push some deferred wrangling down into DeferredCacheRichard van der Hoff2020-10-212-12/+11
| | |
| | * Combine the two sets of tests for CacheDescriptorRichard van der Hoff2020-10-212-228/+230
| | |
* | | Merge commit '70259d8c' into dinsicAndrew Morgan2020-12-312-1/+42
|\| |
| * | Limit AS transactions to 100 events (#8606)Will Hunt2020-10-211-0/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Limit AS transactions to 100 events * Update changelog.d/8606.feature Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> * Add tests * Update synapse/appservice/scheduler.py Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
| * | Separate the TCP and terse JSON formatting code. (#8587)Patrick Cloke2020-10-211-1/+1
| |/ | | | | | | This should (theoretically) allow for using the TCP code with a different output type and make it easier to use the JSON code with files / console.
* | Merge commit 'de5cafe98' into dinsicAndrew Morgan2020-12-316-49/+57
|\|
| * Remove some extraneous @unittest.INFOs on unit tests (#8592)Andrew Morgan2020-10-202-2/+0
| |
| * Fix 'LruCache' object has no attribute '_on_resize' (#8591)Richard van der Hoff2020-10-191-1/+7
| | | | | | We need to make sure we are readu for the `set_cache_factor` callback.
| * Add `DeferredCache.get_immediate` method (#8568)Richard van der Hoff2020-10-191-4/+23
| | | | | | | | | | | | | | | | | | | | | | * Add `DeferredCache.get_immediate` method A bunch of things that are currently calling `DeferredCache.get` are only really interested in the result if it's completed. We can optimise and simplify this case. * Remove unused 'default' parameter to DeferredCache.get() * another get_immediate instance
| * Include a simple message in email notifications that include encrypted ↵Patrick Cloke2020-10-191-1/+14
| | | | | | | | content (#8545)
* | Merge commit '3ee17585c' into dinsicAndrew Morgan2020-12-319-49/+111
|\|
| * Make LruCache register its own metrics (#8561)Richard van der Hoff2020-10-161-2/+2
| | | | | | | | | | rather than have everything that instantiates an LruCache manage metrics separately, have LruCache do it itself.
| * Merge pull request #8535 from matrix-org/rav/third_party_events_updatesRichard van der Hoff2020-10-151-4/+24
| |\ | | | | | | Support modifying event content from ThirdPartyRules modules
| | * guard against accidental modificationRichard van der Hoff2020-10-131-0/+20
| | |
| | * Allow ThirdPartyRules modules to replace event contentRichard van der Hoff2020-10-131-4/+4
| | | | | | | | | | | | Support returning a new event dict from `check_event_allowed`.
| * | Solidify the HomeServer constructor. (#8515)Jonathan de Jong2020-10-155-20/+23
| | | | | | | | | | | | | | | | | | This implements a more standard API for instantiating a homeserver and moves some of the dependency injection into the test suite. More concretely this stops using `setattr` on all `kwargs` passed to `HomeServer`.
| * | Send some ephemeral events to appservices (#8437)Will Hunt2020-10-152-23/+62
| | | | | | | | | Optionally sends typing, presence, and read receipt information to appservices.
* | | Merge commit '74976a8e4' into dinsicAndrew Morgan2020-12-3143-437/+1411
|\| |
| * | Merge pull request #8548 from matrix-org/rav/deferred_cacheRichard van der Hoff2020-10-154-118/+140
| |\ \ | | | | | | | | Rename Cache to DeferredCache, and related changes
| | * | Combine the two sets of DeferredCache testsRichard van der Hoff2020-10-142-74/+75
| | | |
| | * | move DeferredCache into its own moduleRichard van der Hoff2020-10-144-46/+67
| | | |
| | * | Rename Cache->DeferredCacheRichard van der Hoff2020-10-143-9/+9
| | |/
| * | Merge pull request #8537 from matrix-org/rav/simplify_locally_reject_inviteRichard van der Hoff2020-10-154-5/+4
| |\ \ | | | | | | | | Simplify `_locally_reject_invite`
| | * | Simplify `_locally_reject_invite`Richard van der Hoff2020-10-133-4/+4
| | | | | | | | | | | | | | | | | | | | Update `EventCreationHandler.create_event` to accept an auth_events param, and use it in `_locally_reject_invite` instead of reinventing the wheel.
| | * | Remove redundant `token_id` parameter to create_eventRichard van der Hoff2020-10-131-1/+0
| | |/ | | | | | | | | | this is always the same as requester.access_token_id.
| * | Add basic tests for sync/pagination with vector clock tokens. (#8488)Erik Johnston2020-10-142-1/+248
| | | | | | | | | | | | | | | These are tests for #8439
| * | Fix not sending events over federation when using sharded event persisters ↵Erik Johnston2020-10-141-3/+10
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#8536) * Fix outbound federaion with multiple event persisters. We incorrectly notified federation senders that the minimum persisted stream position had advanced when we got an `RDATA` from an event persister. Notifying of federation senders already correctly happens in the notifier, so we just delete the offending line. * Change some interfaces to use RoomStreamToken. By enforcing use of `RoomStreamTokens` we make it less likely that people pass in random ints that they got from somewhere random.
| * Move additional tasks to the background worker, part 4 (#8513)Patrick Cloke2020-10-131-34/+14
| |
| * Fix message duplication if something goes wrong after persisting the event ↵Erik Johnston2020-10-133-3/+167
| | | | | | | | | | (#8476) Should fix #3365.
| * Make event persisters periodically announce position over replication. (#8499)Erik Johnston2020-10-121-9/+16
| | | | | | | | | | Currently background proccesses stream the events stream use the "minimum persisted position" (i.e. `get_current_token()`) rather than the vector clock style tokens. This is broadly fine as it doesn't matter if the background processes lag a small amount. However, in extreme cases (i.e. SyTests) where we only write to one event persister the background processes will never make progress. This PR changes it so that the `MultiWriterIDGenerator` keeps the current position of a given instance as up to date as possible (i.e using the latest token it sees if its not in the process of persisting anything), and then periodically announces that over replication. This then allows the "minimum persisted position" to advance, albeit with a small lag.
| * Clean-up some broken/unused code in the test framework (#8514)Patrick Cloke2020-10-092-70/+54
| |
| * Fix threadsafety in ThreadedMemoryReactorClock (#8497)Richard van der Hoff2020-10-091-4/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This could, very occasionally, cause: ``` tests.test_visibility.FilterEventsForServerTestCase.test_large_room =============================================================================== [ERROR] Traceback (most recent call last): File "/src/tests/rest/media/v1/test_media_storage.py", line 86, in test_ensure_media_is_in_local_cache self.wait_on_thread(x) File "/src/tests/unittest.py", line 296, in wait_on_thread self.reactor.advance(0.01) File "/src/.tox/py35/lib/python3.5/site-packages/twisted/internet/task.py", line 826, in advance self._sortCalls() File "/src/.tox/py35/lib/python3.5/site-packages/twisted/internet/task.py", line 787, in _sortCalls self.calls.sort(key=lambda a: a.getTime()) builtins.ValueError: list modified during sort tests.rest.media.v1.test_media_storage.MediaStorageTests.test_ensure_media_is_in_local_cache ```
| * Allow modules to create and send events into rooms (#8479)Andrew Morgan2020-10-092-1/+122
| | | | | | | | | | This PR allows Synapse modules making use of the `ModuleApi` to create and send non-membership events into a room. This can useful to have modules send messages, or change power levels in a room etc. Note that they must send event through a user that's already in the room. The non-membership event limitation is currently arbitrary, as it's another chunk of work and not necessary at the moment.
| * Remove the deprecated Handlers object (#8494)Patrick Cloke2020-10-0918-63/+36
| | | | | | All handlers now available via get_*_handler() methods on the HomeServer.
| * Invalidate the cache when an olm fallback key is uploaded (#8501)Hubert Chathi2020-10-081-0/+20
| |
| * Reduce serialization errors in MultiWriterIdGen (#8456)Erik Johnston2020-10-071-0/+1
| | | | | | | | | | | | We call `_update_stream_positions_table_txn` a lot, which is an UPSERT that can conflict in `REPEATABLE READ` isolation level. Instead of doing a transaction consisting of a single query we may as well run it outside of a transaction.
| * Add support for MSC2697: Dehydrated devices (#8380)Hubert Chathi2020-10-071-0/+82
| | | | | | | | This allows a user to store an offline device on the server and then restore it at a subsequent login.
| * Merge pull request #8463 from matrix-org/rav/clean_up_event_handlingRichard van der Hoff2020-10-072-2/+4
| |\ | | | | | | Reduce inconsistencies between codepaths for membership and non-membership events.
| | * kill off `send_nonmember_event`Richard van der Hoff2020-10-052-2/+4
| | | | | | | | | | | | This is now redundant, and we can just call `handle_new_client_event` directly.
| * | Combine `SpamCheckerApi` with the more generic `ModuleApi`. (#8464)Richard van der Hoff2020-10-071-2/+2
| | | | | | | | | | | | | | | Lots of different module apis is not easy to maintain. Rather than adding yet another ModuleApi(hs, hs.get_auth_handler()) incantation, first add an hs.get_module_api() method and use it where possible.
| * | Add support for MSC2732: olm fallback keys (#8312)Hubert Chathi2020-10-061-0/+65
| | |
| * | Additional tests for third-party event rules (#8468)Richard van der Hoff2020-10-061-13/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | * Optimise and test state fetching for 3p event rules Getting all the events at once is much more efficient than getting them individually * Test that 3p event rules can modify events
| * | Merge pull request #8467 from matrix-org/rav/fix_3pevent_rulesRichard van der Hoff2020-10-061-1/+1
| |\ \ | | | | | | | | Fix third-party event modules for `check_visibility_can_be_modified` check
| | * | Fix third-party event modules for `check_visibility_can_be_modified` checkRichard van der Hoff2020-10-051-1/+1
| | |/ | | | | | | | | | | | | | | | PR #8292 tried to maintain backwards compat with modules which don't provide a `check_visibility_can_be_modified` method, but the tests weren't being run, and the check didn't work.
| * / Update default room version to 6 (#8461)Richard van der Hoff2020-10-051-1/+10
| |/ | | | | | | Per https://github.com/matrix-org/matrix-doc/pull/2788
| * Allow ThirdPartyEventRules modules to manipulate public room state (#8292)Andrew Morgan2020-10-052-13/+74
| | | | | | | | | | This PR allows `ThirdPartyEventRules` modules to view, manipulate and block changes to the state of whether a room is published in the public rooms directory. While the idea of whether a room is in the public rooms list is not kept within an event in the room, `ThirdPartyEventRules` generally deal with controlling which modifications can happen to a room. Public rooms fits within that idea, even if its toggle state isn't controlled through a state event.
| * Add logging on startup/shutdown (#8448)Erik Johnston2020-10-022-5/+11
| | | | | | | | | | This is so we can tell what is going on when things are taking a while to start up. The main change here is to ensure that transactions that are created during startup get correctly logged like normal transactions.
| * Speed up unit tests when using PostgreSQL (#8450)Erik Johnston2020-10-021-0/+4
| |
| * Allow background tasks to be run on a separate worker. (#8369)Patrick Cloke2020-10-022-2/+2
| |
| * Add unit test for event persister sharding (#8433)Erik Johnston2020-10-023-22/+306
| |
| * Add config option for always using "userinfo endpoint" for OIDC (#7658)BBBSnowball2020-10-011-2/+8
| | | | | | This allows for connecting to certain IdPs, e.g. GitLab.
* | Allow users to click account renewal links multiple times without hitting an ↵Andrew Morgan2020-12-301-17/+36
| | | | | | | | 'Invalid Token' page (#74)
* | Support PyJWT v2.0.0. (#8986)Patrick Cloke2020-12-291-4/+12
| | | | | | | | Tests were broken due to an API changing. The code used in Synapse proper should be compatible with both versions already.
* | Override any missing default power level keys with DINUM's defaults when ↵Andrew Morgan2020-10-291-0/+47
| | | | | | | | | | | | | | creating a room (#68) The createRoom flow in DINUM's Synapse (through the AccessRules module which has hooks for all of this) already rejects a power levels content dict if it doesn't have high enough power levels to satisfy DINUM's [requirements](https://github.com/matrix-org/synapse-dinsic/blob/ac50ed353b5fdbdf9f853be0d94b6fccaf33973e/synapse/third_party_rules/access_rules.py#L233-L252). This PR ensures that any keys that aren't provided are replaced with the defaults, instead of just assuming the whole dict was correct (and thus those keys were set to mainline Synapse's default instead).
* | Merge commit 'f76194a02' into anoa/dinsic_release_1_21_xAndrew Morgan2020-10-211-0/+1
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit 'f76194a02': 1.21.0 Update change log 1.21.0rc3 Reduce serialization errors in MultiWriterIdGen (#8456) Add Ubuntu 20.10 (Groovy Gorilla) to build scripts. (#8475) move #8444 to 'feature' linkify changelog
| * | Reduce serialization errors in MultiWriterIdGen (#8456)Erik Johnston2020-10-071-0/+1
| |/ | | | | | | | | | | | | We call `_update_stream_positions_table_txn` a lot, which is an UPSERT that can conflict in `REPEATABLE READ` isolation level. Instead of doing a transaction consisting of a single query we may as well run it outside of a transaction.
* | Merge commit 'cc40a59b4' into anoa/dinsic_release_1_21_xAndrew Morgan2020-10-214-73/+141
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit 'cc40a59b4': 1.21.0 Add prometheus metrics to track federation delays (#8430) Make token serializing/deserializing async (#8427) Allow additional SSO properties to be passed to the client (#8413) changelog Add an improved "forward extremities" metric Rewrite BucketCollector Fix _exposition.py to stop stripping samples Drop support for ancient prometheus_client (#8426) Various clean ups to room stream tokens. (#8423) changelog Report state res metrics to Prometheus and log Move Measure calls into `resolve_events_with_store` Expose a `get_resource_usage` method in `Measure` Move `resolve_events_with_store` into StateResolutionHandler
| * Make token serializing/deserializing async (#8427)Erik Johnston2020-09-302-11/+28
| | | | | | The idea is that in future tokens will encode a mapping of instance to position. However, we don't want to include the full instance name in the string representation, so instead we'll have a mapping between instance name and an immutable integer ID in the DB that we can use instead. We'll then do the lookup when we serialize/deserialize the token (we could alternatively pass around an `Instance` type that includes both the name and ID, but that turns out to be a lot more invasive).
| * Merge pull request #8425 from matrix-org/rav/extremity_metricsRichard van der Hoff2020-09-301-8/+11
| |\ | | | | | | Add an improved "forward extremities" metric
| | * Rewrite BucketCollectorRichard van der Hoff2020-09-301-8/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was a bit unweildy for what I wanted: in particular, I wanted to assign each measurement straight into a bucket, rather than storing an intermediate Counter which didn't do any bucketing at all. I've replaced it with something that is hopefully a bit easier to use. (I'm not entirely sure what the difference between a HistogramMetricFamily and a GaugeHistogramMetricFamily is, but given our counters can go down as well as up the latter *sounds* more accurate?)
| * | Allow additional SSO properties to be passed to the client (#8413)Patrick Cloke2020-09-301-55/+105
| |/
| * Various clean ups to room stream tokens. (#8423)Erik Johnston2020-09-292-10/+8
| |
* | Merge commit '8238b55e0' into anoa/dinsic_release_1_21_xAndrew Morgan2020-10-211-0/+18
|\| | | | | | | | | | | | | | | * commit '8238b55e0': Update description of server_name config option (#8415) Discard an empty upload_name before persisting an uploaded file (#7905) Don't table scan events on worker startup (#8419) Mypy fixes for `synapse.handlers.federation` (#8422)
| * Don't table scan events on worker startup (#8419)Erik Johnston2020-09-291-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix table scan of events on worker startup. This happened because we assumed "new" writers had an initial stream position of 0, so the replication code tried to fetch all events written by the instance between 0 and the current position. Instead, set the initial position of new writers to the current persisted up to position, on the assumption that new writers won't have written anything before that point. * Consider old writers coming back as "new". Otherwise we'd try and fetch entries between the old stale token and the current position, even though it won't have written any rows. Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* | Merge commit 'f43c66d23' into anoa/dinsic_release_1_21_xAndrew Morgan2020-10-217-12/+276
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit 'f43c66d23': Add support for running Complement against the local checkout (#8317) Filter out appservices from mau count (#8404) Only assert valid next_link params when provided (#8417) Add metrics to track success/otherwise of replication requests (#8406) Fix handling of connection timeouts in outgoing http requests (#8400) Changelog Don't check whether a 3pid is allowed to register during password reset Add checks for postgres sequence consistency (#8402) Create a mechanism for marking tests "logcontext clean" (#8399) Add `ui_auth_sessions_ips` table to `synapse_port_db` ignore list (#8410) A pair of tiny cleanups in the federation request code. (#8401) typo
| * Filter out appservices from mau count (#8404)Will Hunt2020-09-291-1/+16
| | | | | | This is an attempt to fix #8403.
| * Only assert valid next_link params when provided (#8417)Andrew Morgan2020-09-291-0/+6
| | | | | | | | | | | | | | Broken in https://github.com/matrix-org/synapse/pull/8275 and has yet to be put in a release. Fixes https://github.com/matrix-org/synapse/issues/8418. `next_link` is an optional parameter. However, we were checking whether the `next_link` param was valid, even if it wasn't provided. In that case, `next_link` was `None`, which would clearly not be a valid URL. This would prevent password reset and other operations if `next_link` was not provided, and the `next_link_domain_whitelist` config option was set.
| * Fix handling of connection timeouts in outgoing http requests (#8400)Richard van der Hoff2020-09-292-6/+188
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Remove `on_timeout_cancel` from `timeout_deferred` The `on_timeout_cancel` param to `timeout_deferred` wasn't always called on a timeout (in particular if the canceller raised an exception), so it was unreliable. It was also only used in one place, and to be honest it's easier to do what it does a different way. * Fix handling of connection timeouts in outgoing http requests Turns out that if we get a timeout during connection, then a different exception is raised, which wasn't always handled correctly. To fix it, catch the exception in SimpleHttpClient and turn it into a RequestTimedOutError (which is already a documented exception). Also add a description to RequestTimedOutError so that we can see which stage it failed at. * Fix incorrect handling of timeouts reading federation responses This was trapping the wrong sort of TimeoutError, so was never being hit. The effect was relatively minor, but we should fix this so that it does the expected thing. * Fix inconsistent handling of `timeout` param between methods `get_json`, `put_json` and `delete_json` were applying a different timeout to the response body to `post_json`; bring them in line and test. Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com> Co-authored-by: Erik Johnston <erik@matrix.org>
| * Add checks for postgres sequence consistency (#8402)Erik Johnston2020-09-282-4/+49
| |
| * Create a mechanism for marking tests "logcontext clean" (#8399)Richard van der Hoff2020-09-282-1/+17
| |
* | Merge commit '31acc5c30' into anoa/dinsic_release_1_21_xAndrew Morgan2020-10-214-75/+211
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit '31acc5c30': Escape the error description on the sso_error template. (#8405) Fix occasional "Re-starting finished log context" from keyring (#8398) Allow existing users to login via OpenID Connect. (#8345) Fix schema delta for servers that have not backfilled (#8396) Fix MultiWriteIdGenerator's handling of restarts. (#8374) s/URLs/variables in changelog s/accidentally/incorrectly in changelog Update changelog wording Add type annotations to SimpleHttpClient (#8372) Add new sequences to port DB script (#8387) Add EventStreamPosition type (#8388) Mark the shadow_banned column as boolean in synapse_port_db. (#8386)
| * Fix occasional "Re-starting finished log context" from keyring (#8398)Richard van der Hoff2020-09-251-64/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix test_verify_json_objects_for_server_awaits_previous_requests It turns out that this wasn't really testing what it thought it was testing (in particular, `check_context` was turning failures into success, which was making the tests pass even though it wasn't clear they should have been. It was also somewhat overcomplex - we can test what it was trying to test without mocking out perspectives servers. * Fix warnings about finished logcontexts in the keyring We need to make sure that we finish the key fetching magic before we run the verifying code, to ensure that we don't mess up our logcontexts.
| * Allow existing users to login via OpenID Connect. (#8345)Tdxdxoz2020-09-251-0/+35
| | | | | | | | | | | | | | Co-authored-by: Benjamin Koch <bbbsnowball@gmail.com> This adds configuration flags that will match a user to pre-existing users when logging in via OpenID Connect. This is useful when switching to an existing SSO system.
| * Fix MultiWriteIdGenerator's handling of restarts. (#8374)Erik Johnston2020-09-241-8/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On startup `MultiWriteIdGenerator` fetches the maximum stream ID for each instance from the table and uses that as its initial "current position" for each writer. This is problematic as a) it involves either a scan of events table or an index (neither of which is ideal), and b) if rows are being persisted out of order elsewhere while the process restarts then using the maximum stream ID is not correct. This could theoretically lead to race conditions where e.g. events that are persisted out of order are not sent down sync streams. We fix this by creating a new table that tracks the current positions of each writer to the stream, and update it each time we finish persisting a new entry. This is a relatively small overhead when persisting events. However for the cache invalidation stream this is a much bigger relative overhead, so instead we note that for invalidation we don't actually care about reliability over restarts (as there's no caches to invalidate) and simply don't bother reading and writing to the new table in that particular case.
| * Add EventStreamPosition type (#8388)Erik Johnston2020-09-241-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The idea is to remove some of the places we pass around `int`, where it can represent one of two things: 1. the position of an event in the stream; or 2. a token that partitions the stream, used as part of the stream tokens. The valid operations are then: 1. did a position happen before or after a token; 2. get all events that happened before or after a token; and 3. get all events between two tokens. (Note that we don't want to allow other operations as we want to change the tokens to be vector clocks rather than simple ints)
* | Merge commit '2983049a7' into anoa/dinsic_release_1_21_xAndrew Morgan2020-10-211-25/+41
|\| | | | | | | | | | | | | | | | | | | | | | | * commit '2983049a7': Factor out `_send_dummy_event_for_room` (#8370) Improve logging of state resolution (#8371) Fix bug which caused failure on join with malformed membership events (#8385) Use `async with` for ID gens (#8383) Don't push if an user account has expired (#8353) Do not check lint/test dependencies at runtime. (#8377) Add note to reverse_proxy.md about disabling Apache's mod_security2 (#8375) Changelog
| * Use `async with` for ID gens (#8383)Erik Johnston2020-09-231-25/+41
| | | | | | This will allow us to hit the DB after we've finished using the generated stream ID.