mirror of
https://github.com/penpot/penpot.git
synced 2026-04-29 05:08:08 +00:00
🐛 Prevent invitations to blacklisted domains
This commit is contained in:
parent
0b6416e53b
commit
cfa595bb94
@ -10,6 +10,7 @@
|
|||||||
### :bug: Bugs fixed
|
### :bug: Bugs fixed
|
||||||
|
|
||||||
- Fix incorrect handling of version restore operation [Github #9041](https://github.com/penpot/penpot/pull/9041)
|
- Fix incorrect handling of version restore operation [Github #9041](https://github.com/penpot/penpot/pull/9041)
|
||||||
|
- Prevent invitations to blacklisted domains [Github #9150](https://github.com/penpot/penpot/pull/9150)
|
||||||
|
|
||||||
|
|
||||||
## 2.14.4
|
## 2.14.4
|
||||||
|
|||||||
@ -12,7 +12,7 @@ export PENPOT_PUBLIC_URI=https://localhost:3449
|
|||||||
|
|
||||||
export PENPOT_FLAGS="\
|
export PENPOT_FLAGS="\
|
||||||
$PENPOT_FLAGS \
|
$PENPOT_FLAGS \
|
||||||
enable-login-with-password
|
enable-login-with-password \
|
||||||
disable-login-with-ldap \
|
disable-login-with-ldap \
|
||||||
disable-login-with-oidc \
|
disable-login-with-oidc \
|
||||||
disable-login-with-google \
|
disable-login-with-google \
|
||||||
|
|||||||
@ -19,6 +19,7 @@
|
|||||||
[app.config :as cf]
|
[app.config :as cf]
|
||||||
[app.db :as db]
|
[app.db :as db]
|
||||||
[app.email :as eml]
|
[app.email :as eml]
|
||||||
|
[app.email.blacklist :as email.blacklist]
|
||||||
[app.loggers.audit :as audit]
|
[app.loggers.audit :as audit]
|
||||||
[app.main :as-alias main]
|
[app.main :as-alias main]
|
||||||
[app.rpc :as-alias rpc]
|
[app.rpc :as-alias rpc]
|
||||||
@ -91,6 +92,12 @@
|
|||||||
(let [email (profile/clean-email email)
|
(let [email (profile/clean-email email)
|
||||||
member (profile/get-profile-by-email conn email)]
|
member (profile/get-profile-by-email conn email)]
|
||||||
|
|
||||||
|
(when (and (email.blacklist/enabled? cfg)
|
||||||
|
(email.blacklist/contains? cfg email))
|
||||||
|
(ex/raise :type :restriction
|
||||||
|
:code :email-domain-is-not-allowed
|
||||||
|
:hint "email domain is in the blacklist"))
|
||||||
|
|
||||||
;; When we have email verification disabled and invitation user is
|
;; When we have email verification disabled and invitation user is
|
||||||
;; already present in the database, we proceed to add it to the
|
;; already present in the database, we proceed to add it to the
|
||||||
;; team as-is, without email roundtrip.
|
;; team as-is, without email roundtrip.
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.config :as cf]
|
[app.config :as cf]
|
||||||
[app.db :as db]
|
[app.db :as db]
|
||||||
|
[app.email.blacklist :as email.blacklist]
|
||||||
[app.http :as http]
|
[app.http :as http]
|
||||||
[app.rpc :as-alias rpc]
|
[app.rpc :as-alias rpc]
|
||||||
[app.storage :as sto]
|
[app.storage :as sto]
|
||||||
@ -102,6 +103,46 @@
|
|||||||
(t/is (= :validation (:type edata)))
|
(t/is (= :validation (:type edata)))
|
||||||
(t/is (= :member-is-muted (:code edata))))))))
|
(t/is (= :member-is-muted (:code edata))))))))
|
||||||
|
|
||||||
|
(t/deftest create-team-invitations-blacklisted-domain
|
||||||
|
(with-mocks [mock {:target 'app.email/send! :return nil}]
|
||||||
|
(let [profile1 (th/create-profile* 1 {:is-active true})
|
||||||
|
team (th/create-team* 1 {:profile-id (:id profile1)})
|
||||||
|
data {::th/type :create-team-invitations
|
||||||
|
::rpc/profile-id (:id profile1)
|
||||||
|
:team-id (:id team)
|
||||||
|
:role :editor}]
|
||||||
|
|
||||||
|
;; invite from a directly blacklisted domain should fail
|
||||||
|
(with-redefs [email.blacklist/enabled? (constantly true)
|
||||||
|
email.blacklist/contains? (fn [_ email]
|
||||||
|
(clojure.string/ends-with? email "@blacklisted.com"))]
|
||||||
|
(let [out (th/command! (assoc data :emails ["user@blacklisted.com"]))]
|
||||||
|
(t/is (not (th/success? out)))
|
||||||
|
(t/is (= 0 (:call-count @mock)))
|
||||||
|
(let [edata (-> out :error ex-data)]
|
||||||
|
(t/is (= :restriction (:type edata)))
|
||||||
|
(t/is (= :email-domain-is-not-allowed (:code edata))))))
|
||||||
|
|
||||||
|
;; invite from a subdomain of a blacklisted domain should also fail
|
||||||
|
(th/reset-mock! mock)
|
||||||
|
(with-redefs [email.blacklist/enabled? (constantly true)
|
||||||
|
email.blacklist/contains? (fn [_ email]
|
||||||
|
(clojure.string/ends-with? email "@sub.blacklisted.com"))]
|
||||||
|
(let [out (th/command! (assoc data :emails ["user@sub.blacklisted.com"]))]
|
||||||
|
(t/is (not (th/success? out)))
|
||||||
|
(t/is (= 0 (:call-count @mock)))
|
||||||
|
(let [edata (-> out :error ex-data)]
|
||||||
|
(t/is (= :restriction (:type edata)))
|
||||||
|
(t/is (= :email-domain-is-not-allowed (:code edata))))))
|
||||||
|
|
||||||
|
;; invite from a non-blacklisted domain should succeed
|
||||||
|
(th/reset-mock! mock)
|
||||||
|
(with-redefs [email.blacklist/enabled? (constantly true)
|
||||||
|
email.blacklist/contains? (constantly false)]
|
||||||
|
(let [out (th/command! (assoc data :emails ["user@allowed.com"]))]
|
||||||
|
(t/is (th/success? out))
|
||||||
|
(t/is (= 1 (:call-count @mock))))))))
|
||||||
|
|
||||||
(t/deftest create-team-invitations-with-request-access
|
(t/deftest create-team-invitations-with-request-access
|
||||||
(with-mocks [mock {:target 'app.email/send! :return nil}]
|
(with-mocks [mock {:target 'app.email/send! :return nil}]
|
||||||
(let [profile1 (th/create-profile* 1 {:is-active true})
|
(let [profile1 (th/create-profile* 1 {:is-active true})
|
||||||
|
|||||||
@ -195,6 +195,11 @@
|
|||||||
(= :email-has-complaints code))
|
(= :email-has-complaints code))
|
||||||
(swap! error-text (tr "errors.email-spam-or-permanent-bounces" (:email error)))
|
(swap! error-text (tr "errors.email-spam-or-permanent-bounces" (:email error)))
|
||||||
|
|
||||||
|
(and (= :restriction type)
|
||||||
|
(= :email-domain-is-not-allowed code))
|
||||||
|
(st/emit! (ntf/error (tr "errors.email-domain-not-allowed"))
|
||||||
|
(modal/hide))
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(st/emit! (ntf/error (tr "errors.generic"))
|
(st/emit! (ntf/error (tr "errors.generic"))
|
||||||
(modal/hide)))))
|
(modal/hide)))))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user