Commit Graph

565 Commits

Author SHA1 Message Date
Peter Rabbitson
2d5f8b4ebe Include the git blob id of the dir-index bundle in the ETag
While the content of raw files retrieved via the gateway should never
change, the look and feel of the directory index can and will change
between versions of go-ipfs.

Incorporate the hash of assets/bindata.go into the ETag when appropriate
2020-05-25 18:42:07 +00:00
Steven Allen
6a2fe0a20d fix: support directory listings even if a 404 page is present
fixes https://github.com/ipfs/go-ipfs/pull/4233#issuecomment-631454543

Basically, there's a trade-off here:

1. We can support directory listings while supporting 404 pages (this PR).
2. If a 404 page is present, directory listings don't work.

Given that option 1 is more flexible and users shouldn't be _too_ confused if
they land on a directory with no index.html page, I've gone with that option.
2020-05-20 19:11:50 -07:00
Peter Wu
d4952f2a73 fix(gateway): ensure directory listings have Content-Type text/html
Files already have an explicit Content-Type set. Be sure to do this for
directory listings as well to avoid a fallback to autodetection in
net/http. That fallback fails when a ResponseWriter is installed that
performs compression.
2020-05-20 15:20:33 +02:00
Peter Wu
7c7888c4db fix(gateway): fix status code for HEAD on redirects
Report a consistent status code for HEAD requests that end up in a
redirect.
2020-05-20 14:03:58 +02:00
JP Hastings-Spital
dfceafdbd3 Gateway renders pretty 404 pages if available
In the same way that an `index.html` file is rendered, if one is present, when the
requested path is a directory, now an `ipfs-404.html` file is rendered if
the requested file is not present within the specified IPFS object.

`ipfs-404.html` files are looked for in the directory of the requested path and each
parent until one is found, falling back on the well-known 404 error message.

License: MIT
Signed-off-by: JP Hastings-Spital <jphastings@gmail.com>
2020-05-19 14:41:21 -07:00
Gowtham G
e93f2002f5 optimize import order 2020-05-02 14:19:01 +05:30
Gowtham G
214d29ebf8 #7252 - print error message 2020-05-01 22:37:20 +05:30
Gowtham G
9201b1dde6 #7252 - read content directly instead of sending 512bytes 2020-05-01 20:29:32 +05:30
Gowtham G
2e87ac88a3 Fixes #7252 - Uses gabriel-vasile/mimetype to support additional content types 2020-05-01 12:19:36 +05:30
Steven Allen
46ae021733 feat: show the absolute path every time
Even for dnslink websites.

fixes https://github.com/ipfs/go-ipfs/issues/7205
2020-04-26 17:19:17 -07:00
Steven Allen
d8bc5c991e feat: always show the hash
Previously, we only showed this /ipns paths. However, knowing the hash of the
current directory is useful regardless.
2020-04-26 16:09:02 -07:00
Dimitris Apostolou
1e437c7e97
Fix typos and cleanup 2020-04-20 22:00:01 +03:00
Henrique Dias
135c451997
feat: webui 2.7.5 2020-04-17 20:10:21 +01:00
Marcin Rataj
8290ec11c3
fix: subdomain redirect for dir CIDs
Closes #7164

License: MIT
Signed-off-by: Marcin Rataj <lidel@lidel.org>
2020-04-15 23:50:53 +02:00
Marcin Rataj
7d397ac219
feat: webui v2.7.4
(supersedes v2.7.3)

License: MIT
Signed-off-by: Marcin Rataj <lidel@lidel.org>
2020-04-14 17:51:25 +02:00
Hector Sanjuan
7340543615 corehttp: Gateway handler: add Allow headers when returning MethodNotAllowed
Spec says that response with 405 must set Allow headers.
2020-04-05 09:57:57 +02:00
Hector Sanjuan
1b490476e5 HTTP API: Disallow GET requests on API
This commit upgrades go-ipfs-cmds and configures the commands HTTP API Handler
to only allow POST/OPTIONS, disallowing GET and others in the handling of
command requests in the IPFS HTTP API (where before every type of request
method was handled, with GET/POST/PUT/PATCH being equivalent).

The Read-Only commands that the HTTP API attaches to the gateway endpoint will
additional handled GET as they did before (but stop handling PUT,DELETEs).

By limiting the request types we address the possibility that a website
accessed by a browser abuses the IPFS API by issuing GET requests to it which
have no Origin or Referrer set, and are thus bypass CORS and CSRF protections.

This is a breaking change for clients that relay on GET requests against the
HTTP endpoint (usually :5001). Applications integrating on top of the
gateway-read-only API should still work (including cross-domain access).

Co-Authored-By: Steven Allen <steven@stebalien.com>
Co-Authored-By: Marcin Rataj <lidel@lidel.org>
2020-04-05 09:57:57 +02:00
Marcin Rataj
f9567a0a0f fix(gateway): curl without redirect on localhost
When request is sent to http://localhost:8080/ipfs/$cid response has
HTTP 301 status code and "Location" header with redirect destination at
$cid.ipfs.localhost:8080

Redirect is followed by browsersi, but not by commandline tools.
Status 301 is ignored by curl in default mode: it will print response
and won't follow redirect, user needs to add -L for that.

To fix curl, we return correct payload in body of HTTP 301 response,
but set Clear-Site-Data header to ensure Origin sandbox can't be abused.

This requires a surgical workaround:
If Location header is present in ResponseWriter's Header map,
we ensure http.ServeContent() returns HTTP 301

Context: https://github.com/ipfs/go-ipfs/pull/6982

License: MIT
Signed-off-by: Marcin Rataj <lidel@lidel.org>
2020-03-18 08:50:40 -07:00
Marcin Rataj
3ecccd6e1d feat(gateway): subdomain and proxy gateway
License: MIT
Signed-off-by: Marcin Rataj <lidel@lidel.org>
2020-03-18 08:50:38 -07:00
Steven Allen
72490f7ed0 gateway: simplify/improve dnslink rewrite handling
Instead of adding a new fake header (that could be spoofed by the client...),
just read the original request URI from the request object.

This also removes support for suborigins. They have never been implemented in
browsers and it looks like efforts have stalled. We can add support back if we
need it but, well, maintaining support was going to be more trouble than it was
worth.

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2020-03-17 19:34:44 -07:00
Steven Allen
11c229bb14 rename ProxyOption to P2PProxyOption
(we're implementing an _actual_ proxy)

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2020-03-17 19:34:44 -07:00
Steven Allen
906f45edd9 fix(tracing): remove event tracing
We've deprecated this system and have yet to move to a new system. We might as
well remove everything, switch to a new system, then deliberately trace the
entire system.
2020-01-28 21:31:12 -08:00
Steven Allen
a53d48059b fix: migrate from deprecated warning function 2020-01-28 21:20:21 -08:00
Steven Allen
725e6844ee gateway: cleanup logic
License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2020-01-10 10:19:13 +01:00
Steven Allen
5eea0a4ba0 http: use Method* constants
License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2020-01-10 10:19:08 +01:00
Steven Allen
c64eb11992 test(gateway): test the lazy seeker 2020-01-05 16:43:45 -08:00
Steven Allen
6cb03d4dfd fix(gateway): fix seek read length typo 2020-01-05 16:43:45 -08:00
Steven Allen
453b78962b chore(gateway): remove dead code 2020-01-05 16:43:45 -08:00
Steven Allen
1a06fb6e2f fix(gateway): correct symlink content type
We should be _resolving_ symlinks (sometimes, still need to figure out when to
do this WRT IPNS). However, that's a larger feature.
2020-01-05 16:43:44 -08:00
Steven Allen
3859f08bf7 fix(gateway): better seeking/sized
1. Require files to have known sizes. We can add support for unknown sizes
_later_ but we can't use ServeContent for those files.
2. Replace the `sizeReadSeeker` with a `lazySeeker`. This one makes no
assumptions about how it's used so we're less likely to run into weird bugs.
2020-01-05 16:43:44 -08:00
Steven Allen
e8a6c0c050 fix(gateway): gracefully handle files with unknown sizes in directory listings 2020-01-05 16:43:44 -08:00
Steven Allen
62451039ec fix(gateway): serve the index with serveFile 2020-01-05 16:43:44 -08:00
Marcin Rataj
115b2ba6cd
fix: limit SW registration to content root
Introduces hardening proposed in:
https://github.com/ipfs/go-ipfs/issues/4025#issuecomment-342250616

License: MIT
Signed-off-by: Marcin Rataj <lidel@lidel.org>
2019-12-17 02:20:40 +01:00
Henrique Dias
5ab7a70131
feat: web ui 2.7.2 2019-12-04 08:15:58 +00:00
Steven Allen
c19bc362f5
Merge pull request #6743 from dreamski21/fix/gateway/content-type-header
fix #2203: omit the charset attribute when Content-Type is text/html
2019-12-02 14:13:57 -05:00
Henrique Dias
f4a4baccee
feat: web ui 2.7.1 2019-11-12 23:37:40 +00:00
Steven Allen
7ae6f6fa3e chore(gateway): document encoding fix 2019-11-06 11:47:27 +00:00
Steven Allen
69f6e08d9d chore(gateway): remove redundant seek 2019-11-06 11:45:41 +00:00
Steven Allen
a12d2e265e chore(gateway): fix error call 2019-11-06 11:44:56 +00:00
Steven Allen
ebf2e7da36 chore(gateway): fix import ordering 2019-11-06 11:44:32 +00:00
Djalil Dreamski
a29a9dbb98
gateway: ServeFile: use file extension to determine Content-Type
License: MIT
Signed-off-by: Abdeldjalil Hebal <dreamski21@gmail.com>
2019-11-06 01:52:49 +01:00
Djalil Dreamski
69f81a11dd
Update gateway_handler.go 2019-11-05 17:36:26 +01:00
Djalil Dreamski
aefff48654
fix #2203: omit the charset attribute when Content-Type is text/html
License: MIT
Signed-off-by: Abdeldjalil Hebal <dreamski21@gmail.com>
2019-11-02 21:56:54 +01:00
Henrique Dias
29d6d7e3cd
feat: web ui 2.6.0
See https://github.com/ipfs-shipyard/ipfs-webui/releases/tag/v2.6.0.
2019-10-30 17:50:29 +00:00
Steven Allen
4a102207a3
Merge pull request #6643 from ipfs/fix/provide-prometheus-namespace
ipfs namespace is now being provided to prometheus
2019-10-22 20:38:00 -07:00
Adrian Lanzafame
48f25d9ed7
pass opts.Namespace along like before 2019-10-23 10:46:11 +10:00
Henrique Dias
f3f3899a68
Update webui.go 2019-10-21 20:24:15 +01:00
Henrique Dias
a1854101c0
feat: web ui 2.5.8 2019-10-21 08:31:33 +01:00
Henrique Dias
bb59c24947
feat: web ui 2.5.7
Relevant release notes can be found on [v2.5.5](https://github.com/ipfs-shipyard/ipfs-webui/releases/tag/v2.5.5).
2019-10-08 08:33:58 +01:00
Steven Allen
853ed0be5d chore: fix deprecation warnings 2019-09-26 15:38:12 -07:00