see #9 code refinement
This commit is contained in:
parent
9da81ace39
commit
63244e4330
2 changed files with 2 additions and 7 deletions
|
@ -69,10 +69,7 @@
|
||||||
([this key]
|
([this key]
|
||||||
(let [alg (-> this :header :alg keyword)]
|
(let [alg (-> this :header :alg keyword)]
|
||||||
(cond
|
(cond
|
||||||
(and (= :none alg) (not (= "" key)))
|
(= :none alg) (= "" key (:signature this))
|
||||||
false
|
|
||||||
|
|
||||||
(= :none alg) (= "" (:signature this))
|
|
||||||
|
|
||||||
(supported-algorithm? alg)
|
(supported-algorithm? alg)
|
||||||
(let [verify-fn (get-verify-fn alg)
|
(let [verify-fn (get-verify-fn alg)
|
||||||
|
|
|
@ -93,24 +93,22 @@
|
||||||
(fact "Plain JWT should be verified."
|
(fact "Plain JWT should be verified."
|
||||||
(-> claim jwt verify) => true
|
(-> claim jwt verify) => true
|
||||||
(-> claim jwt to-str str->jwt verify) => true
|
(-> claim jwt to-str str->jwt verify) => true
|
||||||
|
(-> claim jwt to-str str->jwt (verify "foo")) => false
|
||||||
(-> claim jwt (assoc :signature "foo") verify) => false)
|
(-> claim jwt (assoc :signature "foo") verify) => false)
|
||||||
|
|
||||||
(fact "HS256 signed JWT should be verified."
|
(fact "HS256 signed JWT should be verified."
|
||||||
(-> claim jwt (sign "foo") (verify "foo")) => true
|
(-> claim jwt (sign "foo") (verify "foo")) => true
|
||||||
(-> claim jwt (sign "foo") to-str str->jwt (verify "foo")) => true
|
(-> claim jwt (sign "foo") to-str str->jwt (verify "foo")) => true
|
||||||
(-> claim jwt to-str str->jwt (verify "foo")) => false
|
|
||||||
(-> claim jwt (sign "foo") (verify "bar")) => false)
|
(-> claim jwt (sign "foo") (verify "bar")) => false)
|
||||||
|
|
||||||
(fact "HS384 signed JWT should be verified."
|
(fact "HS384 signed JWT should be verified."
|
||||||
(-> claim jwt (sign :HS384 "foo") (verify "foo")) => true
|
(-> claim jwt (sign :HS384 "foo") (verify "foo")) => true
|
||||||
(-> claim jwt (sign :HS384 "foo") to-str str->jwt (verify "foo")) => true
|
(-> claim jwt (sign :HS384 "foo") to-str str->jwt (verify "foo")) => true
|
||||||
(-> claim jwt to-str str->jwt (verify "foo")) => false
|
|
||||||
(-> claim jwt (sign :HS384 "foo") (verify "bar")) => false)
|
(-> claim jwt (sign :HS384 "foo") (verify "bar")) => false)
|
||||||
|
|
||||||
(fact "HS512 signed JWT should be verified."
|
(fact "HS512 signed JWT should be verified."
|
||||||
(-> claim jwt (sign :HS512 "foo") (verify "foo")) => true
|
(-> claim jwt (sign :HS512 "foo") (verify "foo")) => true
|
||||||
(-> claim jwt (sign :HS512 "foo") to-str str->jwt (verify "foo")) => true
|
(-> claim jwt (sign :HS512 "foo") to-str str->jwt (verify "foo")) => true
|
||||||
(-> claim jwt to-str str->jwt (verify "foo")) => false
|
|
||||||
(-> claim jwt (sign :HS512 "foo") (verify "bar")) => false)
|
(-> claim jwt (sign :HS512 "foo") (verify "bar")) => false)
|
||||||
|
|
||||||
(fact "RS256 signed JWT should be verified."
|
(fact "RS256 signed JWT should be verified."
|
||||||
|
|
Loading…
Reference in a new issue