Commit 8973c285 authored by Snorre Magnus Davøen's avatar Snorre Magnus Davøen 💬

Merge branch 'hotfix/jwt-gen' into 'master'

Added generator for ::jwt

See merge request !1
parents 96949ec0 07dc1746
Pipeline #13812 passed with stage
in 28 seconds
......@@ -18,5 +18,5 @@
clojure-term-colors {:mvn/version "0.1.0"}}
:extra-paths ["test" "test-resources"]
:main-opts ["-m exerciser"]}
:jar {:extra-deps {luchiniatwork/cambada {:mvn/version "1.0.0"}}
:main-opts ["-m" "cambada.jar"]}}}
:jar {:extra-deps {luchiniatwork/cambada {:mvn/version "1.0.0"}}
:main-opts ["-m" "cambada.jar"]}}}
......@@ -42,8 +42,10 @@
::scopes
::sub])))
(s/def ::jwt (s/nilable (s/and string?
#(re-matches jwtregex %))))
(s/def ::jwt (s/nilable (s/with-gen (s/and string?
#(re-matches jwtregex %))
#(s/gen #{(jwt/sign (gen/generate (s/gen ::claims))
"secret")}))))
(s/def ::jwt-header (s/keys :req-un [::kid ::kty]))
......@@ -78,13 +80,13 @@
(s/fdef fetch-keys
:args (s/cat :jwks-url ::jwks-url)
:ret (s/with-gen ::key-store
#(s/gen #{(->> (resource "jwks.json")
slurp
((fn [jwks-string] (json/read-str jwks-string :key-fn keyword)))
jwks-edn->public-keys)})))
:args (s/cat :jwks-url ::jwks-url)
:ret (s/with-gen ::key-store
#(s/gen #{(->> (resource "jwks.json")
slurp
((fn [jwks-string] (json/read-str jwks-string :key-fn keyword)))
jwks-edn->public-keys)})))
(defn- fetch-keys
"Fetches the jwks from the supplied jwks-url and converts to java Keys.
......@@ -128,7 +130,6 @@
"Given token, jwks-url, and optionally opts validates and returns the claims
of the given json web token. Opts are the same as buddy-sign.jwt/unsign."
([token jwks-url]
(unsign token jwks-url {}))
(unsign token jwks-url {}))
([token jwks-url opts]
(jwt/unsign token (partial resolve-key jwks-url) (merge {:alg :rs256} opts))))
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