kubo/core/corehttp
Lars Gierth 09937f84b6 gateway: enforce allowlist for path prefixes
The gateway accepts an X-Ipfs-Path-Prefix header,
and assumes that it is mounted in a reverse proxy
like nginx, at this path. Links in directory listings,
as well as trailing-slash redirects need to be rewritten
with that prefix in mind.

We don't want a potential attacker to be able to
pass in arbitrary path prefixes, which would end up
in redirects and directory listings, which is why
every prefix has to be explicitly allowed in the config.

Previously, we'd accept *any* X-Ipfs-Path-Prefix header.

Example:

We mount blog.ipfs.io (a dnslink page) at ipfs.io/blog.

nginx_ipfs.conf:

    location /blog/ {
        rewrite "^/blog(/.*)$" $1 break;
        proxy_set_header Host blog.ipfs.io;
        proxy_set_header X-Ipfs-Gateway-Prefix /blog;
        proxy_pass http://127.0.0.1:8080;
    }

.ipfs/config:

    "Gateway": {
        "PathPrefixes": ["/blog"],
        // ...
    },

dnslink:

    > dig TXT _dnslink.blog.ipfs.io
    dnslink=/ipfs/QmWcBjXPAEdhXDATV4ghUpkAonNBbiyFx1VmmHcQe9HEGd

License: MIT
Signed-off-by: Lars Gierth <larsg@systemli.org>
2016-04-04 16:31:57 -04:00
..
commands.go fix races in http cors 2015-10-13 01:09:55 +03:00
corehttp.go update utp and cleanup more godeps along the way 2016-03-29 19:18:14 -07:00
gateway_handler.go gateway: enforce allowlist for path prefixes 2016-04-04 16:31:57 -04:00
gateway_indexPage.go Use net/url to escape paths in web-ui 2016-03-02 15:46:58 -08:00
gateway_test.go gateway: enforce allowlist for path prefixes 2016-04-04 16:31:57 -04:00
gateway.go gateway: enforce allowlist for path prefixes 2016-04-04 16:31:57 -04:00
ipns_hostname.go correct go-log dep 2016-01-30 09:34:10 -08:00
logs.go correct go-log dep 2016-01-30 09:34:10 -08:00
prometheus.go daemon: instrument the gateway and api HTTP handlers 2015-10-05 03:53:49 +02:00
redirect.go corehttp: add net.Listener to ServeOption 2015-08-02 08:16:51 +02:00
webui.go feat: Update the webui to work with the latest changes in 0.4 2016-03-14 20:49:18 +01:00