matrix-synapse 1.140.0rc1__cp39-abi3-macosx_11_0_arm64.whl → 1.141.0rc2__cp39-abi3-macosx_11_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of matrix-synapse might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: matrix-synapse
3
- Version: 1.140.0rc1
3
+ Version: 1.141.0rc2
4
4
  Summary: Homeserver for the Matrix decentralised comms protocol
5
5
  License: AGPL-3.0-or-later OR LicenseRef-Element-Commercial
6
6
  Author: Matrix.org Team and Contributors
@@ -1,11 +1,11 @@
1
- matrix_synapse-1.140.0rc1.dist-info/RECORD,,
2
- matrix_synapse-1.140.0rc1.dist-info/LICENSE-AGPL-3.0,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
3
- matrix_synapse-1.140.0rc1.dist-info/LICENSE-COMMERCIAL,sha256=EZfebSnFA3xtm1w2B9cuqpC1BF8tYjQA6HCCX9z3Zm4,255
4
- matrix_synapse-1.140.0rc1.dist-info/WHEEL,sha256=scg0IzB77chy-_40STvfbf7iGhX6kulz7EDsXzX0T_8,132
5
- matrix_synapse-1.140.0rc1.dist-info/entry_points.txt,sha256=Xf4Z-Sp4lk8P9pbRhSD40XrhhkooqYWm1OtxUlPwPgs,709
6
- matrix_synapse-1.140.0rc1.dist-info/AUTHORS.rst,sha256=KvPRmsv8L-ZN9AA51KsR-4fZu0ajfkCbSNNH9rhRUO4,1611
7
- matrix_synapse-1.140.0rc1.dist-info/METADATA,sha256=AZkJEl2UQhWobsklcyGMnMz5IG08X3e92YrQKAhDMos,17005
8
- synapse/server.py,sha256=ARplbOkStxgqjWZVc63RokcWGBtnfDW-LeLWT7Q6lSQ,44912
1
+ matrix_synapse-1.141.0rc2.dist-info/RECORD,,
2
+ matrix_synapse-1.141.0rc2.dist-info/LICENSE-AGPL-3.0,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
3
+ matrix_synapse-1.141.0rc2.dist-info/LICENSE-COMMERCIAL,sha256=EZfebSnFA3xtm1w2B9cuqpC1BF8tYjQA6HCCX9z3Zm4,255
4
+ matrix_synapse-1.141.0rc2.dist-info/WHEEL,sha256=scg0IzB77chy-_40STvfbf7iGhX6kulz7EDsXzX0T_8,132
5
+ matrix_synapse-1.141.0rc2.dist-info/entry_points.txt,sha256=Xf4Z-Sp4lk8P9pbRhSD40XrhhkooqYWm1OtxUlPwPgs,709
6
+ matrix_synapse-1.141.0rc2.dist-info/AUTHORS.rst,sha256=KvPRmsv8L-ZN9AA51KsR-4fZu0ajfkCbSNNH9rhRUO4,1611
7
+ matrix_synapse-1.141.0rc2.dist-info/METADATA,sha256=3cIxSPUcTj5AgpZRyjRGEy4ijsmdkequvwO5-bc2ddw,17005
8
+ synapse/server.py,sha256=3JfefqrjLSeX7Gv8ZA9E103E4O6l05uDkfIghkAfNxg,45069
9
9
  synapse/synapse_rust.abi3.so,sha256=c8Hr_z19BOOySFjzivUlQep5buKDZv-KOxKpsEVZsmg,10483184
10
10
  synapse/event_auth.py,sha256=fTm9uAf2iC6bIJuP7QH_7zz26VrqPLIqsoXKXkGINME,47090
11
11
  synapse/notifier.py,sha256=-qPQQiKxrxwU5Cr3Uzv8PIoyWcNKfBipKemOBzELbT4,35910
@@ -16,7 +16,7 @@ synapse/_pydantic_compat.py,sha256=87dKeVb2Anau0frkNqq3y8XC5ZwJ3jLyVOsWSEwsCZ8,2
16
16
  synapse/metrics/_types.py,sha256=XjukHeHdmh5xcELjdh0ZuLWpKlwpRFMedoM2MK3Mmko,1196
17
17
  synapse/metrics/background_process_metrics.py,sha256=L3-hiIX_PRITvCMsGGa5UXDAibBbd5zafkvc5xPpOYA,22473
18
18
  synapse/metrics/_reactor_metrics.py,sha256=crp4x_VgjavL9Es2lo5JLXrzRr3wzTyK54q_gCViv6k,6002
19
- synapse/metrics/common_usage_metrics.py,sha256=j6ekGWIXaob2Z8sLWj1mPVQXZmLs0ejb50btPHzWV-U,2947
19
+ synapse/metrics/common_usage_metrics.py,sha256=guOeJ84ARHNxHH8OLdw_e-MhMRqFfyJfdlTfY5nso1w,2941
20
20
  synapse/metrics/_gc.py,sha256=s2k-GPFUItKGrLuIujrYQWlt-0bJE81WtLVbLfnhjZQ,8304
21
21
  synapse/metrics/jemalloc.py,sha256=H1Dn6B0Ob-PWX4lww78fYMJg8X6pfuXdB5YjURkKs1U,8341
22
22
  synapse/metrics/__init__.py,sha256=cn3EYBg9ehpOkjwxi7LBUOqKib3F6OvLXPjlXa3sCa0,26784
@@ -85,9 +85,9 @@ synapse/types/rest/client/__init__.py,sha256=UZtSkvh4_GfF048h36WR-joK_4OpH2dJ5Dp
85
85
  synapse/app/pusher.py,sha256=8kcF8yev36b8nFs_lI0VfEWgosAXl78aEQr0IZPrWAk,1060
86
86
  synapse/app/frontend_proxy.py,sha256=8kcF8yev36b8nFs_lI0VfEWgosAXl78aEQr0IZPrWAk,1060
87
87
  synapse/app/generic_worker.py,sha256=Y3XYVWBk1kQrjO74TBb4pboAsqK7TBolWpgPF1FWK4s,15705
88
- synapse/app/_base.py,sha256=eGDIixPs1OiKgtPGwMRZYG5wfNAZy_guJaDJDlvoc7E,30734
88
+ synapse/app/_base.py,sha256=1dWeO2lo7ys1sXBctgq3wvIHChgl1XGfK56qYHmCTpA,30249
89
89
  synapse/app/client_reader.py,sha256=8kcF8yev36b8nFs_lI0VfEWgosAXl78aEQr0IZPrWAk,1060
90
- synapse/app/homeserver.py,sha256=65-0hHxx8BR7uiQlKzrRL6ZM9uq--FNdsNIQhv527AM,17211
90
+ synapse/app/homeserver.py,sha256=jilEa1K4HyOpRiFOAmsMbOaU1B6d7a_aAbFyXRkxCvg,17069
91
91
  synapse/app/appservice.py,sha256=8kcF8yev36b8nFs_lI0VfEWgosAXl78aEQr0IZPrWAk,1060
92
92
  synapse/app/synchrotron.py,sha256=8kcF8yev36b8nFs_lI0VfEWgosAXl78aEQr0IZPrWAk,1060
93
93
  synapse/app/complement_fork_starter.py,sha256=-e0KrFWsUp98tQVpKMTvftAZF6CNGehxihOHCDhjRIw,7288
@@ -103,7 +103,7 @@ synapse/util/async_helpers.py,sha256=eq77yWWO1HcJ0B23-EkRaqLeFDst5xAl7xhpte2WoRU
103
103
  synapse/util/logcontext.py,sha256=WLB1FgS7BIJyeCpzc5ltm9gr8EEr0dBY7_kQ31S7_wM,1269
104
104
  synapse/util/threepids.py,sha256=XT_az254AK_DJLGyg5SjKfyMsGYhmCzIN14Dp8lZIZw,3745
105
105
  synapse/util/retryutils.py,sha256=fpOE1kcudz_ETdxpWOm0WkQVauiw3Sqc8sdKy_HDQIY,12787
106
- synapse/util/metrics.py,sha256=T5WjREtVFTsFgSWIqJa0_79BuYKFwfquwSK_ppvpvtM,11826
106
+ synapse/util/metrics.py,sha256=E2MTVyGbEcIdCC2ftgMBj7bhsppPhw_xtkya23IFbgA,12046
107
107
  synapse/util/ratelimitutils.py,sha256=INMr6RS03H5bzwSeNQ2k8Ar43swFGaXyIoXjuXO13_0,14714
108
108
  synapse/util/distributor.py,sha256=f-9_QQelrRriNtJSzNIW9QywQwLeN8Gg6DopQgyDaNc,5291
109
109
  synapse/util/iterutils.py,sha256=gwJFEmgOrVBBFwjgicskuM3Fhb05YoLX6-7n_8zL2ts,5539
@@ -154,7 +154,7 @@ synapse/config/oidc.py,sha256=LJs_H1B_gsN8q6Ibd60HTVNLr5vOzFHrCAk9WpS9P-k,20052
154
154
  synapse/config/_base.py,sha256=nU8YNC_ulDAxjpSPBJtjk8CCyV8PSXHGE9_fiLeuWus,39246
155
155
  synapse/config/metrics.py,sha256=A7A2YpOcBVsAxYT1L54r0pkXJyGLEuvDNl9i5ZueS-I,2764
156
156
  synapse/config/server.py,sha256=OjqiNRcm_xAXN_pk7sepd1D01FVRZkRa8ORT0IsCTvA,43741
157
- synapse/config/experimental.py,sha256=0PKcAQtMMzvp48WO-W0NzeIoIVY8Us6jqB48vTbT_3s,23391
157
+ synapse/config/experimental.py,sha256=c2ZMO1ApocXAIE0ser6cLsNpzEJ3zRfqAVWW4VsWwB0,23182
158
158
  synapse/config/ratelimiting.py,sha256=_97HNDT_WdDPXqJrlqPBNxpK7VpWZU2KMZTvSDqG-W8,8655
159
159
  synapse/config/homeserver.py,sha256=22RCwv4f5oJX_Sjj3gtQ_ryqYavvnF1GfhYFXyK-Qrc,4713
160
160
  synapse/config/room_directory.py,sha256=td6bghPpyv9EJKMR0W1UQwshg1ne6DU17JB_U6BusME,5475
@@ -206,7 +206,7 @@ synapse/_scripts/move_remote_media_to_new_store.py,sha256=VOGFBrZM3qBW4ysmdD8XW9
206
206
  synapse/_scripts/export_signing_key.py,sha256=i-7-vXYNpWRUvPJZNGcWgZ78pVNtHcd-j5VKI8JP9wk,2831
207
207
  synapse/_scripts/update_synapse_database.py,sha256=RGj8-lFjFB74WgUjTZXi-zkGcMWYR10eyg2GtMJ1YFQ,4005
208
208
  synapse/_scripts/register_new_matrix_user.py,sha256=CIdZpokRTis07Jw3SyUeH3WX-zPBJLEHh_4Gs_NSwbs,10757
209
- synapse/_scripts/hash_password.py,sha256=umsXOUS2Tb1TZsn5xBKySA8cPgRJOT1_H8nqUmyAO1w,2174
209
+ synapse/_scripts/hash_password.py,sha256=m6NTSEkFMyvUc4bEBtRGpF-fUBZKPmL1slrVrqKQU14,2621
210
210
  synapse/_scripts/generate_config.py,sha256=KaYWiSVP50PQnhDvrfW6iKiIsPDn_PeAKnm43Tsklqo,2336
211
211
  synapse/_scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
212
212
  synapse/_scripts/synapse_port_db.py,sha256=lrXRqYTd2T3eWJb7lHT4ZufXHvf3dWOepQ7n6Dp0O1c,56646
@@ -828,7 +828,7 @@ synapse/api/auth/internal.py,sha256=qn6RJCPRvTv9bTTFDwVW7KdRiDgbidQMM9DAknbl-Bo,
828
828
  synapse/api/auth/mas.py,sha256=mRjT9dXcELdypXS8VR0uE2jPKv_shpuq3BvtfyleTDw,16143
829
829
  synapse/api/auth/__init__.py,sha256=DR8l59rRPhC_SIQshcqGgzDfECTTt9diw5R3Y55ooOg,7007
830
830
  synapse/api/auth/msc3861_delegated.py,sha256=SfuEl0oZX4CGIRir6liPDsA2JowdhYt6XwYweNBFiM0,24162
831
- synapse/api/auth/base.py,sha256=3mERbu-n4LHBqIDBr32r3v9urEu_S3XNOYEQexDwi48,15563
831
+ synapse/api/auth/base.py,sha256=pEGeMnlzuzM8sngb_do5MdcSBQWZZmiL6CIwF4Y1FlA,15548
832
832
  synapse/replication/__init__.py,sha256=5DWi14gUO6wonAMLxJX7fev_idjDNPLvKGXEQ5IZeDg,705
833
833
  synapse/replication/tcp/handler.py,sha256=mCqEbRsy9Q4TgUcEcMUJZd5Mben3hlp5kRf1F1XzNgg,35312
834
834
  synapse/replication/tcp/protocol.py,sha256=NPcn8HEgH_A5h6Qfal09OiTaZNQmDpVdoOlC0FLqsiE,20624
@@ -873,7 +873,7 @@ synapse/server_notices/resource_limits_server_notices.py,sha256=VpFHZn1DTkpmVjSK
873
873
  synapse/server_notices/worker_server_notices_sender.py,sha256=SYuUXW1yYSIO1bEvaRKXD8DPdCVJ3hDbzrAaDBD50Qo,1388
874
874
  synapse/server_notices/server_notices_manager.py,sha256=pGqkoJrmOGpx5rjL0W0yJ151YesdZP9_dgM3Vzy9vDY,14620
875
875
  synapse/handlers/sync.py,sha256=di99Dk_f8KQmDN0WZiFvn0vPn2jQ0N5YmH3wJqiFBSw,132288
876
- synapse/handlers/auth.py,sha256=9QcBvL7FCi0SBA5ipJ31HsXunmRPXj8lNO7LtNRqylo,99772
876
+ synapse/handlers/auth.py,sha256=MtwCo5_HDILviQdHtg6WEz2hHtLKe5qhDPf8jDyMAso,100948
877
877
  synapse/handlers/oidc.py,sha256=h6Xn5-C_rnD-4IvCu4Lp_sAPKBOskf4WFaLfAOZezcw,71896
878
878
  synapse/handlers/push_rules.py,sha256=WkYG-vbbavU8V-pKuWSdwMQLEkHupvuCJIXqS4SpRFI,6062
879
879
  synapse/handlers/e2e_keys.py,sha256=OOGG7GVdNTrRfmwYM5GnqYYC7BFFwDtNkkDqSCzMpbg,75373
@@ -988,7 +988,7 @@ synapse/rest/client/relations.py,sha256=gL4i5Jfla73MYztfUH4vYwY1Th67iSut7UCrJ9Y4
988
988
  synapse/rest/client/account_data.py,sha256=dRov8NQ8caBi0OgYcxcAUWV9Zcu4QhEm0ne0v_tQG8Q,11359
989
989
  synapse/rest/client/matrixrtc.py,sha256=sOXvAs_fr3Z3UbsUjuQqlV2RfGyc6oySQN8g57ebbus,1712
990
990
  synapse/rest/client/__init__.py,sha256=pGyU2T0uOe01gjI70J92qseRxU5TIhnR2bHI1d-7mWE,728
991
- synapse/rest/client/keys.py,sha256=4AP1FAwWiOfXAHOtA5BBV9DbHy6udkrD3PHwqH1Rpcc,25452
991
+ synapse/rest/client/keys.py,sha256=b-jadOWP8v0P2MIGmivUGx-a0pVC7dB4CF3A8XdXhYI,25311
992
992
  synapse/rest/client/presence.py,sha256=D7gL_Q4QBWs0og0T5rbW3BJ9xsaWCXHhPYFkW05Uyac,4559
993
993
  synapse/rest/client/read_marker.py,sha256=l6My_HOnHhhr1t-O7mKR3TlQZ4Uzc8N1T_vO-eaQupU,3693
994
994
  synapse/rest/client/room_keys.py,sha256=rRTI8O4gfjzElgJgyOpLEUhBYXo9UPjkPKP0nqX43UA,15462
@@ -1006,7 +1006,7 @@ synapse/rest/client/sendtodevice.py,sha256=cFYzZ0o0tvsPK2Ri1SHb65TWabUjkpw7p5zBO
1006
1006
  synapse/rest/client/directory.py,sha256=P12dOFUFXYUDJSBwpBpHI_ry-c-m3sDrihpnqeNMI0s,7395
1007
1007
  synapse/rest/client/thread_subscriptions.py,sha256=8Ww79FFsZTN1ExaUBOB07qhlPIeC87uoVhBwWmZqUB0,9055
1008
1008
  synapse/rest/client/login_token_request.py,sha256=iG2GE6ueI_t9syphFxJRdamkwpC3QcF1Oxaq2rnqLqg,4284
1009
- synapse/rest/client/devices.py,sha256=fSKSBB3FitAWbZF-psmBBAXi9iw8JAgGb-thdZ1g-e8,19533
1009
+ synapse/rest/client/devices.py,sha256=29kauab4ELBxD7CQiZCkJoJddeOtb7p59z8f8N_mtpA,19377
1010
1010
  synapse/rest/client/thirdparty.py,sha256=dohbEvyCtljZlVhiCHB2Hcz-ffLZUEX1A7qiW6dEEX0,4223
1011
1011
  synapse/rest/client/openid.py,sha256=reW553DzSPaYANiGok1tAcvDDq6XMqEywHnQBSQZirQ,3440
1012
1012
  synapse/rest/client/room.py,sha256=kvpwLLkMCqRNgyeedTkRs533_rlYAINso4AyZOW5nFA,59712
@@ -73,8 +73,18 @@ def main() -> None:
73
73
 
74
74
  pw = unicodedata.normalize("NFKC", password)
75
75
 
76
+ bytes_to_hash = pw.encode("utf8") + password_pepper.encode("utf8")
77
+ if len(bytes_to_hash) > 72:
78
+ # bcrypt only looks at the first 72 bytes
79
+ print(
80
+ f"Password + pepper is too long ({len(bytes_to_hash)} bytes); truncating to 72 bytes for bcrypt. "
81
+ "This is expected behaviour and will not affect a user's ability to log in. 72 bytes is "
82
+ "sufficient entropy for a password."
83
+ )
84
+ bytes_to_hash = bytes_to_hash[:72]
85
+
76
86
  hashed = bcrypt.hashpw(
77
- pw.encode("utf8") + password_pepper.encode("utf8"),
87
+ bytes_to_hash,
78
88
  bcrypt.gensalt(bcrypt_rounds),
79
89
  ).decode("ascii")
80
90
 
synapse/api/auth/base.py CHANGED
@@ -302,12 +302,9 @@ class BaseAuth:
302
302
  (the user_id URI parameter allows an application service to masquerade
303
303
  any applicable user in its namespace)
304
304
  - what device the application service should be treated as controlling
305
- (the device_id[^1] URI parameter allows an application service to masquerade
305
+ (the device_id URI parameter allows an application service to masquerade
306
306
  as any device that exists for the relevant user)
307
307
 
308
- [^1] Unstable and provided by MSC3202.
309
- Must use `org.matrix.msc3202.device_id` in place of `device_id` for now.
310
-
311
308
  Returns:
312
309
  the application service `Requester` of that request
313
310
 
@@ -319,7 +316,8 @@ class BaseAuth:
319
316
  - The returned device ID, if present, has been checked to be a valid device ID
320
317
  for the returned user ID.
321
318
  """
322
- DEVICE_ID_ARG_NAME = b"org.matrix.msc3202.device_id"
319
+ # TODO: We can drop unstable support after 2026-01-01 (couple months after stable support)
320
+ UNSTABLE_DEVICE_ID_ARG_NAME = b"org.matrix.msc3202.device_id"
323
321
 
324
322
  app_service = self.store.get_app_service_by_token(access_token)
325
323
  if app_service is None:
@@ -341,13 +339,11 @@ class BaseAuth:
341
339
  else:
342
340
  effective_user_id = app_service.sender
343
341
 
344
- effective_device_id: Optional[str] = None
345
-
346
- if (
347
- self.hs.config.experimental.msc3202_device_masquerading_enabled
348
- and DEVICE_ID_ARG_NAME in request.args
349
- ):
350
- effective_device_id = request.args[DEVICE_ID_ARG_NAME][0].decode("utf8")
342
+ effective_device_id_args = request.args.get(
343
+ b"device_id", request.args.get(UNSTABLE_DEVICE_ID_ARG_NAME)
344
+ )
345
+ if effective_device_id_args:
346
+ effective_device_id = effective_device_id_args[0].decode("utf8")
351
347
  # We only just set this so it can't be None!
352
348
  assert effective_device_id is not None
353
349
  device_opt = await self.store.get_device(
@@ -359,6 +355,8 @@ class BaseAuth:
359
355
  f"Application service trying to use a device that doesn't exist ('{effective_device_id}' for {effective_user_id})",
360
356
  Codes.UNKNOWN_DEVICE,
361
357
  )
358
+ else:
359
+ effective_device_id = None
362
360
 
363
361
  return create_requester(
364
362
  effective_user_id, app_service=app_service, device_id=effective_device_id
synapse/app/_base.py CHANGED
@@ -64,7 +64,6 @@ from twisted.web.resource import Resource
64
64
  import synapse.util.caches
65
65
  from synapse.api.constants import MAX_PDU_SIZE
66
66
  from synapse.app import check_bind_error
67
- from synapse.app.phone_stats_home import start_phone_stats_home
68
67
  from synapse.config import ConfigError
69
68
  from synapse.config._base import format_config_error
70
69
  from synapse.config.homeserver import HomeServerConfig
@@ -592,9 +591,9 @@ async def start(hs: "HomeServer", freeze: bool = True) -> None:
592
591
  # we're not using systemd.
593
592
  sdnotify(b"RELOADING=1")
594
593
 
595
- for sighup_callbacks in _instance_id_to_sighup_callbacks_map.values():
596
- for func, args, kwargs in sighup_callbacks:
597
- func(*args, **kwargs)
594
+ for sighup_callbacks in _instance_id_to_sighup_callbacks_map.values():
595
+ for func, args, kwargs in sighup_callbacks:
596
+ func(*args, **kwargs)
598
597
 
599
598
  sdnotify(b"READY=1")
600
599
 
@@ -683,15 +682,6 @@ async def start(hs: "HomeServer", freeze: bool = True) -> None:
683
682
  if hs.config.worker.run_background_tasks:
684
683
  hs.start_background_tasks()
685
684
 
686
- # TODO: This should be moved to same pattern we use for other background tasks:
687
- # Add to `REQUIRED_ON_BACKGROUND_TASK_STARTUP` and rely on
688
- # `start_background_tasks` to start it.
689
- await hs.get_common_usage_metrics_manager().setup()
690
-
691
- # TODO: This feels like another pattern that should refactored as one of the
692
- # `REQUIRED_ON_BACKGROUND_TASK_STARTUP`
693
- start_phone_stats_home(hs)
694
-
695
685
  if freeze:
696
686
  # We now freeze all allocated objects in the hopes that (almost)
697
687
  # everything currently allocated are things that will be used for the
synapse/app/homeserver.py CHANGED
@@ -430,9 +430,7 @@ def setup(
430
430
 
431
431
  await _base.start(hs, freeze)
432
432
 
433
- # TODO: This should be moved to `SynapseHomeServer.start_background_tasks` (not
434
- # `HomeServer.start_background_tasks`) (this way it matches the behavior of only
435
- # running on `main`)
433
+ # TODO: Feels like this should be moved somewhere else.
436
434
  hs.get_datastores().main.db_pool.updates.start_doing_background_updates()
437
435
 
438
436
  # Register a callback to be invoked once the reactor is running
@@ -412,11 +412,6 @@ class ExperimentalConfig(Config):
412
412
  "msc2409_to_device_messages_enabled", False
413
413
  )
414
414
 
415
- # The portion of MSC3202 which is related to device masquerading.
416
- self.msc3202_device_masquerading_enabled: bool = experimental.get(
417
- "msc3202_device_masquerading", False
418
- )
419
-
420
415
  # The portion of MSC3202 related to transaction extensions:
421
416
  # sending device list changes, one-time key counts and fallback key
422
417
  # usage to application services.
synapse/handlers/auth.py CHANGED
@@ -1683,8 +1683,22 @@ class AuthHandler:
1683
1683
  # Normalise the Unicode in the password
1684
1684
  pw = unicodedata.normalize("NFKC", password)
1685
1685
 
1686
+ bytes_to_hash = pw.encode(
1687
+ "utf8"
1688
+ ) + self.hs.config.auth.password_pepper.encode("utf8")
1689
+ if len(bytes_to_hash) > 72:
1690
+ # bcrypt only looks at the first 72 bytes.
1691
+ #
1692
+ # Note: we explicitly DO NOT log the length of the user's password here.
1693
+ logger.debug(
1694
+ "Password + pepper is too long; truncating to 72 bytes for bcrypt. "
1695
+ "This is expected behaviour and will not affect a user's ability to log in. 72 bytes is "
1696
+ "sufficient entropy for a password."
1697
+ )
1698
+ bytes_to_hash = bytes_to_hash[:72]
1699
+
1686
1700
  return bcrypt.hashpw(
1687
- pw.encode("utf8") + self.hs.config.auth.password_pepper.encode("utf8"),
1701
+ bytes_to_hash,
1688
1702
  bcrypt.gensalt(self.bcrypt_rounds),
1689
1703
  ).decode("ascii")
1690
1704
 
@@ -1706,9 +1720,20 @@ class AuthHandler:
1706
1720
  def _do_validate_hash(checked_hash: bytes) -> bool:
1707
1721
  # Normalise the Unicode in the password
1708
1722
  pw = unicodedata.normalize("NFKC", password)
1723
+ password_pepper = self.hs.config.auth.password_pepper
1724
+
1725
+ bytes_to_hash = pw.encode("utf8") + password_pepper.encode("utf8")
1726
+ if len(bytes_to_hash) > 72:
1727
+ # bcrypt only looks at the first 72 bytes
1728
+ logger.debug(
1729
+ "Password + pepper is too long; truncating to 72 bytes for bcrypt. "
1730
+ "This is expected behaviour and will not affect a user's ability to log in. 72 bytes is "
1731
+ "sufficient entropy for a password."
1732
+ )
1733
+ bytes_to_hash = bytes_to_hash[:72]
1709
1734
 
1710
1735
  return bcrypt.checkpw(
1711
- pw.encode("utf8") + self.hs.config.auth.password_pepper.encode("utf8"),
1736
+ bytes_to_hash,
1712
1737
  checked_hash,
1713
1738
  )
1714
1739
 
@@ -62,7 +62,7 @@ class CommonUsageMetricsManager:
62
62
  """
63
63
  return await self._collect()
64
64
 
65
- async def setup(self) -> None:
65
+ def setup(self) -> None:
66
66
  """Keep the gauges for common usage metrics up to date."""
67
67
  self._hs.run_as_background_process(
68
68
  desc="common_usage_metrics_update_gauges",
@@ -112,7 +112,7 @@ class DeleteDevicesRestServlet(RestServlet):
112
112
  else:
113
113
  raise e
114
114
 
115
- if requester.app_service and requester.app_service.msc4190_device_management:
115
+ if requester.app_service:
116
116
  # MSC4190 can skip UIA for this endpoint
117
117
  pass
118
118
  else:
@@ -192,7 +192,7 @@ class DeviceRestServlet(RestServlet):
192
192
  else:
193
193
  raise
194
194
 
195
- if requester.app_service and requester.app_service.msc4190_device_management:
195
+ if requester.app_service:
196
196
  # MSC4190 allows appservices to delete devices through this endpoint without UIA
197
197
  # It's also allowed with MSC3861 enabled
198
198
  pass
@@ -227,7 +227,7 @@ class DeviceRestServlet(RestServlet):
227
227
  body = parse_and_validate_json_object_from_request(request, self.PutBody)
228
228
 
229
229
  # MSC4190 allows appservices to create devices through this endpoint
230
- if requester.app_service and requester.app_service.msc4190_device_management:
230
+ if requester.app_service:
231
231
  created = await self.device_handler.upsert_device(
232
232
  user_id=requester.user.to_string(),
233
233
  device_id=device_id,
@@ -543,15 +543,11 @@ class SigningKeyUploadServlet(RestServlet):
543
543
  if not keys_are_different:
544
544
  return 200, {}
545
545
 
546
- # MSC4190 can skip UIA for replacing cross-signing keys as well.
547
- is_appservice_with_msc4190 = (
548
- requester.app_service and requester.app_service.msc4190_device_management
549
- )
550
-
551
546
  # The keys are different; is x-signing set up? If no, then this is first-time
552
547
  # setup, and that is allowed without UIA, per MSC3967.
553
548
  # If yes, then we need to authenticate the change.
554
- if is_cross_signing_setup and not is_appservice_with_msc4190:
549
+ # MSC4190 can skip UIA for replacing cross-signing keys as well.
550
+ if is_cross_signing_setup and not requester.app_service:
555
551
  # With MSC3861, UIA is not possible. Instead, the auth service has to
556
552
  # explicitly mark the master key as replaceable.
557
553
  if self.hs.config.mas.enabled:
synapse/server.py CHANGED
@@ -62,6 +62,7 @@ from synapse.api.auth_blocking import AuthBlocking
62
62
  from synapse.api.filtering import Filtering
63
63
  from synapse.api.ratelimiting import Ratelimiter, RequestRatelimiter
64
64
  from synapse.app._base import unregister_sighups
65
+ from synapse.app.phone_stats_home import start_phone_stats_home
65
66
  from synapse.appservice.api import ApplicationServiceApi
66
67
  from synapse.appservice.scheduler import ApplicationServiceScheduler
67
68
  from synapse.config.homeserver import HomeServerConfig
@@ -643,6 +644,8 @@ class HomeServer(metaclass=abc.ABCMeta):
643
644
  for i in self.REQUIRED_ON_BACKGROUND_TASK_STARTUP:
644
645
  getattr(self, "get_" + i + "_handler")()
645
646
  self.get_task_scheduler()
647
+ self.get_common_usage_metrics_manager().setup()
648
+ start_phone_stats_home(self)
646
649
 
647
650
  def get_reactor(self) -> ISynapseReactor:
648
651
  """
synapse/util/metrics.py CHANGED
@@ -323,9 +323,13 @@ class DynamicCollectorRegistry(CollectorRegistry):
323
323
  if server_hooks.get(metric_name) is not None:
324
324
  # TODO: This should be an `assert` since registering the same metric name
325
325
  # multiple times will clobber the old metric.
326
- # We currently rely on this behaviour as we instantiate multiple
327
- # `SyncRestServlet`, one per listener, and in the `__init__` we setup a new
328
- # LruCache.
326
+ #
327
+ # We currently rely on this behaviour in a few places:
328
+ # - We instantiate multiple `SyncRestServlet`, one per listener, and in the
329
+ # `__init__` we setup a new `LruCache`.
330
+ # - We instantiate multiple `ApplicationService` (one per configured
331
+ # application service) which use the `@cached` decorator on some methods.
332
+ #
329
333
  # Once the above behaviour is changed, this should be changed to an `assert`.
330
334
  logger.error(
331
335
  "Metric named %s already registered for server %s",