-
Notifications
You must be signed in to change notification settings - Fork 491
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
feat: improved support for remote API #1613
Conversation
This change adds support for connecting to remote API that is protected by HTTP Basic Auth and enables entering custom configuration as a hidden feature for advanced users. Terse summary: - custom API address is stored in and read from localStorage[ipfsApi] - ipfsApi is a string or null - if ipfsApi is null, ipfs-provider will try default /ip4/127.0.0.1/tcp/5001 and same-origin - ipfsApi tring can be multiaddr, URL or a JSON with constructor config for ipfs-http-client - user can enter URL with inlined basic auth user and password, we convert them to advanced config before passing to http client. - E2E tests for using remote API with basic auth (URL or JSON, by setting localStorage[ipfsApi] or via Settings screen)
@lidel LGTM -- thank you for the super-detailed screenshots 😊 |
@jessicaschilling done: One can test this even without basic auth setup, this JSON will work: |
This comment has been minimized.
This comment has been minimized.
This makes tests DRY and adds regression tests for API set to multiaddr and regular URL in addition to existing basic auth JSON/URL.
Passing config object to I've addressed that in ipfs-shipyard/ipfs-provider#24 but need to update this PR to use documented parameters instead of |
This update ensures that if user passes a custom config for ipfs-http-client, the object is not mutated by the http client.
Switched to ipfs-provider 1.1.0, which does not mutate the custom config, so the "undocumented @rafaelramalho19 ready for your final review. |
This removes double JSON serialization, as noted in #1613 (comment) and cleans up a bunch of tests to only use documented config keys for ipfs-http-client.
This PR adds support for connecting to remote API that is protected by HTTP Basic Auth (#1586), enables entering custom configuration (a hidden feature for advanced users) and adds end-to-end tests.
Terse summary
window.localStorage[ipfsApi]
ipfsApi
is astring
or anull
ipfsApi
isnull
, ipfs-provider will try default address at/ip4/127.0.0.1/tcp/5001
(and same-origin for a good measure)ipfsApi
can be a multiaddr, URL or JSON with config for ipfs-http-client used by webuiVisual changes
Settings page
It is now possible to enter URL with inlined basic auth:
JSON with equivalent config for ipfs-http-client is also accepted:
Note: this is sort of an easter egg, we should not mention it in UI. This is mostly future-proofing. If someone has a very custom setup, webui will be able to support it without the need for a new release or a fancy UI for that one person.
Status page
Default state is the same(multiaddr), so most of the users will see no difference:
If a custom URL was entered on Settings, we also show URL on Status:
If JSON was entered, then we show it as-is. Here, a custom config with Basic Auth header:
I believe this is so niche, power user feature, that there is no point in making UI for this. Edit button is enough.
Instead of showing JSON, we could just print
[JSON config]
placeholder or something – @jessicaschilling thoughts?