-
Notifications
You must be signed in to change notification settings - Fork 16
Add authenticator function used at reconnection #650
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
Conversation
Codecov Report
@@ Coverage Diff @@
## 7-dev #650 +/- ##
==========================================
+ Coverage 85.62% 86.34% +0.71%
==========================================
Files 36 36
Lines 1635 1655 +20
Branches 297 301 +4
==========================================
+ Hits 1400 1429 +29
+ Misses 175 169 -6
+ Partials 60 57 -3
Continue to review full report at Codecov.
|
@Shiranuit I couldn't find a way to know if the SDK was authenticated since with the cookie auth we don't have the JWT property. It was to tricky to put listener in All the re-authentication mechanism will only be executed if the |
The only way I could think of without puting a listener in |
I was wondering, isn't that Breaking Change ? |
The new behavior will be executed only if the
But if the token is expired then kuid will be anonymous so we cannot know if the user was really authenticated or not. |
You're right I didn't see you changed that, LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which authentication function could be in authenticator
property instead of auth:login
?
Could it be interesting to only store strategy/credentials in an object inside authenticator
and perform auth:login
inside the sdk?
It could be a call to an external API that manages secrets like Hashicorp Vault to request a new API key for example |
# [7.7.2](https://github.com/kuzzleio/sdk-javascript/releases/tag/7.7.2) (2021-07-21) #### Bug fixes - [ [#651](#651) ] Hotfix heartbeat race condition ([Shiranuit](https://github.com/Shiranuit)) - [ [#648](#648) ] Fix the Jwt.expired getter wrong comparison of micro timestamp and timestamp ([robingrandval](https://github.com/robingrandval)) - [ [#646](#646) ] Fix usage of SearchResult.next with HTTP ([Aschen](https://github.com/Aschen)) - [ [#644](#644) ] Correctly reject aborted queued requests ([scottinet](https://github.com/scottinet)) #### Enhancements - [ [#650](#650) ] Add authenticator function used at reconnection ([Aschen](https://github.com/Aschen)) ---
What does this PR do ?
When the SDK reconnect to Kuzzle, it trigger the
reconnected
event. The Realtime controller will try to resubscribe when this event is triggered.If the token had expired, then the Realtime controller will try to resubscribe with no authentication and thus the subscriptions request may fail.
This PR include a new
authenticator
property, this property should contain a function that authenticate the SDK (withauth.login
for example).The SDK will call the function before emitting the reconnected event, if the SDK was authenticated and cannot re-authenticate then the
reconnected
event will not be emitted and the SDK will be in thedisconnected
state.A new
reconnectionError
has been added and is triggered when the reconnection has failedHow should this be manually tested?
Create an user:
Then run this script:
Disconnect your user
kourou auth:logout -a global=true --username test --password test
Then stop and restart Kuzzle, the SDK should re-subscribe successfully