You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow the WebUI to connect to an authenticated API #2243
I think there is an old code that support Basic Auth (#836, #1586), but afaik there is no support for Bearer tokens.
The basic auth credentials are passed in URL form:
@hazae41 does Basic Auth work for you (then we can close this), or do you need ability to pass custom Authorization header (then we should turn this into feature request).
When the WebUI is same-origin, I can successfully go to /webui and enter the user:pass in URL and it works
But when the WebUI is cross-origin, its requests don't pass CORS, because it sends an OPTIONS preflight request without Authorization header, so the API then replies a Forbidden 403 since there is no header, which fails the CORS preflight test
The solution would be to always reply to OPTIONS requests with HTTP 200
I also noticed it can work with Bearer if we enter this JSON into the URL input
In case someone comes across this issue, see the new guide covering how to configure IPFS Web UI with a remote Kubo node that is secured with Basic HTTP Auth: ipfs/ipfs-docs#2000.
The guide also covers how to configure CORS and handle OPTIONS requests. It uses Caddy as the reverse proxy, so that you get a TLS cert too, which is needed in any real-world deployment.
I'm not sure if there's anything else to do in this issue, since it's not the WebUI that needs changing, it's just CORS that needs to be configured correctly. I suppose the only thing that might be relevant is enabling CORS preflight handling in Kubo, but that would be an issue for the Kubo repo.
Activity
hazae41 commentedon Jul 8, 2024
I managed to get it to work by putting the secret token in a cookie and by using a Nginx reverse proxy to pass the cookie into an authorization header
Then go to your proxy url
/webuiand execute the following JavaScript in the web consoledocument.cookie="token=YOUR_IPFS_TOKEN"Reload the page and voila
https://github.com/hazae41/safe-ipfs
lidel commentedon Jul 9, 2024
I think there is an old code that support Basic Auth (#836, #1586), but afaik there is no support for
Bearertokens.The basic auth credentials are passed in URL form:
@hazae41 does Basic Auth work for you (then we can close this), or do you need ability to pass custom
Authorizationheader (then we should turn this into feature request).hazae41 commentedon Jul 9, 2024
Thanks, I will try
Yet
Bearershould be good to add at some point if you have timehazae41 commentedon Jul 10, 2024
When the WebUI is same-origin, I can successfully go to
/webuiand enter theuser:passin URL and it worksBut when the WebUI is cross-origin, its requests don't pass CORS, because it sends an
OPTIONSpreflight request withoutAuthorizationheader, so the API then replies aForbidden 403since there is no header, which fails the CORS preflight testThe solution would be to always reply to
OPTIONSrequests with HTTP200I also noticed it can work with
Bearerif we enter this JSON into the URL input{"url":"https://ipfs.example.com","headers":{"authorization":"Bearer YOUR_TOKEN"}}github-actions commentedon Jul 17, 2024
Oops, seems like we needed more information for this issue, please comment with more details or this issue will be closed in 7 days.
github-actions commentedon Jul 25, 2024
This issue was closed because it is missing author input.
hazae41 commentedon Sep 14, 2024
It's still an issue when connecting from a third-party, it's blocked by CORS
vpavlin commentedon Sep 20, 2024
Can't you just set
Allow-OriginandAllow-Methodsin IPFS config?Or is the problem that you don't control the node?
2color commentedon Feb 25, 2025
In case someone comes across this issue, see the new guide covering how to configure IPFS Web UI with a remote Kubo node that is secured with Basic HTTP Auth: ipfs/ipfs-docs#2000.
The guide also covers how to configure CORS and handle OPTIONS requests. It uses Caddy as the reverse proxy, so that you get a TLS cert too, which is needed in any real-world deployment.
I'm not sure if there's anything else to do in this issue, since it's not the WebUI that needs changing, it's just CORS that needs to be configured correctly. I suppose the only thing that might be relevant is enabling CORS preflight handling in Kubo, but that would be an issue for the Kubo repo.