ipfs / ipfs-companion

Browser extension that simplifies access to IPFS resources on the web
https://docs.ipfs.tech/install/ipfs-companion/
Creative Commons Zero v1.0 Universal
2.04k stars 323 forks source link

Disable Brave redirect when Companion global redirect is enabled #1301

Open lidel opened 8 months ago

lidel commented 8 months ago

This is MVP subset of https://github.com/ipfs/ipfs-companion/issues/1281 requested by the Brave team.

Problem

Currently, Companion logic is clashing with Brave logic when both have redirects enabled.

Preconditions:

"Method to resolve IPFS resources": Brave local IPFS node "Automatically redirect requests for IPFS network resources to the configured gateway.": is ON IPFS daemon is started, but repository is cleaned Network access is blocked

Steps:

  1. You try to open the address: https://dweb.link/ipfs/bafkreiedqfhqvarz2y4c2s3vrbrcq427sawhzbewzksegopavnmwbz4zyq
  2. Brave tries to redirect request throug the local node: https://localhost:45008/ipfs/bafkreiedqfhqvarz2y4c2s3vrbrcq427sawhzbewzksegopavnmwbz4zyq

Expected results: The request: https://localhost:45008/ipfs/bafkreiedqfhqvarz2y4c2s3vrbrcq427sawhzbewzksegopavnmwbz4zyq is failed, infobar with proposition to load original URL (i.e. from step1) is shown

Actual result: In case of IPFS Companion is enabled: It redirects us to ipfs://bafkreiedqfhqvarz2y4c2s3vrbrcq427sawhzbewzksegopavnmwbz4zyq as well, and redirect happens again once we try to redirect to original URL. So we never can redirect back to original URL Sometimes I even observed redirect loop (edited)

Proposed fix

The provisional fix is to periodically check if all below are true:

If true, we want to

lidel commented 8 months ago

@whizzzkid fysa I've filled this as a smaller scope of work when compared to #1281 to unblock Brave.

Does this sound sensible, or is there a better way you see to avoid redirect clash?

whizzzkid commented 8 months ago

@lidel thanks, yes this sounds reasonable, one thing I'm not really sure about is why does this need to be "periodically" can't they not persist these values? Also, there is a priority flag for redirect rules. I'm guessing those are being ignored.

lidel commented 8 months ago

re: periodically: Brave user can toggle Brave redirect from OFF to ON again via brave://settings etc, but maybe it will be enough if we check when that URI is opened and on extension start?

Those are different than web extension ones, so priority is most likely ignored.