You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I added to my project the dependency [buddy/buddy-sign "1.1.0"] to implement authentication features. However, for some reason this simple example doesn't work (from the repl):
(require '[buddy.sign.jws :as jws])
;; this work
(jws/sign "a" "secret")
;; => "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXUyJ9.YQ.fbSW5D1FbwwcFijKn6aSghRHIwcpE102OKAvkfxsxls"
;; this doesn't work
(jws/sign {:a 100} "secret") ;; throws an error
And this is the error message: IllegalArgumentException No implementation of method: :-to-bytes of protocol: #'buddy.core.codecs/IByteArray found for class: clojure.lang.PersistentArrayMap clojure.core/-cache-protocol-fn (core_deftype.clj:568)
I am getting a similar error if I try to sign an integer: IllegalArgumentException No implementation of method: :-to-bytes of protocol: #'buddy.core.codecs/IByteArray found for class: java.lang.Long clojure.core/-cache-protocol-fn (core_deftype.clj:568)
Looking the sign implementation (from cursive), I see that it has a pre clause to enforce the use of a map as the claims container, which contradicts the results I am getting.
(defn sign
"Sign arbitrary length string/byte array using
json web token/signature."
;; The exp nbf and iat keys in the options are deprecated
;; and will be removed in the next version.
[claims pkey & [{:keys [alg typ] :or {alg :hs256 typ :jws} :as opts}]]
{:pre [(map? claims)]}
(let [header (encode-header alg typ)
claims (encode-claims claims opts)
signature (calculate-signature {:key pkey
:alg alg
:header header
:claims claims})]
(str/join "." [header claims signature])))
Any idea of what could be the problem?
The text was updated successfully, but these errors were encountered:
I added to my project the dependency [buddy/buddy-sign "1.1.0"] to implement authentication features. However, for some reason this simple example doesn't work (from the repl):
And this is the error message:
IllegalArgumentException No implementation of method: :-to-bytes of protocol: #'buddy.core.codecs/IByteArray found for class: clojure.lang.PersistentArrayMap clojure.core/-cache-protocol-fn (core_deftype.clj:568)
I am getting a similar error if I try to sign an integer:
IllegalArgumentException No implementation of method: :-to-bytes of protocol: #'buddy.core.codecs/IByteArray found for class: java.lang.Long clojure.core/-cache-protocol-fn (core_deftype.clj:568)
Looking the sign implementation (from cursive), I see that it has a
pre
clause to enforce the use of a map as the claims container, which contradicts the results I am getting.Any idea of what could be the problem?
The text was updated successfully, but these errors were encountered: