Authenticated Media Support #51
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #31
History
Previously, all media uploaded to a Matrix server could be fetched via a public URL. If you know the media ID and can construct:
https://matrix.DOMAIN/_matrix/media/v1/download/SERVER_NAME/MEDIA_ID?allow_redirect=true)https://matrix.DOMAIN/_matrix/media/r0/thumbnail/SERVER_NAME/MEDIA_ID)Synapse now supports a new enable_authenticated_media configuration setting. When enabled:
Authorization: Bearer syn_...)The matrix.org homeserver has disabled unauthenticated media already.
What remains to follow is:
enable_authenticated_mediachanging (false->true) which will make many more servers start to use authenticated mediaHow this affects synapse-admin?
For now, synapse-admin is fine, but authenticated media is coming soon.
synapse-admin will still be able to access old media files via the old API endpoints, but new media will not be accessible.
User avatars
Avatar in the Users list (as well as user view pages) are currently loaded via the old thumbnail API (
/_matrix/media/r0/thumbnail/SERVER_NAME/MEDIA_ID), instead of the new one. This works for old media (which continues to be served on the old media endpoints URLs), but does not work for users who uploaded new avatars after Synapse'senable_authenticated_mediasetting was set totrueMedia
The user's media tab currently looks like this:
The icon on the left side is a button that opens the media in a new tab. It's very hard to see and click this icon (and most people will not even notice it), so it should be reworked.
Clicking this "view media" button right now leads to the old
/_matrix/media/v1/download/SERVER_NAME/MEDIA_ID?allow_redirect=trueendpoint. This only works for old media.For new media, the GET /_matrix/client/v1/media/download/{serverName}/{mediaId} API needs to be used.
What should we do?
We should switch all media access to the new endpoints. We don't need to worry if something is old media or new media. The new (authenticated) media endpoints will serve all media. We should stop using the old media endpoints completely.
Since the new authenticated media API URLs require an
AuthorizationHTTP header, you cannot use them directly in<img src=".." />and will need to fetch the media separately (while passing the access token).For the User's Media tab and its "view media" button, it probably means that opening it in a new tab will not be possible anymore and we'll need some kind of inline viewer or something. Here's some sample code:
Perhaps this way of adjusting the
href(well, `src) works with all media and we may be able to have a generic "download" button anyway?