cursive-ide / cursive

Cursive: The IDE for beautiful Clojure code
590 stars 7 forks source link

Connecting to remote REPL via HTTP #999

Open martinraison opened 9 years ago

martinraison commented 9 years ago

Leiningen natively supports connecting to a remote repl over http like this:

lein repl :connect https://user:pass@host:port/repl

Is it possible to add that capability to Cursive as well? It looks like it should be just just a matter of allowing to enter an HTTP URL in the config, and passing the correct argument to leiningen's repl task (I don't know cursive internals so I may be wrong).

More context on the technique here: https://devcenter.heroku.com/articles/debugging-clojure (the drawbridge dependency is automatically pulled in by leiningen)

madvas commented 9 years ago

:+1: I hit the same issue today

vikeri commented 9 years ago

I don't know if this is what you are looking for but Cursive can connect to a _networked_REPL (nREPL). See Remote REPLs in https://cursiveclojure.com/userguide/repl.html

I use this for connecting to figwheel for example.

martinraison commented 9 years ago

I'm aware of this, however I'm specifically looking for nREPL over HTTPS, not just raw nREPL. The problem with raw nREPL is that it's completely insecure. If you set it up on a remote machine that is accessible to the outside world, it becomes trivial for anyone to execute arbitrary code on that machine. So you need to work around this by isolating the remote machine and connecting to it through an ssh tunnel, which is cumbersome.

staypufd commented 8 years ago

You could potentially use DrawBridge lib as it supports nRepl over http and https.

martinraison commented 8 years ago

Leiningen uses the drawbridge lib right out of the box when using an http URL with :connect. This is why I was hoping it wouldn't be too hard to implement, if Cursive uses Leiningen under the hood as I think it does (not 100% sure)

Otann commented 7 years ago

Encountered same issue today. Was there any progress on this?

erolosty commented 7 years ago

Would really appreciate this too

jaydeesimon commented 5 years ago

Would also appreciate this feature 👍

markbastian commented 5 years ago

+1 on this as well.

cursive-ide commented 5 years ago

I finally got around to looking into this, thinking it would be a relatively simple change, but it's trickier than it seems. The alternative nREPL protocols seem a bit neglected, and I couldn't get drawbridge to work. There's only one working client for it as far as I can tell, which is Leiningen - I did exactly the same in the Cursive code and it hangs at startup when trying to establish a session.

Drawbridge also requires a metric ton of dependencies which I'm unwilling to bundle in Cursive for a pretty niche use case. I added some classloader black magic to allow downloading the dependency on first use and hot-loading it, but I still can't actually make it work.

I've parked the code for now, if I manage to find someone who understands the gory details enough to help me make it work I'll revisit it, but for now SSH tunnelling remains the only option for a secure production REPL, I'm afraid.

KaliszAd commented 3 years ago

Could you please show, how I can setup basic HTTP authentication with a remote repl in Cursive? Currently, I have to run lein repl :connect http://${USER}:${PASS}@localhost:7001/api/repl with a ssh local port forwarding (ssh -L 7001:localhost:7000 user@server). In Cursive, I don't seen an option how to provide user and password unfortunately. This would greatly help us as paying customers. It is just not very comfortable to run the default console using lein repl and slows down small adjustments like running a data manipulation function in staging or prod.