feat: add onTokenSync hook for auth token re-sync#1001
feat: add onTokenSync hook for auth token re-sync#1001janthurau merged 6 commits intoueberdosis:mainfrom
Conversation
|
Thank you for your PR! Wondering if we need a new message type that the provider sends, or if it can just send the usual Auth message and we handle that in the server? That would probably also solve https://github.com/ueberdosis/hocuspocus/pull/1001/files#diff-2f3921abc2796f1f97fc6ca37bea53ef1a43b7327e68645d7f546653e04e6958R114 then |
3cdb52c to
30140f9
Compare
My initial idea was to separate authentication from token sync, since the latter doesn’t always constitute an authentication operation. |
87ac1af to
9772018
Compare
4fc7c34 to
10b2d47
Compare
|
any further thoughts @janthurau? I did push some docs around the new hook. |
fa89780 to
4ebfb95
Compare
4ebfb95 to
8bb920a
Compare
Problem
Currently, Hocuspocus only validates user authentication during the initial handshake. If a user's token expires, or permissions change while they have an active connection, they can continue editing documents until they reconnect.
Solution
This PR suggests the first step towards "periodic" reauth (ref: #752) by adding a token synchronization mechanism. The server can now request the current token from any connected provider, enabling validation of user permissions without requiring a full reconnection.
Changes
sendToken()- Provider method to send current token to serverrequestToken()- Server method to request token from provideronTokenSynchook - Server hook triggered when token is receivedTokenSyncmessage type - New message type for token synchronizationLooking for Feedback
onTokenSynchook failures trigger disconnection?requestToken()?onTokenSynchook