Compare commits

...

9 Commits

Author SHA1 Message Date
Andrey Antukh
24da25f0f7 📎 Update changelog and increase version (minor). 2021-08-19 11:15:30 +02:00
Andrey Antukh
84ba8e6dde Add better error reporting when ldap is not configured correctly. 2021-08-19 11:04:08 +02:00
Andrey Antukh
c6fe035939 🐛 Fix demo user login issue. 2021-08-19 11:04:08 +02:00
Andrey Antukh
df1fcd5e22 📎 Update changelog. 2021-08-18 15:08:25 +02:00
Andrey Antukh
de87da9c91 🐛 Fix font uploading issue on windows. 2021-08-18 15:06:19 +02:00
Andrey Antukh
326c52604b 🐛 Don't dissoc :current-team-id on finalizing workspace. 2021-08-04 11:54:54 +02:00
Andrey Antukh
e7d1647769 🐛 Don't allow remove default teams. 2021-08-04 10:54:31 +02:00
Andrey Antukh
1e35116d8f 🐛 Don't allow remove default projects. 2021-08-04 10:50:21 +02:00
Andrey Antukh
35ca3ec895 🐛 Fix loggin issue when user uses the same email as previously deleted profile. 2021-08-04 10:42:22 +02:00
10 changed files with 74 additions and 16 deletions

View File

@@ -1,8 +1,5 @@
# CHANGELOG #
## :rocket: Next
### :sparkles: New features
@@ -12,6 +9,20 @@
### :boom: Breaking changes
### :heart: Community contributions by (Thank you!)
## 1.7.4-alpha
### :bug: Bugs fixed
- Fix demo user creation (self-hosted only)
- Add better ldap response validation and reporting (self-hosted only)
## 1.7.3-alpha
### :bug: Bugs fixed
- Fix font uploading issue on Windows.
## 1.7.2-alpha

View File

@@ -6,6 +6,7 @@
(ns app.rpc.mutations.fonts
(:require
[app.common.exceptions :as ex]
[app.common.spec :as us]
[app.common.uuid :as uuid]
[app.config :as cf]
@@ -49,6 +50,7 @@
(let [data (media/run cfg {:cmd :generate-fonts :input data :rlimit :font})
storage (media/configure-assets-storage storage conn)
otf (when-let [fdata (get data "font/otf")]
(sto/put-object storage {:content (sto/content fdata)
:content-type "font/otf"}))
@@ -65,6 +67,13 @@
(sto/put-object storage {:content (sto/content fdata)
:content-type "font/woff2"}))]
(when (and (nil? otf)
(nil? ttf)
(nil? woff1)
(nil? woff2))
(ex/raise :type :validation
:code :invalid-font-upload))
(db/insert! conn :team-font-variant
{:id (uuid/next)
:team-id (:team-id params)

View File

@@ -13,11 +13,20 @@
[app.loggers.audit :as audit]
[app.rpc.mutations.profile :as profile-m]
[app.rpc.queries.profile :as profile-q]
[app.util.logging :as l]
[app.util.services :as sv]
[clj-ldap.client :as ldap]
[clojure.spec.alpha :as s]
[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
[]
(let [params {:ssl? (cfg/get :ldap-ssl)
@@ -57,6 +66,13 @@
(ex/raise :type :validation
: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)
:backend (:backend info)
:fullname (:fullname info)})]
@@ -94,7 +110,9 @@
(cfg/get :ldap-attrs-fullname)]
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))))
(defn- authenticate

View File

@@ -117,11 +117,15 @@
(s/def ::delete-project
(s/keys :req-un [::id ::profile-id]))
;; TODO: right now, we just don't allow delete default projects, in a
;; future we need to ensure raise a correct exception signaling that
;; this is not allowed.
(sv/defmethod ::delete-project
[{:keys [pool] :as cfg} {:keys [id profile-id] :as params}]
(db/with-atomic [conn pool]
(proj/check-edition-permissions! conn profile-id id)
(db/update! conn :project
{:deleted-at (dt/now)}
{:id id})
{:id id :is-default false})
nil))

View File

@@ -125,6 +125,10 @@
(s/def ::delete-team
(s/keys :req-un [::profile-id ::id]))
;; TODO: right now just don't allow delete default team, in future it
;; should raise a speific exception for signal that this acction is
;; not allowed.
(sv/defmethod ::delete-team
[{:keys [pool] :as cfg} {:keys [id profile-id] :as params}]
(db/with-atomic [conn pool]
@@ -135,7 +139,7 @@
(db/update! conn :team
{:deleted-at (dt/now)}
{:id id})
{:id id :is-default false})
nil)))

View File

@@ -92,11 +92,16 @@
profile))
(def ^:private sql:profile-by-email
"select p.* from profile as p
where p.email = ?
and (p.deleted_at is null or
p.deleted_at > now())")
(defn retrieve-profile-data-by-email
[conn email]
(try
(db/get-by-params conn :profile {:email (str/lower email)})
(catch Exception _e)))
(ex/ignoring
(db/exec-one! conn [sql:profile-by-email (str/lower email)])))
;; --- Attrs Helpers

View File

@@ -92,6 +92,7 @@ services:
ports:
- "1080:1080"
# https://github.com/rroemhild/docker-test-openldap
ldap:
image: rroemhild/test-openldap:2.1
expose:

View File

@@ -111,10 +111,13 @@
(:data content)})
(dissoc :content)))))))
(parse-mtype [mtype]
(case mtype
"application/vnd.oasis.opendocument.formula-template" "font/otf"
mtype))
(parse-mtype [ba]
(let [u8 (js/Uint8Array. ba 0 4)
sg (areduce u8 i ret "" (str ret (if (zero? i) "" " ") (.toString (aget u8 i) 8)))]
(case sg
"117 124 124 117" "font/otf"
"0 1 0 0" "font/ttf"
"167 117 106 106" "font/woff")))
(parse-font [{:keys [data] :as params}]
(try
@@ -128,7 +131,11 @@
(rx/map (fn [data]
{:data data
:name (.-name blob)
:type (parse-mtype (.-type blob))}))))]
:type (parse-mtype data)}))
(rx/mapcat (fn [{:keys [type] :as font}]
(if type
(rx/of font)
(rx/empty))))))]
(->> (rx/from blobs)
(rx/mapcat read-blob)

View File

@@ -206,7 +206,6 @@
(dissoc state
:current-file-id
:current-project-id
:current-team-id
:workspace-data
:workspace-editor-state
:workspace-file

View File

@@ -1 +1 @@
1.7.2-alpha
1.7.4-alpha