-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
Cannot call handle_open to handle JWT expiration #174
Comments
The If you're connecting via If you're not using AnyCable JWT feature, and using a custom token-based auth instead, you should use the def connect
self.current_user = find_verified_user
rescue VerificationFailed
logger.error 'An expired JWT token was rejected'
close(reason: 'token_expired', reconnect: false) if anycabled? || websocket.alive?
reject_unauthorized_connection
end Note that I added |
Oh, I didn't know that.
In our case, we're using a custom token-based auth. I could understand very clearly. |
Tell us about your environment
Ruby version:
2.7.2
Rails version:
6.0.3
anycable
gem version:1.2.3
anycable-rails
gem version:1.3.4
grpc
gem version:1.47.0
anycable-go
version:1.2.1
What did you do?
I try to refresh my authentication tokens (JWT) by using following
tokenRefresher
:anycable/anycable-client: AnyCable / Action Cable JavaScript client for web, Node.js & React Native
And try to respond
token_expired
message from server side in case of auth error:anycable/anycable-rails-jwt: JWT identification helpers for AnyCable
What did you expect to happen?
I expect
handle_open
method is called when the websocket connection establishes.and to catch
VerificationFailed
and respondtoken_expired
message if token auth fails.What actually happened?
But
handle_open
method was not called.I changed my code the following, it is OK to catch
VerificationFailed
and respondtoken_expired
message.(but if I use
websocket.alive?
inconnect
,undefined method
alive?' for #AnyCable::Socket:0x00007fe00fe108b0` occurs.)The text was updated successfully, but these errors were encountered: