-
-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
The Guard is not work in Websocket Gateway #9231
Labels
needs triage
This issue has not been looked into
Comments
Please search through some of our old issues on this (this has been discussed several times in the past). |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Is there an existing issue for this?
Current behavior
When i apply Guard on controller, it can intercept and get the context for further processing, but Gateway just skip the guard.
The Guard is not work in Gateway level or handleConnection, only work in SubscribeMessage Level.
But if i work will Controller, the Guard work perfectly
Minimum reproduction code
https://github.com/jackykwandesign/gateway-guard-issue/tree/main
Steps to reproduce
Expected behavior
Bonus:
2. Provide a lifecycle function to work with Guard to accept or reject connection
Since websocket is for high speed communication with less overhead as we can, can we do Auth checking in a life cycle before Connect ? Then the socket will be authed for any further process we want?
I found in Socket.io there is middleware, can we do that and apply to specific namespace only?
Package
@nestjs/common
@nestjs/core
@nestjs/microservices
@nestjs/platform-express
@nestjs/platform-fastify
@nestjs/platform-socket.io
@nestjs/platform-ws
@nestjs/testing
@nestjs/websockets
Other package
No response
NestJS version
8.1.6
Packages versions
Node.js version
16.13.1
In which operating systems have you tested?
Other
No response
The text was updated successfully, but these errors were encountered: