dmunch / couch_jwt_auth

JSON Web Token (JWT) authentication plugin for CouchDB
Apache License 2.0
7 stars 8 forks source link

start_link not called in Couch 2, fails with "noproc" #2

Open jjd314 opened 7 years ago

jjd314 commented 7 years ago

First, thanks a million for porting this to Couch 2. I don't know jack about erlang, and I can't get Couch 1.6 running on Debian Stretch, so without this I would have been stuck. Although it compiled and installed, it kept throwing {"error":"noproc","reason":"{gen_server,call,[couch_jwt_auth,{get_jwk}]}"} whenever I tried to authenticate. From what I could tell, start_link was never being called, and so the get_jwk call failed. Digging through the other parts of Couch 2 (in particular, couchdb-b64url), I saw that it began with an "on_load" call (in that case, to init/0). I added - on_load(start_link/0). after the module() line at the top of couch_jwt_auth.erl, and it seems to work fine now.

I'm just leaving this as an issue, rather than a pull request, because 1) I don't know what I'm doing with erlang, and this is just a sufficiently successful hack for me, and 2) it breaks a bunch of tests (and again, my erlang-less-ness stopped me from fixing them).

I hope this helps, and again, thanks a bunch!

dmunch commented 7 years ago

Hi, thanks for your interest in couch_jwt_auth

There might be still some things missing in the documentation. Actually, for this version to work you need to add an additional line in you local.ini in the [deamons] section like follows

[daemons]
jwt_auth = {couch_jwt_auth, start_link, []}

Let me know if this works for you!

Best, Daniel

jjd314 commented 6 years ago

Hi Daniel, Thanks for this fork! I had the same problem as the OP of this issue, and your solution worked for me. I just thought you (and others following) might want to know. I also just submitted a pull request for a change putting those lines into priv/default.d/jwt_auth.ini