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

Add LDAP support #14 #16

Merged
merged 4 commits into from Sep 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/vault/client/http.clj
Expand Up @@ -164,6 +164,22 @@
:as :json})))))


(defn- authenticate-ldap!
"Updates the token ref by making a request to authenticate with a username
and password, to be authenticated against an LDAP backend."
[client credentials]
(let [{:keys [username password]} credentials]
(api-auth!
(str "LDAP user " username)
(:auth client)
(do-api-request :post (str (:api-url client) "/v1/auth/ldap/login/" username)
(merge
(:http-opts client)
{:form-params {:password password}
:content-type :json
:accept :json
:as :json})))))


;; ## Timer Logic

Expand Down Expand Up @@ -278,6 +294,7 @@
:token (authenticate-token! this credentials)
:app-id (authenticate-app! this credentials)
:userpass (authenticate-userpass! this credentials)
:ldap (authenticate-ldap! this credentials)
; Unknown type
(throw (ex-info (str "Unsupported auth-type " (pr-str auth-type))
{:auth-type auth-type})))
Expand Down
1 change: 1 addition & 0 deletions src/vault/core.clj
Expand Up @@ -16,6 +16,7 @@

- `:token \"...\"`
- `:userpass {:username \"user\", :password \"hunter2\"}`
- `:ldap {:username \"LDAP username\", :password \"hunter2\"}`
- `:app-id {:app \"foo-service-dev\", :user \"...\"}`")

(status
Expand Down