Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove backwards-compatibility code for access tokens without an associated device #11829

Open
matrixbot opened this issue Dec 19, 2023 · 0 comments
Labels

Comments

@matrixbot
Copy link
Collaborator

matrixbot commented Dec 19, 2023

This issue has been migrated from #11829.


I ran into this while implementing #11215.

Before matrix-org/synapse#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 as Optional in many places, including:

https://github.com/matrix-org/synapse/blob/d4e6f358b64b340a670e4f7496a530c11a715920/synapse/handlers/sync.py#L87-L93

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:

https://github.com/matrix-org/synapse/blob/3e0536cd2afb5a640619bd872fc27b068ec3eb9b/synapse/storage/databases/main/deviceinbox.py#L199-L201

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, not Optional[str]?

Edit: There are currently 64 entries in the access_tokens table on matrix.org that do not have an associated device ID. They are all either abuse, or go neb...

@matrixbot matrixbot changed the title Dummy issue Remove backwards-compatibility code for access tokens without an associated device Dec 21, 2023
@matrixbot matrixbot reopened this Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant