-
-
Notifications
You must be signed in to change notification settings - Fork 677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@Authorized
in subscriptions
#175
Comments
I would like to suggest a workaround for refusing connections in resolvers @19majkel94 : const subscriptionServer = new SubscriptionServer({
schema,
execute,
subscribe,
onConnect(connectionParams) {
// ... do authorization
return { authorized: false }; // or true
}
... next off, when declaring your topic in subscribtion you can access the .authorized field: @Subscription({
topics: ({ args, context, payload }) => {
if (!context.authorized )
{
// this gives user error response and cancels subsribtion
throw new AuthenticationError(`Unauthorized user cannot receive info from this socket`);
}
return SOME_TOPIC;
}
})
accountBalanceChangeTopic(
//...
} throwing error inside topics ( or filters) results in socket connection being closed (and send a desired error to user). |
Just wondering if I could get some information about whether this is still an issue and if so where it is in the pipeline? |
It's related to #200 and will be handled in the 1.0.0 milestone. |
Right now
@Authorized
in subscriptions cause that the autorization checker is called only when pubsub emit new event in selected topic (when subscription method body is called). But it should be called only duringsubscribe
phase to reject unauthorized clients.This would require some changes in creating middlewares stack that is applied only for resolvers. For now I will handle that case manually without exposing different kind of middlewares.
The text was updated successfully, but these errors were encountered: