#5 bug fix for claims containing string key
This commit is contained in:
parent
fc1ae52a92
commit
c611871156
3 changed files with 13 additions and 4 deletions
|
@ -1,4 +1,4 @@
|
|||
(defproject clj-jwt "0.0.6"
|
||||
(defproject clj-jwt "0.0.7"
|
||||
:description "Clojure library for JSON Web Token(JWT)"
|
||||
:url "https://github.com/liquidz/clj-jwt"
|
||||
:license {:name "Eclipse Public License"
|
||||
|
|
|
@ -7,8 +7,11 @@
|
|||
[clojure.string :as str]))
|
||||
|
||||
(def ^:private DEFAULT_SIGNATURE_ALGORITHM :HS256)
|
||||
(def ^:private map->encoded-json (comp url-safe-encode-str json/write-str))
|
||||
(def ^:private encoded-json->map (comp #(json/read-str % :key-fn keyword) url-safe-decode-str))
|
||||
(def ^:private full-key-name #(subs (str %) 1))
|
||||
(def ^:private map->encoded-json (comp url-safe-encode-str
|
||||
#(json/write-str % :key-fn full-key-name)))
|
||||
(def ^:private encoded-json->map (comp #(json/read-str % :key-fn keyword)
|
||||
url-safe-decode-str))
|
||||
(defn- update-map [m k f] (if (contains? m k) (update-in m [k] f) m))
|
||||
|
||||
(defrecord JWT [header claims signature])
|
||||
|
|
|
@ -147,7 +147,13 @@
|
|||
|
||||
(fact "ES512 signed JWT shoud be verified."
|
||||
(-> claim jwt (sign :ES512 ec-prv-key) (verify ec-pub-key)) => true
|
||||
(-> claim jwt (sign :ES512 ec-prv-key) to-str str->jwt (verify ec-pub-key)) => true))
|
||||
(-> claim jwt (sign :ES512 ec-prv-key) to-str str->jwt (verify ec-pub-key)) => true)
|
||||
|
||||
(fact "Claims containing string key should be verified"
|
||||
(let [sclaim {"a/b" "c"}]
|
||||
(-> sclaim jwt (sign "foo") (verify "foo")) => true
|
||||
(-> sclaim jwt (sign "foo") to-str str->jwt (verify "foo")) => true
|
||||
(-> sclaim jwt (sign "foo") (verify "bar")) => false)))
|
||||
|
||||
|
||||
(facts "str->jwt function should work."
|
||||
|
|
Loading…
Reference in a new issue