Fork me on GitHub
#graphql
<
2020-11-12
>
emccue18:11:33

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

emccue18:11:43

{"Sec-WebSocket-Version" ["13"],
 "Origin" [""],
 "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"]}

emccue18:11:00

This is what comes with the ServletUpgradeRequest in init-context

emccue18:11:04

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

emccue18:11:22

(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"))
        #{}))))

emccue18:11:50

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

emccue18:11:29

slash reject if the user isn't authorized

emccue22:11:32

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

Daniel Stephens23:11:48

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

emccue23:11:53

Just made that change and no

emccue23:11:06

not that i've noticed yet

Daniel Stephens23:11:57

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

emccue23:11:14

for clarification, where should I be checking this?

emccue23:11:40

I have the interceptors in :subscription-interceptors

emccue23:11:51

and I have :init-context

emccue23:11:25

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

emccue23:11:08

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

emccue23:11:21

I have these keys in the context for :subscription interceptors

emccue23:11:39

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

emccue23:11:52

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

emccue23:11:27

(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))
        

emccue23:11:51

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

emccue23:11:07

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

Daniel Stephens23:11:43

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 Stephens23:11:22

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 Stephens23:11:12

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

Daniel Stephens23:11:42

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

emccue23:11:06

yeah so far not there

emccue23:11:34

I might give up for a week