This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-06
Channels
- # aleph (15)
- # beginners (40)
- # boot (14)
- # cider (90)
- # cljs-dev (132)
- # cljsrn (25)
- # clojars (7)
- # clojure (188)
- # clojure-chicago (4)
- # clojure-dusseldorf (1)
- # clojure-greece (9)
- # clojure-italy (43)
- # clojure-russia (16)
- # clojure-sg (7)
- # clojure-spec (39)
- # clojure-uk (81)
- # clojurescript (170)
- # component (5)
- # core-async (7)
- # cursive (49)
- # data-science (65)
- # datascript (3)
- # datomic (27)
- # graphql (3)
- # hoplon (4)
- # instaparse (56)
- # klipse (129)
- # leiningen (1)
- # lumo (28)
- # off-topic (4)
- # om (15)
- # onyx (54)
- # overtone (7)
- # pedestal (7)
- # re-frame (9)
- # reagent (72)
- # ring (33)
- # ring-swagger (2)
- # spacemacs (1)
- # untangled (19)
- # vim (2)
- # yada (12)
Hi all, I’m trying to implement my own verify authorization, and I can make it work fine until I need to go to the db to authorize against the request. I can’t figure out how to inject a datomic conn via the multi method approach that follows:
(defmethod yada.security/verify :my/custom-static
[ctx scheme]
{:user "alice"
:roles #{:user}})
I tried to make the following work without implementing the multimethod, but I’ve hit a lot of problems:
(defn produce [env]
(yada/resource
{:access-control {:authorization {:methods {:post :user}}
:verify (fn [ctx] (do something with env here))}
The defmethod approach makes it pretty hard to inject the connection via a component. Perhaps I should be injecting it into the context first?
Yes. Use an interceptor to do that. We do that quite a lot.
I feel this is a common pattern that needs a better answer than 'just hack the interceptor chain'.
(In yada parlance, I think you're talking about authentication rather than authorization, in case anyone here is confused.)
OK, great. I wasn’t so sure if that was the right place as I hadn’t seen exactly that case come up in posts. Thanks for the response - it should be easy enough from here then.
Do I have to prepend the interceptor per route if I use yada with bidi, or can I have one overall interceptor that will inject the connection?
When I add an interceptor to my resource it seems to break everything. It’s as if it’s using only the interceptor I added. Do I have to set the interceptor chain for the resource before I add to it?
:interceptor-chain yada/default-interceptor-chain
did the trick.