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

Even when explicitely set, the subdomain gateway config still include ipfs.io, gateway.ipfs.io and dweb.link #7317

Closed
MichaelMure opened this issue May 14, 2020 · 9 comments · Fixed by #8069
Assignees
Labels
exp/novice Someone with a little familiarity can pick up kind/enhancement A net-new feature or improvement to an existing feature P2 Medium: Good to have, but can wait until someone steps up status/in-progress In progress

Comments

@MichaelMure
Copy link
Contributor

go-ipfs v0.5.1

https://github.com/ipfs/go-ipfs/blob/master/core/corehttp/hostname.go#L37-L42

It seems ok to me to implicitly accept localhost when no public gateway is defined but including the Protocol Labs gateway as well seems too much. At least when explicitly defined, those should not be included as well.

@MichaelMure MichaelMure added kind/bug A bug in existing code (including security flaws) need/triage Needs initial labeling and prioritization labels May 14, 2020
@Stebalien
Copy link
Member

Isn't this the same as #7281?

@MichaelMure
Copy link
Contributor Author

It's related but not the same.

#7281 is about the default config being not explicit and a surprising user experience

This issue is about the config not being honored as it should (extra gateways are added without the possibility to avoid it).

@Stebalien
Copy link
Member

Ah, got it.

So, in this case, you can disable these gateways, but you need to explicitly map "domain": null (documented in docs/config.md but a bit hard to find...). The idea is that this lets us extend/change this list in the future if necessary, even when the user wants to add additional gateways.

A better solution may be to add a DefaultPublicGateways: bool flag. Thoughts @MichaelMure & @lidel?

@lidel
Copy link
Member

lidel commented May 14, 2020

AFAIK those implicit entries were included so canonical gateways work in HTTP Proxy mode:

$ chromium --user-data-dir=$(mktemp -d) --proxy-server="http://127.0.0.1:8080" "http://dweb.link/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR"

..but I don't think many people will use it due to HSTS limitations, nor care if we remove them and ask for manual add if someone wants to use HTTP proxy.

If anything, just remove them, adding additional flag would be an overkill.

@MichaelMure
Copy link
Contributor Author

you need to explicitly map "domain": null (documented in docs/config.md but a bit hard to find...)

Hooo, I see. Well you still need to know that they are there in the first place (that is, read the code) ;)

What about simply doing something like:

diff --git a/core/corehttp/hostname.go b/core/corehttp/hostname.go
index 143435106..5eb25d686 100644
--- a/core/corehttp/hostname.go
+++ b/core/corehttp/hostname.go
@@ -55,20 +55,26 @@ func HostnameOption() ServeOption {
                if err != nil {
                        return nil, err
                }
-               knownGateways := make(
-                       map[string]config.GatewaySpec,
-                       len(defaultKnownGateways)+len(cfg.Gateway.PublicGateways),
-               )
-               for hostname, gw := range defaultKnownGateways {
-                       knownGateways[hostname] = gw
-               }
-               for hostname, gw := range cfg.Gateway.PublicGateways {
-                       if gw == nil {
-                               // Allows the user to remove gateways but _also_
-                               // allows us to continuously update the list.
-                               delete(knownGateways, hostname)
-                       } else {
-                               knownGateways[hostname] = *gw
+
+               var knownGateways map[string]config.GatewaySpec
+               if len(cfg.Gateway.PublicGateways) > 0 {
+                       knownGateways = make(
+                               map[string]config.GatewaySpec,
+                               len(cfg.Gateway.PublicGateways),
+                       )
+
+                       for hostname, gw := range cfg.Gateway.PublicGateways {
+                               if gw != nil {
+                                       knownGateways[hostname] = *gw
+                               }
+                       }
+               } else {
+                       knownGateways := make(
+                               map[string]config.GatewaySpec,
+                               len(defaultKnownGateways),
+                       )
+                       for hostname, gw := range defaultKnownGateways {
+                               knownGateways[hostname] = gw
                        }
                }

@Stebalien
Copy link
Member

Yeah, just dropping the defaults (except localhost) sounds reasonable).

@Stebalien Stebalien added exp/novice Someone with a little familiarity can pick up kind/enhancement A net-new feature or improvement to an existing feature P2 Medium: Good to have, but can wait until someone steps up and removed kind/bug A bug in existing code (including security flaws) need/triage Needs initial labeling and prioritization labels May 22, 2020
@Stebalien Stebalien added the status/in-progress In progress label May 22, 2020
@lidel
Copy link
Member

lidel commented May 26, 2020

cc @mburns in case removal of implicit config impacts dweb.link deployment scripts

@mburns
Copy link
Contributor

mburns commented May 26, 2020

@lidel we were explicit just in case a change like this landed. Thanks for the heads up. 🚢

@BigLep
Copy link
Contributor

BigLep commented Apr 12, 2021

@lidel : please check if this can be closed out or if there are any updates needed.

lidel added a commit that referenced this issue Apr 12, 2021
This closes #7317 by removing hardcoded PL hostnames from default
config, making the localhost the only implicit gateway hostname.
@lidel lidel assigned lidel and unassigned MichaelMure Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exp/novice Someone with a little familiarity can pick up kind/enhancement A net-new feature or improvement to an existing feature P2 Medium: Good to have, but can wait until someone steps up status/in-progress In progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants