-
Notifications
You must be signed in to change notification settings - Fork 154
docs: add example of gateway that proxies to ?format=raw #151
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
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6e7b2fd
docs: example proxy gatewya to ?format=raw & ?format=ipns-record
hacdias c721528
docs: improve readne
hacdias 47519ff
refactor: move common code to common
hacdias a8d8d13
fix: blockstore must validate untrusted requests
hacdias 4dec0c5
feat: add some smoke tests
hacdias File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # Gateway as a Verifying Proxy for Untrusted Remote Blockstore | ||
|
|
||
| This is an example of building a Gateway that uses `application/vnd.ipld.raw` | ||
| responses from another gateway acting as a remote blockstore and IPNS resolver. | ||
|
|
||
| Key benefits: | ||
| 1. Verifies raw blocks and IPNS records fetched from untrusted third-party gateways. | ||
| 2. The proxy provides web gateway functionalities: returns deserialized files and websites, including index.html support, while the remote gateway only needs to support block responses. | ||
|
|
||
| In this example, we implement two major structures: | ||
|
|
||
| - [Block Store](./blockstore.go), which forwards the block requests to the backend | ||
| gateway using `?format=raw`, and | ||
| - [Routing System](./routing.go), which forwards the IPNS requests to the backend | ||
| gateway using `?format=ipns-record`. In addition, DNSLink lookups are done locally. | ||
| - Note: `ipns-record` was introduced just recently in [IPIP-351](https://github.com/ipfs/specs/pull/351) and reference support for it will ship in Kubo 0.19. Until that happens, it may not be supported by public gateways yet. | ||
|
|
||
| ## Build | ||
|
|
||
| ```bash | ||
| > go build -o verifying-proxy | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| First, you need a compliant gateway that supports both [RAW Block](https://www.iana.org/assignments/media-types/application/vnd.ipld.raw) and IPNS Record response | ||
| types. Once you have it, run the proxy gateway with its address as the host parameter: | ||
|
|
||
|
|
||
| ``` | ||
| ./verifying-proxy -h https://ipfs.io -p 8040 | ||
| ``` | ||
|
|
||
| Now you can access the gateway in [127.0.0.1:8040](http://127.0.0.1:8040). It will | ||
| behave like a regular IPFS Gateway, except for the fact that it runs no libp2p, and has no local blockstore. | ||
| All contents are provided by a remote gateway and fetched as RAW Blocks and Records, and verified locally. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.