Add clojure.tools.logging based logs for key functions

Signed-off-by: Snorre Magnus Davøen's avatarSnorre Magnus Davøen <snorre.davoen@nsd.no>
parent 542044f0
Pipeline #13785 passed with stage
in 30 seconds
{:paths ["src" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.9.0"}
buddy/buddy-core {:mvn/version "1.5.0"}
buddy/buddy-sign {:mvn/version "3.0.0"}
org.clojure/data.json {:mvn/version "0.2.6"}
org.clojure/algo.generic {:mvn/version "0.1.3"}
invetica/uri {:mvn/version "0.5.0"}}
:deps {org.clojure/clojure {:mvn/version "1.9.0"}
buddy/buddy-core {:mvn/version "1.5.0"}
buddy/buddy-sign {:mvn/version "3.0.0"}
org.clojure/data.json {:mvn/version "0.2.6"}
org.clojure/algo.generic {:mvn/version "0.1.3"}
org.clojure/tools.logging {:mvn/version "0.4.1"}
invetica/uri {:mvn/version "0.5.0"}}
:aliases {:test {:extra-paths ["test" "test-resources"]
:extra-deps {com.cognitect/test-runner {:git/url "https://github.com/cognitect-labs/test-runner.git"
:sha "028a6d41ac9ac5d5c405dfc38e4da6b4cc1255d5"}
......
......@@ -7,6 +7,7 @@
[clojure.java.io :refer [resource]]
[clojure.spec.gen.alpha :as gen]
[clojure.spec.alpha :as s]
[clojure.tools.logging :as log]
[invetica.uri :as uri]))
......@@ -89,12 +90,13 @@
"Fetches the jwks from the supplied jwks-url and converts to java Keys.
Returns a map keyed on key-id where each value is a RSAPublicKey object"
[jwks-url]
(log/info "Fetching keys from jwks-url" jwks-url)
(try (->> jwks-url
slurp
(#(json/read-str % :key-fn keyword))
jwks-edn->public-keys)
(catch Exception e false)))
(catch Exception e (do (log/error "Could not fetch jwks keys")
false))))
(def public-keys
"Atom to hold the public keys used for signature validation in memory for
......@@ -111,6 +113,7 @@
"Returns java.security.PublicKey given jwks-url and :kid in jwt-header.
If no key is found refreshes"
[jwks-url jwt-header]
(log/info "Resolving key " jwt-header " from " jwks-url)
(let [key-fn (fn [] (get @public-keys (:kid jwt-header)))]
(if-let [key (key-fn)]
key
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment