diff --git a/src/vault/client/http.clj b/src/vault/client/http.clj index 8252354..8542a31 100644 --- a/src/vault/client/http.clj +++ b/src/vault/client/http.clj @@ -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 @@ -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}))) diff --git a/src/vault/core.clj b/src/vault/core.clj index da8ef94..dad3743 100644 --- a/src/vault/core.clj +++ b/src/vault/core.clj @@ -16,6 +16,7 @@ - `:token \"...\"` - `:userpass {:username \"user\", :password \"hunter2\"}` + - `:ldap {:username \"LDAP username\", :password \"hunter2\"}` - `:app-id {:app \"foo-service-dev\", :user \"...\"}`") (status