GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Migrate Matrix media to authenticated endpoints before the Synapse flag flips · Issue #1487 · OpenResilienceInitiative/ORISO-Frontend

Migrate Matrix media to authenticated endpoints before the Synapse flag flips #1487

New issue
Copy link
New issue
Copy link
Open
Open
Migrate Matrix media to authenticated endpoints before the Synapse flag flips#1487
Copy link

Description

@Storypapst
Storypapst
opened on Sep 19, 2026
Issue body actions

Affected repos: ORISO-Frontend, ORISO-UserService, ORISO-Helm

Why

ORISO is switching Synapse's enable_authenticated_media to true (owner decision, 2026-09-19 — the counsellor avatar has to reach the call grid, and authenticated media is what makes a picture in Synapse media defensible at all). Flipping it retires the legacy unauthenticated media endpoints, and this app still calls them.

Six unsafe call sites, from an inventory of all four repos read at origin/dev:

Repo Call site What it does
Frontend src/utils/matrixTimelineEventFormatter.ts:30 produces the media URL — the single producer
Frontend src/components/message/MessageAttachment.tsx:112-119, :205, :282, :375 four consumers
UserService MatrixMediaClient.java:24-25 (used at :78-105) → MatrixSynapseService.java:1423 → MatrixMessageController.java:399 one endpoint constant, three locations

ORISO-ElementCall is already safe — Avatar.tsx:55-63 passes useAuthentication: true and :110-117 attaches the bearer and hands a blob URL to the image. It is also the in-house reference implementation for the fix. ORISO-Admin has no Matrix code at all.

matrix-js-sdk is pinned at 38.4.0 in this repo and does support authenticated URLs. The capability is there and unused: the code hand-builds the path string instead.

The risk that decides how we verify this

The flip is self-concealing. Grandfathering is decided per media row at upload time, so media already in existing chats keeps working on the legacy path permanently. A post-flip smoke test on an existing conversation therefore passes. Only files uploaded after the flip fail — with 404 M_NOT_FOUND, which is indistinguishable from "the file was deleted".

The deploy looks clean, and then over the following days every new attachment, image and voice message silently arrives broken in counselling chats, and it gets reported as "the file disappeared", not as a regression. So: re-verification is only valid with freshly uploaded files.

The sharpest instance

MessageAttachment.tsx:112-119 fetches the E2EE ciphertext through fetchData, and fetchData (src/api/fetchData.ts:130-136) attaches the Keycloak access token from the keycloak cookie — not the Matrix one:

const accessToken = getValueFromCookie('keycloak');
const authorization = !skipAuth && accessToken ? { Authorization: `Bearer ${accessToken}` } : null;

This works today only because the legacy media endpoint ignores authorization entirely. With E2EE permanently on, this is the path almost every attachment takes. It is therefore broken in two independent ways — wrong path and wrong token — and a path-only fix will not repair it.

What to build

  • An authenticated-fetch→blob-URL helper, modelled on ORISO-ElementCall's Avatar.tsx:99-128.
  • Rewire the producer and all four consumers to the /_matrix/client/v1/media/... endpoints with the Matrix access token.
  • Repoint MatrixMediaClient.java:24-25 in UserService to the v1 path — its bearer header is already correct.
  • Update the tests that hard-code the legacy path.

Order — and there is no dual-path window

/_matrix/client/v1/media/download already works today with the flag still false, and serves grandfathered media too. So the migration is one-directional and nothing needs both generations live at once: migrate and verify while the flag is still off, then flip. Rollback is cheap — setting the flag back to false restores legacy access even for media already marked.

The Helm change (templates/matrix/matrix-configmaps.yaml:149, plus pinning allow_per_room_profiles) is shared cluster configuration and is coordinated separately, gated on this being deployed. No ingress change is needed: the /_matrix prefix rule covers both generations.

Goal

Every Matrix media fetch in ORISO uses an authenticated endpoint with the correct token, verified with freshly uploaded files, so that flipping the Synapse flag changes nothing an advice seeker or counsellor can notice.

Acceptance criteria:

  • No legacy /_matrix/media/... path remains in Frontend or UserService.
  • The attachment path sends the Matrix token, not the Keycloak token.
  • An encrypted attachment uploaded after the migration downloads and decrypts.
  • Image, file and voice-message attachments each verified with a fresh upload.
  • Tests no longer hard-code a legacy media path.

Reviewer test plan

  • With the flag still false: upload an image, a file and a voice message in a counselling chat, reload, and open each one.
  • Repeat with an E2EE room — the ciphertext fetch must succeed and decrypt.
  • Confirm the network tab shows /_matrix/client/v1/media/... and a Matrix bearer token, not the Keycloak one.
  • Explicitly do NOT accept an existing old attachment as evidence — grandfathered media proves nothing here.

Part of OpenResilienceInitiative/ORISO-UserService#1198. Inventory: 0 - Docs/research/2026-09-19-authenticated-media-migration-inventory.md.

QA retest on Dev, 18 Nov 2026

Homer sent a fresh synthetic PNG through the normal Dev composer in Case 14. Lisa saw it in the same case and a normal media action returned HTTP 200 on the client media route. The test did not produce a browser download event, so downloaded-byte identity is unverified. Voice, server-side consumers and the remaining acceptance matrix are open.

Current Dev follow-up with fresh App-TOTP: the asker used Download on the synthetic PNG uploaded after migration. The application-created download blob matched the original PNG byte for byte. The first probe of the inline preview had no blob. Other file kinds and a complete media matrix remain open.

Dev receipt: the recipient reopened the synthetic case and used the attachment action twice. A browser download was generated on the second activation and the PDF bytes exactly matched the synthetic original. Together with the fresh PNG byte comparison and the exact fresh voice event playback after reload, this completes the three media-kind criterion. The two-activation behavior, legacy upload route and remaining token-level checks stay open.

The exact v2.0.17 attachment regression supplied distinct synthetic Matrix and Keycloak credentials simultaneously and asserted that the request used the Matrix bearer and excluded the Keycloak credential. The release suite passed. Independent inspection of bearer provenance in a live browser request is still open.

Installed Dev browser network retest: the synthetic Case 14 PDF returned HTTP 200 via Matrix client v1 media. Its bearer matched a successful Matrix session request and differed from the bearer on the authenticated application user-data GET. The downloaded bytes matched the inert fixture. The token comparison stayed in memory and the receipt records only equality. The test reused the synthetic post-migration PDF from the earlier controlled upload.

Installed Dev configuration readback: enable_authenticated_media is true in both the Synapse ConfigMap and the file mounted in the running Synapse container. The remaining pre-flip false-flag reviewer check therefore cannot be verified on the current Dev runtime without a separate controlled environment. No flag or deployment was changed.

The accepted media samples were created during this QA run after the migration. On a repeat of the synthetic PDF download, the authenticated 200 response returned same-length bytes that differed from the original and did not have a PDF header. The normal download immediately returned the exact plaintext fixture. No media bytes were retained beyond the comparison and temporary download cleanup.

One-run Dev PDF verification joined the fresh Matrix send to the exact recipient row before and after reload. The authenticated download returned non-PDF wire bytes, and the browser output exactly matched the inert PDF. The send request did not use the m.room.encrypted event route. This proves file encryption and client decryption for that sample, while the separate encrypted-room repeat remains open.

An authenticated Matrix state read verified Megolm room encryption in exact Dreambau Case 14, where the fresh image, PDF and voice uploads were previously tested. The same PDF event was visible after reload, its authenticated wire bytes differed from the original, and its in-app download decrypted to byte-exact plaintext. A second scoped test room also reported Megolm. The earlier send-path observation alone did not determine room encryption. The false-flag test remains open.

Activity

  1. github-project-automation
    added this to ORISO Roadmapon Sep 19, 2026
  2. github-project-automation
    moved this to Backlog in ORISO Roadmapon Sep 19, 2026
  3. shazia-k
    added a commit that references this issue on Sep 22, 2026

    Merge pull request #1489 from OpenResilienceInitiative/fix/1487-authe…

    5a19952
  4. Storypapst
    added a commit that references this issue on Oct 8, 2026

    fix(matrix): fetch media over the authenticated endpoint with the Mat…

    3c75d93
  5. Storypapst
    moved this from Backlog to QA internal in ORISO Roadmapon Nov 4, 2026
  6. kiodreambau commented on Nov 18, 2026

    @kiodreambau
    kiodreambau
    on Nov 18, 2026
    Contributor
    More actions

    Release QA: all 21 targeted authenticated media, attachment and event formatter tests passed at df85ae9. The source audit still finds /_matrix/media/v3/upload in UserService, deliberately retained for upload, and legacy path strings in Frontend negative controls. Those findings distinguish the download migration from the literal no-legacy-path wording. The Dev downloaded-byte check and fresh file/voice acceptance remain open.

  7. kiodreambau commented on Nov 18, 2026

    @kiodreambau
    kiodreambau
    on Nov 18, 2026
    Contributor
    More actions

    Dev v2.0.17 file retest in the same verified two-account synthetic case. An inert PDF submitted through the normal attachment composer produced HTTP 200 on the legacy upload endpoint. The recipient browser did not show the exact filename with the sampled locator within 20 seconds, and no download was verified. The upload route observation concerns upload, while the existing successful PNG receipt proves the authenticated download path. The PDF and voice matrix remain open.

  8. kiodreambau commented on Nov 18, 2026

    @kiodreambau
    kiodreambau
    on Nov 18, 2026
    Contributor
    More actions

    Follow-up isolated the send from the upload. A second inert synthetic PDF in the same verified Dev case returned HTTP 200 on upload and HTTP 200 with an event ID on the subsequent Matrix room send. The sender rendered the exact filename. The independent recipient did not display that filename within 20 seconds. The PDF download/decryption checkpoint remains open. This confirms the server accepted the room send, but does not identify why the attachment was absent from the sampled recipient UI.

  9. kiodreambau commented on Nov 18, 2026

    @kiodreambau
    kiodreambau
    on Nov 18, 2026
    Contributor
    More actions

    Dev v2.0.17 synthetic voice-note follow-up with the same two-account case. The normal composer recorder accepted fake microphone audio, uploaded it (HTTP 200), and wrote the Matrix room event (HTTP 200 with an event ID). The independent recipient browser gained a visible playback control. Playback after reload and byte/decryption proof were not part of this run. The upload still used the legacy upload route.

  10. kiodreambau commented on Nov 18, 2026

    @kiodreambau
    kiodreambau
    on Nov 18, 2026
    Contributor
    More actions

    Dev v2.0.17 recipient readback in a fresh page of the same verified synthetic case: clicking the last visible voice player advanced the browser audio clock and produced HTTP 200 on the Matrix client media route. This proves that rendered voice audio can be fetched and played after a new page load. The playback probe selected the last player by position and did not bind it to the previous send event ID, so exact fresh-event playback remains unverified. The PDF delivery/download gap remains open.

  11. kiodreambau commented on Nov 18, 2026

    @kiodreambau
    kiodreambau
    on Nov 18, 2026
    Contributor
    More actions

    Exact fresh voice-message verification passed on installed Dev in the existing synthetic pair. The recorder sent a new event. The independent recipient matched that event's message row, reloaded, then activated the play button in the same exact row. The HTML audio clock advanced and the Matrix client-media download returned HTTP 200. Only match booleans are retained. The PDF delivery/download and legacy-upload checkpoints remain open.

  12. kiodreambau commented on Nov 18, 2026

    @kiodreambau
    kiodreambau
    on Nov 18, 2026
    Contributor
    More actions

    The event-ID-based PDF comparison confirms recipient delivery on the new attempt. Matrix accepted the send, the exact message row appeared before and after reload, and the reloaded row showed the expected filename and an action. The recipient observed HTTP 200 on the authenticated client media route. Clicking the action did not produce a Playwright download event in 10 seconds, so saved bytes are still unverified. This narrows the earlier filename-only misses; it does not establish that the earlier PDFs were lost.

  13. kiodreambau commented on Nov 18, 2026

    @kiodreambau
    kiodreambau
    on Nov 18, 2026
    Contributor
    More actions

    Release audit for the two literal “legacy path” criteria. Browser PDF and voice writes use the pinned Matrix SDK's v3 upload route. UserService MatrixMediaClient also deliberately keeps that upload route; its separate download method uses authenticated client v1. Frontend's remaining source literals are comments and negative-control tests. UserService tests also explicitly assert the retained upload route. The implemented migration covers media reads. The literal criteria about removing every legacy path and every hard-coded test occurrence still differ from that implementation and remain open.

  14. kiodreambau commented on Nov 19, 2026

    @kiodreambau
    kiodreambau
    on Nov 19, 2026
    Contributor
    More actions

    Exact Frontend v2.0.17 df85ae9, Node 22.23.3: all 21 tests across the three authenticated-media/formatter suites passed. Remaining Frontend production path literals are explanatory comments. The test literals actively model or reject legacy downloads. UserService a0ce7e32 still intentionally uses the v3 upload route. The literal no-legacy-path/test-text checkboxes remain open as written; the installed authenticated download evidence and true Synapse flag are unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Platform release

    None yet

    Projects

    • ORISO Roadmap
      Status
      QA internal
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.