Nikky
01/12/2021, 1:53 PM{
"error": "Could not connect to websocket endpoint <ws://localhost:8080/subscriptions>. Please check if the endpoint url is correct."
}
not sure if this is a issue in plaground or in the library however
and seems like the GraphQLContextFactory
does not kick in for subscriptions
so we cannot figure out how to get access to Header Authorization
for subscriptions currentlyDariusz Kuc
01/12/2021, 2:12 PMspring-server
or your own implementation?Dariusz Kuc
01/12/2021, 2:12 PMDariusz Kuc
01/12/2021, 2:15 PMAuthorization
header -> in current released version of spring-server
context is created in a WebFilter
(same way as for queries/mutations). Maybe this is related to https://github.com/ExpediaGroup/graphql-kotlin/discussions/975?
side note -> we recently abstracted away execution logic to avoid the need for the webfilter which should simplify this (not yet released)Nikky
01/12/2021, 2:49 PMSpringSubscriptionGraphQLContextFactory
then ? we are currently using a GraphQLContextFactory
i assume that is on the latest snapshot, or only in master ? then i might have to use mavenLocal()Nikky
01/12/2021, 3:03 PMDariusz Kuc
01/12/2021, 3:19 PMSpringSubscriptionGraphQLContextFactory
is on latest snapshot (should be releasing another alpha soon)Dariusz Kuc
01/12/2021, 3:20 PMDariusz Kuc
01/12/2021, 3:20 PMNikky
01/12/2021, 4:19 PMSpringSubscriptionGraphQLContextFactory
but in the generateContext
call i do not get the headerDariusz Kuc
01/12/2021, 4:29 PMNikky
01/12/2021, 4:32 PMhttps://nikky.catgirl.host/i/cumht626.png▾
Dariusz Kuc
01/12/2021, 4:33 PMNikky
01/12/2021, 4:33 PMDariusz Kuc
01/12/2021, 4:34 PMNikky
01/12/2021, 4:35 PMNikky
01/12/2021, 4:35 PMDariusz Kuc
01/12/2021, 4:37 PMNikky
01/12/2021, 4:41 PMDariusz Kuc
01/12/2021, 4:41 PMDariusz Kuc
01/12/2021, 4:41 PMDariusz Kuc
01/12/2021, 4:43 PMNikky
01/12/2021, 4:57 PMDariusz Kuc
01/12/2021, 5:14 PMNikky
01/12/2021, 5:21 PMDariusz Kuc
01/12/2021, 5:25 PMNikky
01/12/2021, 6:16 PMJoe
01/13/2021, 4:51 PMPrincipal?
to our GraphQLContext implementation
• In the GraphQL websocket upgrade, check the user principal from dropwizard auth and put it in the context (optionally rejecting all unauthenticated websocket upgrades with a 401)
• use a service-hosted graphiQL with subscription support. Putting that behind the same auth gate as the graphql endpoint makes the browser prompt for auth when hitting graphiQL, and then re-use the creds when hitting the graphql endpoint when we're using Basic auth. token based auth may or may not complicate things from a usability point of view
• In graphql resolver functions, inject the GraphQLContext and check the principal as needed (minimal test example that refs the principal but doesn't actually do much)
Most of this should be replicable in graphql-kotlin's spring implementation, but not sure how much would be included out of the boxShane Myrick
01/13/2021, 8:53 PMgraphql-kotlin-spring-server
you can implement the ApolloSubscriptionHooks.onConnect
to modify the context
https://github.com/ExpediaGroup/graphql-kotlin/blob/335f857c5496679723ae76ceba26cc[…]/graphql/server/spring/subscriptions/ApolloSubscriptionHooks.ktNikky
01/14/2021, 9:31 AM