xud icon indicating copy to clipboard operation
xud copied to clipboard

Use macaroons for grpc authentication

Open sangaman opened this issue 6 years ago • 15 comments

Currently there's no authentication on rpc calls. This issue tracks using macaroons for securing rpc calls. We'll need to generate macaroons on startup if none exist.

The most mature macaroons implementation for javascript appears to be https://github.com/nitram509/macaroons.js, however it has not been updated in over a year and there are apparently issues with its type definitions. We should consider forking that project and fixing the type definitions.

Note: This will necessarily be a breaking change as far as the swap-resolver code goes, so we'll need to coordinate this with changes to swap-resolver logic.

sangaman avatar Oct 04 '18 18:10 sangaman

since it'll be breaking changes rather sooner than later? I put it into the next milestone for now, let me know if you'd push it one further @sangaman @offerm

kilrau avatar Oct 26 '18 17:10 kilrau

Yeah that's true, I figure we should definitely support a nomacaroons mode to make testing easier but it's still breaking in that we'd need to add that arg for current behavior to continue working. I'll take a look at this next week.

sangaman avatar Oct 26 '18 20:10 sangaman

@offerm anything to add from your side? Preferably we do this now since breaking changes and alpha.3 should be the first version we distribute to some exchanges

kilrau avatar Nov 07 '18 11:11 kilrau

I'm not sure about the need. I think in most cases the RPC will be used from a local machine and the access to the macaroons file will be automatic by looking for the XUD working directory.

Having said that, I don't see it as an issue to have it now.

Suggest to support nomacaroons option and make it the default until the swap-resolver /simnet is ready for macaroon usage.

offerm avatar Nov 07 '18 12:11 offerm

Hmm not sure if nomacaroons as temporary default makes sense since once we switch to default it will break things. Push to next milestone to give @offerm some time to fix simnet? @sangaman

kilrau avatar Nov 07 '18 16:11 kilrau

@kilrau nomacaroons is our current setup, right?

switching to macarons is the breaking change.

My suggestion is to add macaron support while keeping current defalt (nomacaroon), check it, switch to macaroons on simnet, and when everything is working, make it the default.

offerm avatar Nov 08 '18 14:11 offerm

Ok then. Let's do it like that.

kilrau avatar Nov 08 '18 14:11 kilrau

Yeah I was also planning on starting with nomacaroons as defaulting to true.

sangaman avatar Nov 10 '18 05:11 sangaman

Maybe we could use this library: https://github.com/go-macaroon/js-macaroon

michael1011 avatar Dec 15 '18 13:12 michael1011

Conclusion from the call. For mainnet:

  • readonly
  • everything

erkarl avatar Apr 24 '19 12:04 erkarl

As discussed, it would make sense to have separate macaroons with access to different sets of rpc calls. A simple breakdown would be one macaroon with access to all calls and another with access to strictly read-only calls (GetInfo, ListOrders, etc...).

sangaman avatar Apr 24 '19 12:04 sangaman

Yup, I think that's what @erkarl meant. Sounds good!

kilrau avatar Apr 25 '19 03:04 kilrau

I have worked with macaroons in the past and can implement this

hatmer avatar Jan 19 '20 16:01 hatmer

Still up for this? @hatmer

kilrau avatar Apr 01 '20 14:04 kilrau

Sure, this will be my next project

hatmer avatar Apr 02 '20 14:04 hatmer