Marcus Ilgner
07/10/2025, 10:10 AMAuthorization information from the connection_init message of a websocket connection for authentication? I have installed the Authentication plugin - works fine for regular JWT Bearer Tokens in the Authorization header of regular HTTP requests - and also set up a ContextFactory for subscriptions can handle the authorization part.
Unfortunately, the authentication part doesn't work yet, as it seems like the connection_init message isn't used by the Authentication plugin to set up the principal. The client used is graphql-ws and it looks like adding the auth information to connection_init is the only supported method. I read this comment about how using regular HTTP headers for websockets might not be a good idea and think that probably there is some way to get Ktor to use the connection_init payload. Any ideas / reading material?Marcus Ilgner
07/10/2025, 2:04 PMSubscriptionsContextFactory and checking the params of its generateContext method. Then I parse the Authorization param, decode the JWT and set the account into the context.
So in the end, the Ktor authentication plugin wasn't even used after all.