This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-09-05
Channels
- # 100-days-of-code (1)
- # announcements (9)
- # aws (1)
- # beginners (195)
- # braveandtrue (60)
- # calva (3)
- # cider (36)
- # cljs-dev (3)
- # clojure (124)
- # clojure-canada (13)
- # clojure-dev (18)
- # clojure-germany (2)
- # clojure-italy (2)
- # clojure-losangeles (1)
- # clojure-nl (9)
- # clojure-russia (1)
- # clojure-spec (20)
- # clojure-uk (109)
- # clojurescript (49)
- # core-logic (29)
- # cursive (7)
- # datomic (62)
- # defnpodcast (1)
- # devcards (11)
- # docker (3)
- # duct (6)
- # figwheel (13)
- # figwheel-main (57)
- # fulcro (2)
- # graphql (11)
- # hyperfiddle (3)
- # jobs (5)
- # jobs-discuss (9)
- # leiningen (2)
- # lumo (1)
- # off-topic (12)
- # onyx (2)
- # pedestal (1)
- # portkey (2)
- # rdf (1)
- # re-frame (39)
- # reitit (13)
- # remote-jobs (2)
- # rum (5)
- # shadow-cljs (82)
- # tools-deps (48)
- # unrepl (3)
- # vim (12)
- # yada (1)
what's a good way to put a JWT token into the resolver context for use in the GraphiQL app for authorization?
@thosmos I guess you would want to decode the token before assoc
ing it to context?
hmm, so if I'm using lacinia-pedestal this would be in an interceptor before lacinia? I'm just getting familiar with pedestal
So your question is specific to lacinia-pedestal? I don't use lacinia-pedestal myself 😐
well, you can use com.walmartlabs.lacinia/execute
directly. I think lacinia's unit tests would cover it
@thosmos, I'm not as familiar with the pedestal stuff but in general you'd want to interceptor for that, I would think
I work on a Ring app, and basically we've got middleware that decodes the token and puts it in request
. For my app we don't even allow graphql access without a token, but in principle what you'd want to do is pull the data you need out of request
and then assoc it into the lacinia app-context at the time you call (execute)
, like @myguidingstar was saying. Then in your resolvers you can pull the data back out of the context if you need to do something with it, via the third argument to your resolver functions.
@timgilbert thanks. yes, that's more or less what I figured out for the regular lacinia-pedestal backend service. It even provides an API for injecting a custom interceptor into its interceptor vector before creating the service. But I realized that the problem I'm attempting to solve is with the embedded GraphiQL frontend UI. I'd need to alter that to get it to modify the HTTP request header that it sends to the backend service. Since this need is just for development, instead what I did was use a browser plugin that adds a custom header that gets sent to the backend.
Oh, cool, makes sense. For our auth stuff we set a cookie with the JWT token in it, which carries over from our main app to GraphiQL if they're both running on localhost
.