Fork me on GitHub
#luminus
<
2018-05-03
>
clojer00:05:19

I switched my ns.<app>.middleware to [buddy.auth.backends.token :refer [jws-backend]] in line with https://funcool.github.io/buddy-auth/latest/api/buddy.auth.backends.token.html but I’m getting an error: “Could not locate buddy/auth/backends/tokens/jws__init.class or buddy/auth/backends/tokens/jws.clj on classpath”. Any ideas?

eoliphant00:05:36

do you have the buddy-auth lib in your project.clj?

clojer01:05:56

@eoliphant Just buddy but there are numerous references to budy.auth in the app’s middleware namespace.

eoliphant01:05:28

yeah I think you need buddy-auth explicitly

eoliphant01:05:36

for JWT stuff

clojer01:05:49

If so why does this work: [buddy.auth.backends.session :refer [session-backend]], ie. the default?

eoliphant01:05:07

hmm, not sure in my project

eoliphant01:05:13

is in buddy-auth

eoliphant01:05:16

session as well

clojer01:05:02

@eoliphant Maybe buddy-auth is a dep.

eoliphant01:05:24

crap this slack is over quota lol

eoliphant01:05:53

i pasted in a screenshot my dep tree with the transitive dependencies

eoliphant01:05:12

buddy doens’t seem to include the auth backends

eoliphant01:05:28

in any case, try adding i

eoliphant01:05:33

explicitly for now

clojer01:05:13

How can I get that library listing?

clojer01:05:23

I’ll just check if it’s there.

eoliphant01:05:50

i just deleted the explcit dependency

eoliphant01:05:57

and it still resolves it

eoliphant01:05:03

so looks like it’s something else

clojer01:05:10

nvm? Isn’t that for Node?

eoliphant01:05:28

what does your code look like?

eoliphant01:05:03

that namespace has a jws-backend function

eoliphant01:05:12

but no plain jws

eoliphant01:05:49

and i think it should be just ‘token’

eoliphant01:05:07

[buddy.auth.backends.token :a ..

eoliphant01:05:43

check your require

clojer01:05:57

The buddy-auth code in Luminus seems to be totally different than what’s in the buddy-auth docs.

eoliphant01:05:04

that’s buddy._sign_.jwt

clojer01:05:45

Also referred to as jws

clojer01:05:22

Very confusing. I think the authors of buddy-auth could have made this a bit more beginner-friendly.

clojer01:05:09

What hope does a newcomer to Clojure web development have trying to make sense of all this?

eoliphant01:05:17

yeah i think their docs are a little out of date

eoliphant01:05:57

well one sec let me make sure

clojer01:05:24

This is a classic supporting argument for a Clojure web framework. I mean Luminus is great as far as it goes but it’s only a guide to curated libraries at best. “Web Development with Clojure”, as far as I can tell only has an OAuth example and doesn’t touch the Buddy stuff.

eoliphant01:05:36

that stuff is there

eoliphant01:05:21

jws is in backends.clj

eoliphant01:05:36

can you paste in your require?

clojer01:05:29

According to the buddy docs I can simply call (backends/jws {:secret “mysecret”}) but I can’t get it to work.

eoliphant01:05:46

backends/jws shold be fine. based on your error you have backends.token/jws which doesn’t exists

clojer01:05:58

Last I tried was: [buddy.auth.backends.token :refer [jws-backend]] . Combined with (let [backend (jws-backend {:secret “mysecret”})]

clojer01:05:14

I’ve tried all permutations but I get the same error.

clojer01:05:19

It’s always “Could not locate buddy/auth/backends/tokens/jws__init.class or buddy/auth/backends/tokens/jws.clj on classpath”

clojer01:05:18

Even the error message doesn’t match what I specified, ie. backends.token not backends.tokens . Jeeeezus.

clojer02:05:28

Thanks @eoliphant but I’ve wasted the best part of a week trying to untangle this knot in order to get my app off the ground. The Clojure community is just too wedded to its libraries-only philosophy so I’ll give Node a shot.

eoliphant02:05:45

hey sorry was working through a form lib

eoliphant02:05:48

issue i was having

eoliphant02:05:17

hmm i’m using it in one of my services

eoliphant02:05:52

is the let call the one that’s causing the problem?

eoliphant02:05:42

;; requires
...
[buddy.auth.backends.token :refer [jwe-backend jws-backend]]
[buddy.sign.jwt :refer [encrypt sign]]
...
(def token-backend
  (jws-backend {:secret secret}))

(defn token [username role id]
  (let [claims {:user (keyword username)
                :role role
                :id id
                :exp (plus (now) (minutes 60))}]
    ;(encrypt claims secret {:alg :a256kw :enc :a128gcm})
    (sign claims secret)
    ))

eoliphant02:05:49

well if you look at it again, gen a luminus project with the buddy-jwt option, and compare that config to yours. I think you may just have something mistyped somewhere

clojer04:05:41

ag 'tokens' in my app folder returns nothing so I can’t fathom why the error keeps referring to “auth/backends/tokens”

xlevus20:05:45

is it usual for a single luminus repl to use over 1GB of ram?