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

added ntlm-auth and support for custom auth-scheme factories #198

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/clj_http/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
HttpEntityEnclosingRequest
HttpResponse Header HttpHost
HttpResponseInterceptor)
(org.apache.http.auth UsernamePasswordCredentials AuthScope)
(org.apache.http.auth AuthScope
UsernamePasswordCredentials
NTCredentials)
(org.apache.http.params CoreConnectionPNames)
(org.apache.http.client HttpClient HttpRequestRetryHandler)
(org.apache.http.client.methods HttpDelete
Expand Down Expand Up @@ -211,7 +213,8 @@
[{:keys [request-method scheme server-name server-port uri query-string
headers body multipart socket-timeout conn-timeout proxy-host
proxy-ignore-hosts proxy-port as cookie-store retry-handler
response-interceptor digest-auth connection-manager client-params]
response-interceptor digest-auth ntlm-auth auth-schemes
connection-manager client-params]
:as req}]
(let [^ClientConnectionManager conn-mgr
(or connection-manager
Expand Down Expand Up @@ -241,6 +244,17 @@
(.getCredentialsProvider http-client)
(AuthScope. nil -1 nil)
(UsernamePasswordCredentials. user pass)))

(when-let [[user pass host domain] ntlm-auth]
(.setCredentials
(.getCredentialsProvider http-client)
(AuthScope. nil -1 nil)
(NTCredentials. user pass host domain)))

(doseq [[policy scheme-factory] auth-schemes]
(-> (.getAuthSchemes http-client)
(.register policy scheme-factory)))

(let [http-url (str scheme "://" server-name
(when server-port (str ":" server-port))
uri
Expand Down