Skip to content

Commit

Permalink
Merge pull request #16 from kenrestivo-stem/feature/issue-14-ldap-auth
Browse files Browse the repository at this point in the history
Add LDAP support #14
  • Loading branch information
greglook committed Sep 25, 2017
2 parents c90dcc7 + 18228d9 commit 28caf7d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
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

0 comments on commit 28caf7d

Please sign in to comment.