mirror of
https://github.com/penpot/penpot.git
synced 2025-01-23 23:18:48 -05:00
⏪ Revert some changes related to admin that are no longer necessary
This commit is contained in:
parent
44102050ee
commit
bafe3ec087
11 changed files with 6 additions and 180 deletions
|
@ -106,9 +106,6 @@
|
|||
(s/def ::file-change-snapshot-every ::us/integer)
|
||||
(s/def ::file-change-snapshot-timeout ::dt/duration)
|
||||
|
||||
(s/def ::setup-admin-email ::us/email)
|
||||
(s/def ::setup-admin-password ::us/not-empty-string)
|
||||
|
||||
(s/def ::default-executor-parallelism ::us/integer)
|
||||
(s/def ::scheduled-executor-parallelism ::us/integer)
|
||||
|
||||
|
@ -314,9 +311,6 @@
|
|||
::srepl-host
|
||||
::srepl-port
|
||||
|
||||
::setup-admin-email
|
||||
::setup-admin-password
|
||||
|
||||
::assets-storage-backend
|
||||
::storage-assets-fs-directory
|
||||
::storage-assets-s3-bucket
|
||||
|
|
|
@ -408,9 +408,6 @@
|
|||
{:port (cf/get :srepl-port)
|
||||
:host (cf/get :srepl-host)}
|
||||
|
||||
:app.setup/initial-profile
|
||||
{::db/pool (ig/ref ::db/pool)}
|
||||
|
||||
:app.setup/builtin-templates
|
||||
{::http.client/client (ig/ref ::http.client/client)}
|
||||
|
||||
|
|
|
@ -299,9 +299,6 @@
|
|||
{:name "0096-del-storage-pending-table"
|
||||
:fn (mg/resource "app/migrations/sql/0096-del-storage-pending-table.sql")}
|
||||
|
||||
{:name "0097-mod-profile-table"
|
||||
:fn (mg/resource "app/migrations/sql/0097-mod-profile-table.sql")}
|
||||
|
||||
{:name "0098-add-quotes-table"
|
||||
:fn (mg/resource "app/migrations/sql/0098-add-quotes-table.sql")}
|
||||
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
ALTER TABLE profile
|
||||
ADD COLUMN is_admin boolean DEFAULT false;
|
|
@ -290,7 +290,6 @@
|
|||
(let [cfg (assoc cfg ::type "command" ::metrics-id :rpc-command-timing)]
|
||||
(->> (sv/scan-ns 'app.rpc.commands.binfile
|
||||
'app.rpc.commands.comments
|
||||
'app.rpc.commands.profile
|
||||
'app.rpc.commands.management
|
||||
'app.rpc.commands.verify-token
|
||||
'app.rpc.commands.search
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
;; ---- COMMAND: login with password
|
||||
|
||||
(defn login-with-password
|
||||
[{:keys [::db/pool session] :as cfg} {:keys [email password scope] :as params}]
|
||||
[{:keys [::db/pool session] :as cfg} {:keys [email password] :as params}]
|
||||
|
||||
(when-not (or (contains? cf/flags :login)
|
||||
(contains? cf/flags :login-with-password))
|
||||
|
@ -119,17 +119,8 @@
|
|||
;; accept invitation with other email
|
||||
response (if (and (some? invitation) (= (:id profile) (:member-id invitation)))
|
||||
{:invitation-token (:invitation-token params)}
|
||||
(update profile :is-admin (fn [admin?]
|
||||
(or admin?
|
||||
(let [admins (cf/get :admins)]
|
||||
(contains? admins (:email profile)))))))]
|
||||
|
||||
(when (and (nil? (:default-team-id profile))
|
||||
(not= scope "admin"))
|
||||
(ex/raise :type :restriction
|
||||
:code :admin-only-profile
|
||||
:hint "can't login with admin-only profile"))
|
||||
|
||||
(assoc profile :is-admin (let [admins (cf/get :admins)]
|
||||
(contains? admins (:email profile)))))]
|
||||
(-> response
|
||||
(rph/with-transform (session/create-fn session (:id profile)))
|
||||
(rph/with-meta {::audit/props (audit/profile->props profile)
|
||||
|
|
|
@ -1,75 +0,0 @@
|
|||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) KALEIDOS INC
|
||||
|
||||
(ns app.rpc.commands.profile
|
||||
(:require
|
||||
[app.auth :as auth]
|
||||
[app.common.exceptions :as ex]
|
||||
[app.common.spec :as us]
|
||||
[app.config :as cf]
|
||||
[app.db :as db]
|
||||
[app.rpc :as-alias rpc]
|
||||
[app.rpc.climit :as-alias climit]
|
||||
[app.rpc.doc :as-alias doc]
|
||||
[app.util.services :as sv]
|
||||
[clojure.spec.alpha :as s]))
|
||||
|
||||
;; --- MUTATION: Set profile password
|
||||
|
||||
(declare update-profile-password!)
|
||||
|
||||
(s/def ::profile-id ::us/uuid)
|
||||
(s/def ::password ::us/not-empty-string)
|
||||
|
||||
(s/def ::get-derived-password
|
||||
(s/keys :req [::rpc/profile-id]
|
||||
:req-un [::password]))
|
||||
|
||||
(sv/defmethod ::get-derived-password
|
||||
"Get derived password, only ADMINS allowed to call this RPC
|
||||
methods. Designed for administration pannel integration."
|
||||
{::climit/queue :auth
|
||||
::climit/key-fn ::rpc/profile-id
|
||||
::doc/added "1.18"}
|
||||
[{:keys [::db/pool]} {:keys [::rpc/profile-id password]}]
|
||||
(db/with-atomic [conn pool]
|
||||
(let [admins (cf/get :admins)
|
||||
profile (db/get-by-id conn :profile profile-id)]
|
||||
|
||||
(if (or (:is-admin profile)
|
||||
(contains? admins (:email profile)))
|
||||
{:password (auth/derive-password password)}
|
||||
(ex/raise :type :authentication
|
||||
:code :only-admins-allowed
|
||||
:hint "only admins allowed to call this RPC method")))))
|
||||
|
||||
;; --- MUTATION: Check profile password
|
||||
|
||||
(s/def ::attempt ::us/not-empty-string)
|
||||
(s/def ::check-profile-password
|
||||
(s/keys :req [::rpc/profile-id]
|
||||
:req-un [::profile-id ::password]))
|
||||
|
||||
(sv/defmethod ::check-profile-password
|
||||
"Check profile password, only ADMINS allowed to call this RPC
|
||||
methods. Designed for administration pannel integration."
|
||||
{::climit/queue :auth
|
||||
::climit/key-fn ::rpc/profile-id
|
||||
::doc/added "1.18"}
|
||||
[{:keys [::db/pool]} {:keys [profile-id password] :as params}]
|
||||
(db/with-atomic [conn pool]
|
||||
(let [admins (cf/get :admins)
|
||||
profile (db/get-by-id pool :profile (::rpc/profile-id params))]
|
||||
|
||||
(if (or (:is-admin profile)
|
||||
(contains? admins (:email profile)))
|
||||
(let [profile (if (not= (::rpc/profile-id params) profile-id)
|
||||
(db/get-by-id conn :profile profile-id)
|
||||
profile)]
|
||||
(auth/verify-password password (:password profile)))
|
||||
(ex/raise :type :authentication
|
||||
:code :only-admins-allowed
|
||||
:hint "only admins allowed to call this RPC method")))))
|
|
@ -13,7 +13,6 @@
|
|||
[app.db :as db]
|
||||
[app.main :as-alias main]
|
||||
[app.setup.builtin-templates]
|
||||
[app.setup.initial-user]
|
||||
[app.setup.keys :as keys]
|
||||
[buddy.core.codecs :as bc]
|
||||
[buddy.core.nonce :as bn]
|
||||
|
@ -69,5 +68,5 @@
|
|||
(let [secret (or key (generate-random-key))]
|
||||
(-> (retrieve-all conn)
|
||||
(assoc :secret-key secret)
|
||||
(assoc :tokens-key (keys/derive secret :salt "tokens" :size 32))
|
||||
(assoc :tokens-key (keys/derive secret :salt "tokens"))
|
||||
(update :instance-id handle-instance-id conn (db/read-only? pool))))))
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) KALEIDOS INC
|
||||
|
||||
(ns app.setup.initial-user
|
||||
"Initial data setup of instance."
|
||||
(:require
|
||||
[app.auth :as auth]
|
||||
[app.common.logging :as l]
|
||||
[app.config :as cf]
|
||||
[app.db :as db]
|
||||
[app.setup :as-alias setup]
|
||||
[clojure.spec.alpha :as s]
|
||||
[integrant.core :as ig]))
|
||||
|
||||
(def ^:private sql:insert-profile
|
||||
"insert into profile (id, fullname, email, password, is_active, is_admin, created_at, modified_at)
|
||||
values ('00000000-0000-0000-0000-000000000000', 'Admin', ?, ?, true, true, now(), now())
|
||||
on conflict (id)
|
||||
do update set email = ?, password = ?")
|
||||
|
||||
(defmethod ig/pre-init-spec ::setup/initial-profile [_]
|
||||
(s/keys :req [::db/pool]))
|
||||
|
||||
(defmethod ig/init-key ::setup/initial-profile
|
||||
[_ {:keys [::db/pool]}]
|
||||
(let [email (cf/get :setup-admin-email)
|
||||
password (cf/get :setup-admin-password)]
|
||||
(when (and email password)
|
||||
(db/with-atomic [conn pool]
|
||||
(let [pwd (auth/derive-password password)]
|
||||
(db/exec-one! conn [sql:insert-profile email pwd email pwd])
|
||||
(l/info :hint "setting initial user (admin)"
|
||||
:email email
|
||||
:password "********"))))
|
||||
nil))
|
||||
|
||||
|
|
@ -11,9 +11,10 @@
|
|||
[app.common.spec :as us]
|
||||
[buddy.core.kdf :as bk]))
|
||||
|
||||
|
||||
(defn derive
|
||||
"Derive a key from secret-key"
|
||||
[secret-key & {:keys [salt size]}]
|
||||
[secret-key & {:keys [salt size] :or {size 32}}]
|
||||
(us/assert! ::us/not-empty-string secret-key)
|
||||
(let [engine (bk/engine {:key secret-key
|
||||
:salt salt
|
||||
|
|
|
@ -137,15 +137,6 @@ services:
|
|||
environment:
|
||||
- PENPOT_FLAGS=enable-registration enable-login disable-email-verification enable-smtp
|
||||
|
||||
## Setup initial administration user, uncommit only if you are
|
||||
## going to use the penpot-admin; Once uncommented, the special
|
||||
## user will be created on application start. This user can only
|
||||
## be used for access admin, you will not be able to login with
|
||||
## it on penpot application.
|
||||
|
||||
# - PENPOT_SETUP_ADMIN_EMAIL=admin@example.com
|
||||
# - PENPOT_SETUP_ADMIN_PASSWORD=password
|
||||
|
||||
## Public URI. If you are going to expose this instance to the
|
||||
## internet, or use it under different domain than 'localhost'
|
||||
## consider using traefik and set the
|
||||
|
@ -240,32 +231,6 @@ services:
|
|||
networks:
|
||||
- penpot
|
||||
|
||||
## An optional admin application for pentpot. It allows manage
|
||||
## users, teams and inspect some parts of the database. You can read
|
||||
## more about it on: https://github.com/penpot/penpot-admin
|
||||
##
|
||||
## Status: EXPERIMENTAL
|
||||
|
||||
# penpot-admin:
|
||||
# image: "penpotapp/admin:alpha"
|
||||
# networks:
|
||||
# - penpot
|
||||
#
|
||||
# depends_on:
|
||||
# - penpot-postgres
|
||||
# - penpot-backend
|
||||
#
|
||||
# environment:
|
||||
# - PENPOT_PUBLIC_URI=http://localhost:9001
|
||||
# - PENPOT_API_URI=http://penpot-frontend/
|
||||
#
|
||||
# - PENPOT_DATABASE_HOST=penpot-postgres
|
||||
# - PENPOT_DATABASE_NAME=penpot
|
||||
# - PENPOT_DATABASE_USERNAME=penpot
|
||||
# - PENPOT_DATABASE_PASSWORD=penpot
|
||||
# - PENPOT_REDIS_URI=redis://penpot-redis/0
|
||||
# - PENPOT_DEBUG="false"
|
||||
|
||||
## A mailcatch service, used as temporal SMTP server. You can access
|
||||
## via HTTP to the port 1080 for read all emails the penpot platform
|
||||
## has sent. Should be only used as a temporal solution meanwhile
|
||||
|
|
Loading…
Add table
Reference in a new issue