mirror of
https://github.com/penpot/penpot.git
synced 2025-05-15 07:16:37 +02:00
✨ Improve get-user-info implementation (oidc)
This commit is contained in:
parent
b3f0683d02
commit
c39702fbf7
1 changed files with 7 additions and 6 deletions
|
@ -391,13 +391,14 @@
|
||||||
(defn- get-user-info
|
(defn- get-user-info
|
||||||
[{:keys [provider]} tdata]
|
[{:keys [provider]} tdata]
|
||||||
(try
|
(try
|
||||||
(let [{:keys [kid alg] :as theader} (jwt/decode-header (:token/id tdata))]
|
(when (:token/id tdata)
|
||||||
(when-let [key (if (str/starts-with? (name alg) "hs")
|
(let [{:keys [kid alg] :as theader} (jwt/decode-header (:token/id tdata))]
|
||||||
(:client-secret provider)
|
(when-let [key (if (str/starts-with? (name alg) "hs")
|
||||||
(get-in provider [:jwks kid]))]
|
(:client-secret provider)
|
||||||
|
(get-in provider [:jwks kid]))]
|
||||||
|
|
||||||
(let [claims (jwt/unsign (:token/id tdata) key {:alg alg})]
|
(let [claims (jwt/unsign (:token/id tdata) key {:alg alg})]
|
||||||
(dissoc claims :exp :iss :iat :sid :aud :sub))))
|
(dissoc claims :exp :iss :iat :sid :aud :sub)))))
|
||||||
(catch Throwable cause
|
(catch Throwable cause
|
||||||
(l/warn :hint "unable to get user info from JWT token (unexpected exception)"
|
(l/warn :hint "unable to get user info from JWT token (unexpected exception)"
|
||||||
:cause cause))))
|
:cause cause))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue