Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Implementation of -to-bytes on PersistentArrayMap #34

Closed
alexanderkiel opened this issue Jun 19, 2016 · 2 comments
Closed

Missing Implementation of -to-bytes on PersistentArrayMap #34

alexanderkiel opened this issue Jun 19, 2016 · 2 comments

Comments

@alexanderkiel
Copy link

The documentation has the following example:

(require '[buddy.sign.jws :as jws])

(jws/sign {:userid 1} "secret")
;; "eyJ0eXAiOiJKV1MiLCJhbGciOiJIU..."

If I run this, I get the following error:

CompilerException java.lang.IllegalArgumentException: No implementation of method: :-to-bytes of protocol: #'buddy.core.codecs/IByteArray found for class: clojure.lang.PersistentArrayMap

The implementation could look something like this (encoded as JSON for JWT):

(extend-protocol buddy.core.codecs/IByteArray
    IPersistentMap
    (-to-bytes [m]
      (buddy.core.codecs/-to-bytes (cheshire.core/generate-string m))))

I'm not sure about the JSON part because I currently don't understand weather JWS has always a JSON payload. I suspect no.

@alexanderkiel
Copy link
Author

I found in the changeling that I have to replace the namespace buddy.sign.jws with buddy.sign.jwt. Than everything works as expected.

I think you should make this clear in the doc.

@niwinz
Copy link
Member

niwinz commented Jun 20, 2016

I just updated the doc (related #33).

@niwinz niwinz closed this as completed Jun 20, 2016
nha added a commit to nha/yada that referenced this issue Nov 26, 2016
chrisbetz added a commit to gorillalabs/tesla that referenced this issue May 2, 2017
during update of buddy, I stumbled upon this issue: funcool/buddy-sign#34. Replacing buddy.sign.jwe with buddy.sign.jwt resolved the issue, update went fine.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants