Skip to content
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

Request: Add authentication for client side #34

Open
PabloReszczynski opened this issue Nov 29, 2018 · 12 comments
Open

Request: Add authentication for client side #34

PabloReszczynski opened this issue Nov 29, 2018 · 12 comments

Comments

@PabloReszczynski
Copy link

First of all, thanks for this awesome project!

I'm currently developing a debugging feature (nrepl-in instead of ssh-in) for a project I'm working in.
For obvious security reasons, I'm setting authentication for nrepl on the server side (using ring-basic-authentication), but currently the drawbridge client doesn't contain authentication options.

With some guidance I could implement this myself.

Thanks in advance

@bbatsov
Copy link
Contributor

bbatsov commented Nov 29, 2018

Hey there!

That'd be great to have, but the problem is that I can't provide you much guidance as I'm not super familiar with the codebase myself (I did very little work on it, since I became nREPL and related project's maintainer). There's not a lot of code, though, so I assume that if you're determined enough you'll figure things out pretty quickly.

@mallt
Copy link
Contributor

mallt commented Nov 29, 2018

For basic authentication you would have to add a :basic-auth key to the http call as described in the clj-http library. The :basic-auth key can be added here in the ring-client-transport function.

I'm not sure what would be the preferred way to pass the user and password however. One way could be to pass them as environment variables using the environ library for example.

@PabloReszczynski
Copy link
Author

I imagine something like this could be done:

(defn ring-client-transport [url & [options]]
 ...
  (merge {:as :stream
          :cookies @session-cookies}
         (if (:auth options) 
             {:basic-auth [(-> options :auth :user) (-> options :auth :pass)]} 
             {}))
  ...)

@mallt
Copy link
Contributor

mallt commented Nov 29, 2018

Could you perhaps try to pass the username and password in the connection url? F.ex.

lein repl :connect https://username:password@example.com/repl

or

(nrepl/url-connect "https://username:password@example.com/repl")

This might work already without any changes to the code.

@mallt
Copy link
Contributor

mallt commented Dec 3, 2018

@PabloReszczynski Did you get a chance to check passing the username and password in the url? Thanks!

@PabloReszczynski
Copy link
Author

I'm having some issues.
A quick try in my terminal gives this error:

lein repl :connect http://user:pass@localhost:8080/repl

java.io.FileNotFoundException: Could not locate cemerick/drawbridge/client__init.class or cemerick/drawbridge/client.clj on classpath.

I know this is the old version of drawbridge, but I don't know how to tell leiningen to use the newest one

@mallt
Copy link
Contributor

mallt commented Dec 3, 2018

I don't think nrepl/drawbridge is supported yet in the current version of leiningen.

Can you try to add com.cemerick/drawbridge "0.0.7" to your :plugins and retry the lein repl :connect command?

@PabloReszczynski
Copy link
Author

This is the error now:

java.lang.IllegalArgumentException: No nREPL support known for scheme http, url http://
user:pass@localhost:8080/repl

This is with both lein and requiring nrepl 0.5.0

@mallt
Copy link
Contributor

mallt commented Dec 4, 2018

Which version of leiningen are you using?

@PabloReszczynski
Copy link
Author

2.8.1 but the problem persist when using CIDER

@mallt
Copy link
Contributor

mallt commented Dec 31, 2018

I've retested this, and with leiningen 2.8.1 [com.cemerick/drawbridge "0.0.7"] should be added to the plugins. With leiningen 2.8.3 [nrepl/drawbridge "0.1.5"] is needed in the plugins.

I'm not sure where the No nREPL support known for scheme http error would come from if the plugin is present.

Can you perhaps retest with lein 2.8.3 and the [nrepl/drawbridge "0.1.5"] plugin?

@Vinai
Copy link

Vinai commented Jun 3, 2019

In case someone else stumbles over this issue:
we are using nrepl/drawbridge 0.2.0 and changing the plugin to [nrepl/drawbridge "0.2.0"] fixed the Could not locate cemerick/drawbridge/client__init.class or cemerick/drawbridge/client.clj on classpath error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants