mirror of
https://github.com/penpot/penpot.git
synced 2025-05-10 19:26:38 +02:00
✨ Improve debug information of oidc provider.
This commit is contained in:
parent
5d2742dd37
commit
07e8bb00fb
1 changed files with 38 additions and 17 deletions
|
@ -268,14 +268,29 @@
|
||||||
|
|
||||||
(defn- discover-oidc-config
|
(defn- discover-oidc-config
|
||||||
[{:keys [base-uri] :as opts}]
|
[{:keys [base-uri] :as opts}]
|
||||||
|
|
||||||
(let [discovery-uri (u/join base-uri ".well-known/openid-configuration")
|
(let [discovery-uri (u/join base-uri ".well-known/openid-configuration")
|
||||||
response (http/send! {:method :get :uri (str discovery-uri)})]
|
response (ex/try (http/send! {:method :get :uri (str discovery-uri)}))]
|
||||||
(when (= 200 (:status response))
|
(cond
|
||||||
|
(ex/exception? response)
|
||||||
|
(do
|
||||||
|
(l/warn :hint "unable to discover oidc configuration"
|
||||||
|
:discover-uri (str discovery-uri)
|
||||||
|
:cause response)
|
||||||
|
nil)
|
||||||
|
|
||||||
|
(= 200 (:status response))
|
||||||
(let [data (json/read-str (:body response))]
|
(let [data (json/read-str (:body response))]
|
||||||
(assoc opts
|
{:token-uri (get data "token_endpoint")
|
||||||
:token-uri (get data "token_endpoint")
|
:auth-uri (get data "authorization_endpoint")
|
||||||
:auth-uri (get data "authorization_endpoint")
|
:user-uri (get data "userinfo_endpoint")})
|
||||||
:user-uri (get data "userinfo_endpoint"))))))
|
|
||||||
|
:else
|
||||||
|
(do
|
||||||
|
(l/warn :hint "unable to discover OIDC configuration"
|
||||||
|
:uri (str discovery-uri)
|
||||||
|
:response-status-code (:status response))
|
||||||
|
nil))))
|
||||||
|
|
||||||
(defn- obfuscate-string
|
(defn- obfuscate-string
|
||||||
[s]
|
[s]
|
||||||
|
@ -299,17 +314,23 @@
|
||||||
(if (and (string? (:base-uri opts))
|
(if (and (string? (:base-uri opts))
|
||||||
(string? (:client-id opts))
|
(string? (:client-id opts))
|
||||||
(string? (:client-secret opts)))
|
(string? (:client-secret opts)))
|
||||||
(if (and (string? (:token-uri opts))
|
(do
|
||||||
(string? (:user-uri opts))
|
(l/debug :hint "initialize oidc provider" :name "generic-oidc"
|
||||||
(string? (:auth-uri opts)))
|
:opts (update opts :client-secret obfuscate-string))
|
||||||
(do
|
(if (and (string? (:token-uri opts))
|
||||||
(l/info :action "initialize" :provider "oidc" :method "static"
|
(string? (:user-uri opts))
|
||||||
:opts (pr-str (update opts :client-secret obfuscate-string)))
|
(string? (:auth-uri opts)))
|
||||||
(assoc-in cfg [:providers "oidc"] opts))
|
(do
|
||||||
(let [opts (discover-oidc-config opts)]
|
(l/debug :hint "initialized with user provided configuration")
|
||||||
(l/info :action "initialize" :provider "oidc" :method "discover"
|
(assoc-in cfg [:providers "oidc"] opts))
|
||||||
:opts (pr-str (update opts :client-secret obfuscate-string)))
|
(do
|
||||||
(assoc-in cfg [:providers "oidc"] opts)))
|
(l/debug :hint "trying to discover oidc provider configuration using BASE_URI")
|
||||||
|
(if-let [opts' (discover-oidc-config opts)]
|
||||||
|
(do
|
||||||
|
(l/debug :hint "discovered opts" :additional-opts opts')
|
||||||
|
(assoc-in cfg [:providers "oidc"] (merge opts opts')))
|
||||||
|
|
||||||
|
cfg))))
|
||||||
cfg)))
|
cfg)))
|
||||||
|
|
||||||
(defn- initialize-google-provider
|
(defn- initialize-google-provider
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue