mirror of
https://github.com/penpot/penpot.git
synced 2025-03-11 23:31:21 -05:00
✨ Add better error reporting when ldap is not configured correctly.
This commit is contained in:
parent
c6fe035939
commit
84ba8e6dde
2 changed files with 20 additions and 1 deletions
|
@ -13,11 +13,20 @@
|
||||||
[app.loggers.audit :as audit]
|
[app.loggers.audit :as audit]
|
||||||
[app.rpc.mutations.profile :as profile-m]
|
[app.rpc.mutations.profile :as profile-m]
|
||||||
[app.rpc.queries.profile :as profile-q]
|
[app.rpc.queries.profile :as profile-q]
|
||||||
|
[app.util.logging :as l]
|
||||||
[app.util.services :as sv]
|
[app.util.services :as sv]
|
||||||
[clj-ldap.client :as ldap]
|
[clj-ldap.client :as ldap]
|
||||||
[clojure.spec.alpha :as s]
|
[clojure.spec.alpha :as s]
|
||||||
[clojure.string]))
|
[clojure.string]))
|
||||||
|
|
||||||
|
|
||||||
|
(s/def ::fullname ::us/not-empty-string)
|
||||||
|
(s/def ::email ::us/email)
|
||||||
|
(s/def ::backend ::us/not-empty-string)
|
||||||
|
|
||||||
|
(s/def ::info-data
|
||||||
|
(s/keys :req-un [::fullname ::email ::backend]))
|
||||||
|
|
||||||
(defn ^java.lang.AutoCloseable connect
|
(defn ^java.lang.AutoCloseable connect
|
||||||
[]
|
[]
|
||||||
(let [params {:ssl? (cfg/get :ldap-ssl)
|
(let [params {:ssl? (cfg/get :ldap-ssl)
|
||||||
|
@ -57,6 +66,13 @@
|
||||||
(ex/raise :type :validation
|
(ex/raise :type :validation
|
||||||
:code :wrong-credentials))
|
:code :wrong-credentials))
|
||||||
|
|
||||||
|
(when-not (s/valid? ::info-data info)
|
||||||
|
(let [explain (s/explain-str ::info-data info)]
|
||||||
|
(l/warn ::l/raw (str "invalid response from ldap, looks like ldap is not configured correctly\n" explain))
|
||||||
|
(ex/raise :type :restriction
|
||||||
|
:code :wrong-ldap-response
|
||||||
|
:reason explain)))
|
||||||
|
|
||||||
(let [profile (login-or-register cfg {:email (:email info)
|
(let [profile (login-or-register cfg {:email (:email info)
|
||||||
:backend (:backend info)
|
:backend (:backend info)
|
||||||
:fullname (:fullname info)})]
|
:fullname (:fullname info)})]
|
||||||
|
@ -94,7 +110,9 @@
|
||||||
(cfg/get :ldap-attrs-fullname)]
|
(cfg/get :ldap-attrs-fullname)]
|
||||||
|
|
||||||
base-dn (cfg/get :ldap-base-dn)
|
base-dn (cfg/get :ldap-base-dn)
|
||||||
params {:filter query :sizelimit 1 :attributes attrs}]
|
params {:filter query
|
||||||
|
:sizelimit 1
|
||||||
|
:attributes attrs}]
|
||||||
(first (ldap/search cpool base-dn params))))
|
(first (ldap/search cpool base-dn params))))
|
||||||
|
|
||||||
(defn- authenticate
|
(defn- authenticate
|
||||||
|
|
|
@ -92,6 +92,7 @@ services:
|
||||||
ports:
|
ports:
|
||||||
- "1080:1080"
|
- "1080:1080"
|
||||||
|
|
||||||
|
# https://github.com/rroemhild/docker-test-openldap
|
||||||
ldap:
|
ldap:
|
||||||
image: rroemhild/test-openldap:2.1
|
image: rroemhild/test-openldap:2.1
|
||||||
expose:
|
expose:
|
||||||
|
|
Loading…
Add table
Reference in a new issue