mirror of
https://github.com/penpot/penpot.git
synced 2025-05-10 20:16:37 +02:00
⬆️ Replace outdated org.clojars.pntblnk/clj-ldap with puppetlabs/clj-ldap
This commit is contained in:
parent
b475853922
commit
712563a984
2 changed files with 15 additions and 18 deletions
|
@ -53,7 +53,7 @@
|
||||||
com.draines/postal {:mvn/version "2.0.3"
|
com.draines/postal {:mvn/version "2.0.3"
|
||||||
:exclusions [commons-codec/commons-codec]}
|
:exclusions [commons-codec/commons-codec]}
|
||||||
|
|
||||||
org.clojars.pntblnk/clj-ldap {:mvn/version"0.0.16"}
|
puppetlabs/clj-ldap {:mvn/version"0.3.0"}
|
||||||
|
|
||||||
;; exception printing
|
;; exception printing
|
||||||
io.aviso/pretty {:mvn/version "0.1.37"}
|
io.aviso/pretty {:mvn/version "0.1.37"}
|
||||||
|
|
|
@ -31,10 +31,10 @@
|
||||||
(log/errorf e "Cannot connect to LDAP %s:%s"
|
(log/errorf e "Cannot connect to LDAP %s:%s"
|
||||||
(:ldap-auth-host cfg/config) (:ldap-auth-port cfg/config)))))
|
(:ldap-auth-host cfg/config) (:ldap-auth-port cfg/config)))))
|
||||||
:stop (when (realized? *ldap-pool)
|
:stop (when (realized? *ldap-pool)
|
||||||
(some-> *ldap-pool deref (client/close))))
|
(some-> *ldap-pool deref (.close))))
|
||||||
|
|
||||||
(defn- auth-with-ldap [username password]
|
(defn- auth-with-ldap [username password]
|
||||||
(when-let [conn (some-> *ldap-pool deref (client/get-connection))]
|
(when-some [conn (some-> *ldap-pool deref)]
|
||||||
(let [user-search-query (replace-several (:ldap-auth-user-query cfg/config)
|
(let [user-search-query (replace-several (:ldap-auth-user-query cfg/config)
|
||||||
"$username" username)
|
"$username" username)
|
||||||
user-attributes (-> cfg/config
|
user-attributes (-> cfg/config
|
||||||
|
@ -43,21 +43,18 @@
|
||||||
:ldap-auth-fullname-attribute
|
:ldap-auth-fullname-attribute
|
||||||
:ldap-auth-avatar-attribute])
|
:ldap-auth-avatar-attribute])
|
||||||
vals)]
|
vals)]
|
||||||
(try
|
(when-some [user-entry (-> conn
|
||||||
(when-some [user-entry (-> conn
|
(client/search (:ldap-auth-base-dn cfg/config)
|
||||||
(client/search
|
{:filter user-search-query
|
||||||
(:ldap-auth-base-dn cfg/config)
|
:sizelimit 1
|
||||||
{:filter user-search-query
|
:attributes user-attributes})
|
||||||
:sizelimit 1
|
(first))]
|
||||||
:attributes user-attributes})
|
(when-not (client/bind? conn (:dn user-entry) password)
|
||||||
first)]
|
(ex/raise :type :authentication
|
||||||
(when-not (client/bind? conn (:dn user-entry) password)
|
:code ::wrong-credentials))
|
||||||
(ex/raise :type :authentication
|
(set/rename-keys user-entry {(keyword (:ldap-auth-avatar-attribute cfg/config)) :photo
|
||||||
:code ::wrong-credentials))
|
(keyword (:ldap-auth-fullname-attribute cfg/config)) :fullname
|
||||||
(set/rename-keys user-entry {(keyword (:ldap-auth-avatar-attribute cfg/config)) :photo
|
(keyword (:ldap-auth-email-attribute cfg/config)) :email})))))
|
||||||
(keyword (:ldap-auth-fullname-attribute cfg/config)) :fullname
|
|
||||||
(keyword (:ldap-auth-email-attribute cfg/config)) :email}))
|
|
||||||
(finally (client/release-connection @*ldap-pool conn))))))
|
|
||||||
|
|
||||||
(defn auth [req]
|
(defn auth [req]
|
||||||
(let [data (:body-params req)
|
(let [data (:body-params req)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue