-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Remove backwards-compatibility code for access tokens without an associated device #11829
Comments
We don't know what the situation may be like on other servers, so realistically we'd have to have some kind of migration to take care of this. For example, one idea might be to assign random device IDs to IDless devices/access tokens on-demand. |
I'd be up for just invalidating such access tokens (requiring the holders of them to log in again). We can include a bit of SQL in the upgrade notes to let people figure out if they are affected. |
@richvdh Likewise. Unfortunately, one of the abuse tokens was used yesterday, so we first need to figure out how these are being created. It appears that access tokens without a device can still be created via the User Login Admin API, so that may be what's happening here. synapse/synapse/rest/admin/users.py Lines 939 to 944 in 7a1cefc
It'd be pretty easy to start generating device IDs, but we'd need to figure out what bit of our current infrastructure is using this. Other quirks about this Admin API: you cannot use this endpoint to generate an access token for the current account. |
It might just be very old? |
Definitely a possibility. We don't record when an access token was created alas. |
I just created an admin account through the EMS dashboard and it came back with an access token, but no device ID. It is presumably using the User Login Admin API to retrieve that access token. |
For the record, I would also like to mandate |
I ran into this while implementing #11215.
Before #949, it was possible to have access tokens that were not associated with a device. This has now been deprecated for 5 years.
This possibility has now crept across the codebase, as we've marked
device_id
asOptional
in many places, including:synapse/synapse/handlers/sync.py
Lines 87 to 93 in d4e6f35
This makes little sense, as you're expected to have a device if you're calling
/sync
. Much of the/sync
handling code assumes you have a device, and would logically fail if the user didn't:synapse/synapse/storage/databases/main/deviceinbox.py
Lines 199 to 201 in 3e0536c
Passing
device_id=None
to this function always results in zero to-device messages being returned.Is there anything holding us back (old access tokens?) from marking device IDs as
str
, notOptional[str]
?Edit: There are currently
64
entries in theaccess_tokens
table on matrix.org that do not have an associated device ID. They are all either abuse, or go neb...The text was updated successfully, but these errors were encountered: