Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/staging' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
niwinz committed Jul 25, 2024
2 parents e5daa00 + 5ed4999 commit 025034c
Show file tree
Hide file tree
Showing 21 changed files with 197 additions and 162 deletions.
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@

## 2.1.1

### :sparkles: New features

- Consolidate templates new order and naming [Taiga #8392](https://tree.taiga.io/project/penpot/task/8392)

### :bug: Bugs fixed

- Fix the “search” label in translations [Taiga #8402](https://tree.taiga.io/project/penpot/issue/8402)
- Fix pencil loader [Taiga #8348](https://tree.taiga.io/project/penpot/issue/8348)
- Fix several issues on the OIDC.
- Fix regression on the `email-verification` flag [Taiga #8398](https://tree.taiga.io/project/penpot/issue/8398)

## 2.1.0 - Things can only get better!

Expand Down
28 changes: 14 additions & 14 deletions backend/resources/app/onboarding.edn
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
[{:id "tutorial-for-beginners"
[{:id "wireframing-kit"
:name "Wireframe library"
:file-uri "https://github.com/penpot/penpot-files/raw/binary-files/wireframing-kit.penpot"}
{:id "prototype-examples"
:name "Prototipe template"
:file-uri "https://github.com/penpot/penpot-files/raw/binary-files/prototype-examples.penpot"}
{:id "plants-app"
:name "UI mockup example"
:file-uri "https://github.com/penpot/penpot-files/raw/binary-files/Plants-app.penpot"}
{:id "penpot-design-system"
:name "Design system example"
:file-uri "https://github.com/penpot/penpot-files/raw/binary-files/Penpot-Design-system.penpot"}
{:id "tutorial-for-beginners"
:name "Tutorial for beginners"
:file-uri "https://github.com/penpot/penpot-files/raw/binary-files/tutorial-for-beginners.penpot"}
{:id "lucide-icons"
Expand All @@ -7,12 +19,6 @@
{:id "font-awesome"
:name "Font Awesome"
:file-uri "https://github.com/penpot/penpot-files/raw/binary-files/Font-Awesome.penpot"}
{:id "plants-app"
:name "Plants app"
:file-uri "https://github.com/penpot/penpot-files/raw/binary-files/Plants-app.penpot"}
{:id "wireframing-kit"
:name "Wireframing Kit"
:file-uri "https://github.com/penpot/penpot-files/raw/binary-files/wireframing-kit.penpot"}
{:id "black-white-mobile-templates"
:name "Black & White Mobile Templates"
:file-uri "https://github.com/penpot/penpot-files/raw/binary-files/Black-White-Mobile-Templates.penpot"}
Expand All @@ -30,10 +36,4 @@
:file-uri "https://github.com/penpot/penpot-files/raw/binary-files/Open-Color-Scheme.penpot"}
{:id "flex-layout-playground"
:name "Flex Layout Playground"
:file-uri "https://github.com/penpot/penpot-files/raw/binary-files/Flex-Layout-Playground.penpot"}
{:id "prototype-examples"
:name "Prototipe template"
:file-uri "https://github.com/penpot/penpot-files/raw/binary-files/prototype-examples.penpot"}
{:id "penpot-design-system"
:name "Design system example"
:file-uri "https://github.com/penpot/penpot-files/raw/binary-files/Penpot-Design-system.penpot"}]
:file-uri "https://github.com/penpot/penpot-files/raw/binary-files/Flex-Layout-Playground.penpot"}]
5 changes: 3 additions & 2 deletions backend/src/app/auth/oidc.clj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
[app.rpc.commands.profile :as profile]
[app.setup :as-alias setup]
[app.tokens :as tokens]
[app.util.inet :as inet]
[app.util.json :as json]
[app.util.time :as dt]
[buddy.sign.jwk :as jwk]
Expand Down Expand Up @@ -571,10 +572,10 @@
props (audit/profile->props profile)
context (d/without-nils {:external-session-id (:external-session-id info)})]

(audit/submit! cfg {::audit/type "command"
(audit/submit! cfg {::audit/type "action"
::audit/name "login-with-oidc"
::audit/profile-id (:id profile)
::audit/ip-addr (audit/parse-client-ip request)
::audit/ip-addr (inet/parse-request request)
::audit/props props
::audit/context context})

Expand Down
42 changes: 18 additions & 24 deletions backend/src/app/loggers/audit.clj
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,18 @@
[app.rpc :as-alias rpc]
[app.rpc.retry :as rtry]
[app.setup :as-alias setup]
[app.util.inet :as inet]
[app.util.services :as-alias sv]
[app.util.time :as dt]
[app.worker :as wrk]
[clojure.spec.alpha :as s]
[cuerdas.core :as str]
[integrant.core :as ig]
[ring.request :as rreq]))
[integrant.core :as ig]))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; HELPERS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defn parse-client-ip
[request]
(let [ip-addr (or (some-> (rreq/get-header request "x-forwarded-for") (str/split ",") first)
(rreq/get-header request "x-real-ip")
(some-> (rreq/remote-addr request) str))
ip-addr (-> ip-addr
(str/split ":" 2)
(first))]
ip-addr))

(defn extract-utm-params
"Extracts additional data from params and namespace them under
`penpot` ns."
Expand Down Expand Up @@ -90,17 +80,20 @@
(remove #(contains? reserved-props (key %))))
props))

(defn params->context
"Extract default context properties from RPC params object"
(defn event-from-rpc-params
"Create a base event skeleton with pre-filled some important
data that can be extracted from RPC params object"
[params]
(d/without-nils
{:external-session-id (::rpc/external-session-id params)
:event-origin (::rpc/external-event-origin params)
:triggered-by (::rpc/handler-name params)}))
(let [context {:external-session-id (::rpc/external-session-id params)
:external-event-origin (::rpc/external-event-origin params)
:triggered-by (::rpc/handler-name params)}]
{::type "action"
::profile-id (::rpc/profile-id params)
::ip-addr (::rpc/ip-addr params)
::context (d/without-nils context)}))

;; --- SPECS


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; COLLECTOR
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand Down Expand Up @@ -167,14 +160,16 @@
(assoc :external-session-id session-id)
(assoc :external-event-origin event-origin)
(assoc :access-token-id (some-> token-id str))
(d/without-nils))]
(d/without-nils))

ip-addr (inet/parse-request request)]

{::type (or (::type resultm)
(::rpc/type cfg))
::name (or (::name resultm)
(::sv/name mdata))
::profile-id profile-id
::ip-addr (some-> request parse-client-ip)
::ip-addr ip-addr
::props props
::context context

Expand Down Expand Up @@ -202,7 +197,7 @@
:name (::name event)
:type (::type event)
:profile-id (::profile-id event)
:ip-addr (::ip-addr event "0.0.0.0")
:ip-addr (::ip-addr event)
:context (::context event {})
:props (::props event {})
:source "backend"}
Expand Down Expand Up @@ -246,8 +241,7 @@
(assoc :created-at tnow)
(update :tracked-at #(or % tnow))
(assoc :props {})
(assoc :context {})
(assoc :ip-addr "0.0.0.0"))]
(assoc :context {}))]
(append-audit-entry! cfg params)))

(when (and (contains? cf/flags :webhooks)
Expand Down
7 changes: 6 additions & 1 deletion backend/src/app/rpc.clj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
[app.rpc.rlimit :as rlimit]
[app.setup :as-alias setup]
[app.storage :as-alias sto]
[app.util.inet :as inet]
[app.util.services :as sv]
[app.util.time :as dt]
[clojure.spec.alpha :as s]
Expand Down Expand Up @@ -81,7 +82,9 @@
(defn- get-external-event-origin
[request]
(when-let [origin (rreq/get-header request "x-event-origin")]
(when-not (> (count origin) 256)
(when-not (or (> (count origin) 256)
(= origin "null")
(str/blank? origin))
origin)))

(defn- rpc-handler
Expand All @@ -93,11 +96,13 @@
profile-id (or (::session/profile-id request)
(::actoken/profile-id request))

ip-addr (inet/parse-request request)
session-id (get-external-session-id request)
event-origin (get-external-event-origin request)

data (-> params
(assoc ::handler-name handler-name)
(assoc ::ip-addr ip-addr)
(assoc ::request-at (dt/now))
(assoc ::external-session-id session-id)
(assoc ::external-event-origin event-origin)
Expand Down
5 changes: 3 additions & 2 deletions backend/src/app/rpc/commands/audit.clj
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
[app.config :as cf]
[app.db :as db]
[app.http :as-alias http]
[app.loggers.audit :as audit]
[app.loggers.audit :as-alias audit]
[app.rpc :as-alias rpc]
[app.rpc.climit :as-alias climit]
[app.rpc.doc :as-alias doc]
[app.rpc.helpers :as rph]
[app.util.inet :as inet]
[app.util.services :as sv]
[app.util.time :as dt]))

Expand Down Expand Up @@ -61,7 +62,7 @@
(defn- handle-events
[{:keys [::db/pool]} {:keys [::rpc/profile-id events] :as params}]
(let [request (-> params meta ::http/request)
ip-addr (audit/parse-client-ip request)
ip-addr (inet/parse-request request)
tnow (dt/now)
xform (comp
(map (fn [event]
Expand Down
9 changes: 6 additions & 3 deletions backend/src/app/rpc/commands/auth.clj
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,17 @@

profile (if-let [profile-id (:profile-id claims)]
(profile/get-profile conn profile-id)
(let [is-active (or (boolean (:is-active params))
(let [is-active (or (boolean (:is-active claims))
(not (contains? cf/flags :email-verification)))
params (-> params
(assoc :is-active is-active)
(update :password #(profile/derive-password cfg %)))]
(->> (create-profile! conn params)
(create-profile-rels! conn))))

;; When no profile-id comes on claims means a new register
created? (not (:profile-id claims))

invitation (when-let [token (:invitation-token params)]
(tokens/verify (::setup/props cfg) {:token token :iss :team-invitation}))

Expand Down Expand Up @@ -385,8 +388,8 @@
;; When a new user is created and it is already activated by
;; configuration or specified by OIDC, we just mark the profile
;; as logged-in
(not (:profile-id claims))
(if (:is-active claims)
created?
(if (:is-active profile)
(-> (profile/strip-private-attrs profile)
(rph/with-transform (session/create-fn cfg (:id profile)))
(rph/with-meta
Expand Down
14 changes: 6 additions & 8 deletions backend/src/app/rpc/commands/management.clj
Original file line number Diff line number Diff line change
Expand Up @@ -413,15 +413,13 @@
{:modified-at (dt/now)}
{:id project-id})

(let [props (audit/clean-props params)
context (audit/params->context params)]
(let [props (audit/clean-props params)]
(doseq [file-id result]
(audit/submit! cfg
{::audit/type "action"
::audit/name "create-file"
::audit/profile-id profile-id
::audit/props (assoc props :id file-id)
::audit/context context})))
(let [props (assoc props :id file-id)
event (-> (audit/event-from-rpc-params params)
(assoc ::audit/name "create-file")
(assoc ::audit/props props))]
(audit/submit! cfg event))))

result))))

Expand Down
Loading

0 comments on commit 025034c

Please sign in to comment.