-
Notifications
You must be signed in to change notification settings - Fork 298
Ability to Modify Default Headers #724
Comments
(Assuming jwt is the bearer schema being used) Since the API is still on If the API were to move to |
I think this would be appropriate as I find myself in the same situation as @OR13 . Perhaps as a more general solution would be to allow configuration of custom headers to be sent with any request. This could then extend beyond authentication and a more tailored authentication solution could be implemented if/when the API moves to Thoughts? |
Here is a PR which should support custom headers for all requests made by the library. |
@diasdavid this pull request allows IPFS consumers to use Bearer Authentication with a half-line of code. This will allow us and others to remove our forks and stay up to date with the progress y'all are making. Can you please merge this? |
I'm working out some lint errors, but this is my approach:
|
Closing as #741 was merged and released :D |
As far as I am aware, best practice for securing IPFS is to use an api gateway or proxy to restrict access to the ipfs api.
ipfs/kubo#1532
Bearer Authentication is common, here are some more details on the practice:
https://swagger.io/docs/specification/authentication/bearer-authentication/
I have tested using Kong to secure IPFS in this way and had success, but I find myself wanting to add a header to every network request made by js-ipfs-api.
We could support adding a header to the config:
Here where the user agent is added:
https://github.com/ipfs/js-ipfs-api/blob/master/src/utils/send-request.js#L111
We could add the authorization header to every request.
Axios http client supports this:
axios/axios#209
The api gateway (kong/ tyk) would be responsible for validating the jwt token.
I'm happy to submit a PR for this work, but I'm not sure the potential security implications for the rest of the api.
At a minimum it would seem wise to only allow the authorization header (assuming it is formatted correctly).
Interested to hear if this would be useful for others.
The text was updated successfully, but these errors were encountered: