mirror of
https://github.com/penpot/penpot.git
synced 2025-07-13 20:57:16 +02:00
✨ Simplify internal props handling and telemetry.
This commit is contained in:
parent
fa852a1ab8
commit
b44dfc2d9d
8 changed files with 144 additions and 71 deletions
|
@ -5,7 +5,7 @@
|
|||
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
;; defined by the Mozilla Public License, v. 2.0.
|
||||
;;
|
||||
;; Copyright (c) 2020 UXBOX Labs SL
|
||||
;; Copyright (c) 2020-2021 UXBOX Labs SL
|
||||
|
||||
(ns app.tokens
|
||||
"Tokens generation service."
|
||||
|
@ -23,8 +23,6 @@
|
|||
|
||||
(defn- derive-tokens-secret
|
||||
[key]
|
||||
(when (= key "default")
|
||||
(log/warn "Using default PENPOT_SECRET_KEY, the system will generate insecure tokens."))
|
||||
(let [engine (bk/engine {:key key
|
||||
:salt "tokens"
|
||||
:alg :hkdf
|
||||
|
@ -57,14 +55,16 @@
|
|||
:params params))
|
||||
claims))
|
||||
|
||||
(s/def ::secret-key ::us/not-empty-string)
|
||||
|
||||
(defmethod ig/pre-init-spec ::tokens [_]
|
||||
(s/def ::secret-key ::us/string)
|
||||
(s/def ::sprops
|
||||
(s/keys :req-un [::secret-key]))
|
||||
|
||||
(defmethod ig/pre-init-spec ::tokens [_]
|
||||
(s/keys :req-un [::sprops]))
|
||||
|
||||
(defmethod ig/init-key ::tokens
|
||||
[_ cfg]
|
||||
(let [secret (derive-tokens-secret (:secret-key cfg))
|
||||
[_ {:keys [sprops] :as cfg}]
|
||||
(let [secret (derive-tokens-secret (:secret-key sprops))
|
||||
cfg (assoc cfg ::secret secret)]
|
||||
(fn [action params]
|
||||
(case action
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue