mirror of
https://github.com/penpot/penpot.git
synced 2025-01-09 00:10:11 -05:00
✨ Normalize external-session-id parsing from request
This commit is contained in:
parent
d52f2b18a5
commit
f4b59cc5a0
2 changed files with 37 additions and 11 deletions
|
@ -22,6 +22,7 @@
|
||||||
[app.http.errors :as errors]
|
[app.http.errors :as errors]
|
||||||
[app.http.session :as session]
|
[app.http.session :as session]
|
||||||
[app.loggers.audit :as audit]
|
[app.loggers.audit :as audit]
|
||||||
|
[app.rpc :as rpc]
|
||||||
[app.rpc.commands.profile :as profile]
|
[app.rpc.commands.profile :as profile]
|
||||||
[app.setup :as-alias setup]
|
[app.setup :as-alias setup]
|
||||||
[app.tokens :as tokens]
|
[app.tokens :as tokens]
|
||||||
|
@ -589,17 +590,28 @@
|
||||||
(redirect-to-register cfg info request)
|
(redirect-to-register cfg info request)
|
||||||
(redirect-with-error "registration-disabled")))))
|
(redirect-with-error "registration-disabled")))))
|
||||||
|
|
||||||
|
(defn- get-external-session-id
|
||||||
|
[request]
|
||||||
|
(let [session-id (rreq/get-header request "x-external-session-id")]
|
||||||
|
(when (string? session-id)
|
||||||
|
(if (or (> (count session-id) 256)
|
||||||
|
(= session-id "null")
|
||||||
|
(str/blank? session-id))
|
||||||
|
nil
|
||||||
|
session-id))))
|
||||||
|
|
||||||
(defn- auth-handler
|
(defn- auth-handler
|
||||||
[cfg {:keys [params] :as request}]
|
[cfg {:keys [params] :as request}]
|
||||||
(let [props (audit/extract-utm-params params)
|
(let [props (audit/extract-utm-params params)
|
||||||
esid (rreq/get-header request "x-external-session-id")
|
esid (rpc/get-external-session-id request)
|
||||||
state (tokens/generate (::setup/props cfg)
|
params {:iss :oauth
|
||||||
{:iss :oauth
|
:invitation-token (:invitation-token params)
|
||||||
:invitation-token (:invitation-token params)
|
:external-session-id esid
|
||||||
:external-session-id esid
|
:props props
|
||||||
:props props
|
:exp (dt/in-future "4h")}
|
||||||
:exp (dt/in-future "4h")})
|
state (tokens/generate (::setup/props cfg)
|
||||||
uri (build-auth-uri cfg state)]
|
(d/without-nils params))
|
||||||
|
uri (build-auth-uri cfg state)]
|
||||||
{::rres/status 200
|
{::rres/status 200
|
||||||
::rres/body {:redirect-uri uri}}))
|
::rres/body {:redirect-uri uri}}))
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,20 @@
|
||||||
(handle-response-transformation request mdata)
|
(handle-response-transformation request mdata)
|
||||||
(handle-before-comple-hook mdata))))
|
(handle-before-comple-hook mdata))))
|
||||||
|
|
||||||
|
(defn get-external-session-id
|
||||||
|
[request]
|
||||||
|
(when-let [session-id (rreq/get-header request "x-external-session-id")]
|
||||||
|
(when-not (or (> (count session-id) 256)
|
||||||
|
(= session-id "null")
|
||||||
|
(str/blank? session-id))
|
||||||
|
session-id)))
|
||||||
|
|
||||||
|
(defn- get-external-event-origin
|
||||||
|
[request]
|
||||||
|
(when-let [origin (rreq/get-header request "x-event-origin")]
|
||||||
|
(when-not (> (count origin) 256)
|
||||||
|
origin)))
|
||||||
|
|
||||||
(defn- rpc-handler
|
(defn- rpc-handler
|
||||||
"Ring handler that dispatches cmd requests and convert between
|
"Ring handler that dispatches cmd requests and convert between
|
||||||
internal async flow into ring async flow."
|
internal async flow into ring async flow."
|
||||||
|
@ -79,8 +93,8 @@
|
||||||
profile-id (or (::session/profile-id request)
|
profile-id (or (::session/profile-id request)
|
||||||
(::actoken/profile-id request))
|
(::actoken/profile-id request))
|
||||||
|
|
||||||
session-id (rreq/get-header request "x-external-session-id")
|
session-id (get-external-session-id request)
|
||||||
event-origin (rreq/get-header request "x-event-origin")
|
event-origin (get-external-event-origin request)
|
||||||
|
|
||||||
data (-> params
|
data (-> params
|
||||||
(assoc ::handler-name handler-name)
|
(assoc ::handler-name handler-name)
|
||||||
|
|
Loading…
Reference in a new issue