graphql

emccue 2020-11-12T18:34:33.073100Z

I'm still at a loss about getting to my Authorization key

emccue 2020-11-12T18:34:43.073700Z

{"Sec-WebSocket-Version" ["13"],
 "Origin" ["<http://localhost:8000>"],
 "Sec-WebSocket-Extensions" ["permessage-deflate"],
 "User-Agent"
 ["Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0"],
 "Accept-Encoding" ["gzip, deflate"],
 "Cache-Control" ["no-cache"],
 "Accept-Language" ["en-US,en;q=0.5"],
 "Sec-WebSocket-Protocol" ["graphql-ws"],
 "Connection" ["keep-alive, Upgrade"],
 "Sec-WebSocket-Key" ["VrocNXrlymz9f3WWNd+Ifg=="],
 "Upgrade" ["websocket"],
 "Accept" ["*/*"],
 "Pragma" ["no-cache"],
 "Host" ["localhost:8000"]}

emccue 2020-11-12T18:35:00.074100Z

This is what comes with the ServletUpgradeRequest in init-context

emccue 2020-11-12T18:36:04.074700Z

I configured graphiql to send an auth token, so that shouldn't be the issue (hopefully)

emccue 2020-11-12T18:36:22.075Z

(if (config/non-production? config)
        (set/union
          #{["/api/v1/graphiql"
             :get (lp/graphiql-ide-handler {:api-path "/api/v1/graphql"
                                            :subscriptions-path "/api/v1/ws"
                                            :ide-headers {"Authorization" "Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJqdGkiOiJjZjMxMjQwMDkxNmM0YmY5ODA4M2ExNTg4M2UzYjRhZiIsImV4cCI6MTYwNTI4MTE2Nn0.U8lKgjPl-NxWHMpCZwdUgQ6ceQsFtm8CQkpw4niMjEo"}}) ;; EDIT IN DEV
             :route-name ::graphiql]}
          (lp/graphiql-asset-routes "/assets/graphiql"))
        #{}))))

emccue 2020-11-12T18:36:50.075500Z

but its still unclear where I can get that and associate it with the :user key

emccue 2020-11-12T18:37:29.076Z

slash reject if the user isn't authorized

emccue 2020-11-12T22:01:32.076600Z

Now i'm digging through old issues, but i'm still not there since the context def. does not have any request info

Daniel Stephens 2020-11-12T23:02:48.077600Z

do you get anything when passing the same map to :ide-connection-params rather than :ide-headers ? @emccue

emccue 2020-11-12T23:09:53.078200Z

Just made that change and no

emccue 2020-11-12T23:10:06.078600Z

not that i've noticed yet

Daniel Stephens 2020-11-12T23:15:57.080200Z

😞 have you checked in ctx for the key :connection-params or just headers?

emccue 2020-11-12T23:17:01.080500Z

err

emccue 2020-11-12T23:17:14.080900Z

for clarification, where should I be checking this?

emccue 2020-11-12T23:17:40.081300Z

I have the interceptors in :subscription-interceptors

emccue 2020-11-12T23:17:51.081600Z

and I have :init-context

emccue 2020-11-12T23:19:25.082300Z

right now my interceptors are looking for a :request and a "Authorization" in the request

emccue 2020-11-12T23:20:08.083200Z

(:query
 :variables
 :id
 :shutdown-ch
 :response-data-ch
 :parsed-lacinia-query
 :lacinia-app-context)

emccue 2020-11-12T23:20:21.083600Z

I have these keys in the context for :subscription interceptors

emccue 2020-11-12T23:20:39.083900Z

(:io.pedestal.interceptor.chain/terminators
 :com.walmartlabs.lacinia.pedestal.subscriptions/values-chan-fn
 :io.pedestal.interceptor.chain/queue)

emccue 2020-11-12T23:20:52.084300Z

and these keys in what I think is coming from init-context

emccue 2020-11-12T23:22:27.084700Z

(http/default-interceptors)
        (update :io.pedestal.http/interceptors conj (interceptor/interceptor context-adder))
        (update :io.pedestal.http/interceptors conj (interceptor/interceptor auth/user-from-jwt-interceptor))
        

emccue 2020-11-12T23:22:51.085300Z

I have this chain that adds an interceptor that should add the user to the request map of stuff

emccue 2020-11-12T23:23:07.085800Z

and I do see a db query when i fire off the subscription req, but nothing else

Daniel Stephens 2020-11-12T23:23:43.086600Z

hmm, honestly I'm probably not going to be able to help much, I just remembered the connection-params things from the docs maybe in lacinia-app-context there will be the connection params

Daniel Stephens 2020-11-12T23:26:22.087800Z

This https://github.com/walmartlabs/lacinia-pedestal/blob/master/src/com/walmartlabs/lacinia/pedestal/subscriptions.clj#L322 suggests to me that the map you get in looks something like

{:request {... the bit you posted}
 :connection-params {the other stuff}}

Daniel Stephens 2020-11-12T23:27:12.088800Z

since on context there it does both (get-in context [:request :lacinia-app-context]) and (:connection-params context)

Daniel Stephens 2020-11-12T23:28:42.090100Z

basically I would say, wherever you are currently doing (get-in x [:request "Authorisation"]) in your interceptors just log out x and see if it has anything that looks like your token

emccue 2020-11-12T23:31:06.090400Z

yeah so far not there

emccue 2020-11-12T23:31:34.091Z

I might give up for a week