-
-
Notifications
You must be signed in to change notification settings - Fork 752
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
user entity is not getting removed on logout #1883
Comments
Do you have an example when this is causing issues?
I don't disagree that it would still make sense to remove but I currently can't think of a reliable way to do this (since the entity name or authentication result can be anything). |
@daffl you are right regarding the The problem for me came when I used a combination of authenticated + no-auth-required services. The exact scenario is like this: I was trying to create an audit log service that logs every other service call. I made this Taking the cue from feathers-authentication-hooks, I tried to determine the current user with below kind of code (sampled from the docs there):
And used couple of these (again from the docs there) in the authenticated services to restrict/filter the current user:
All this started giving weird results. Took me a day to figure out what was going wrong: the To summarize, I understand it might be difficult to remove the
I guess I would have to check
And since we are on that topic, another question on a slightly different tangent is:
|
Also came across this scenario: consider a mixed-auth endpoint which shows some public records for unauthed users, and all private records for authed users. Below sequence of steps:
This was the problem I was facing. |
That shouldn't be possible because like I mentioned in my previous comment, external requests that require authentication will fail if there is no information available (even if the user is still set on the connection). @KrishnaPG Thinking a little more about it, there is a fairly straightforward fix for this which is adding const { entity } = this.configuration;
delete connection[entity]; to https://github.com/feathersjs/feathers/blob/master/packages/authentication/src/jwt.ts#L58 |
Thank you @daffl The problem is not with authenticated endpoints. It is with endpoints that support both authenticated and unauthenticated (for example, this scenario from the guide) Wondering - why not just remove the whole The added advantage is: JWT can be tied to the connection (some UID specific to the connection is put in the payload and verified). Any other connections that try to use the same JWT will fail, and once the connection is removed JWT will automatically fail to verify. (Currently, JWTs are still valid even after the client is logged out, if someone has a copy of them, if I am not mistaken) |
I wonder how you came across that guide. The docs are from two versions and several years ago and might not be applicable to the most recent version (which is at https://docs.feathersjs.com/). Your suggestion of clearing the connection completely makes sense though, however, to invalidate JWTs properly a JWT blacklisting mechanism should be used. |
I did more debugging, and the issue is occurring in a more common scenario than what I described earlier. Scenario is as simple as
The problem is:
which ofcourse yields zero results, and there by auth failing. Not sure how to resolve this situation. I am unable to progress and enforce queries to limit to the current logged in user. If I remove the second hook in the |
This will be fixed via #1889 |
Thank you. Meanwhile, I have forced socket The only problem now is,
|
Never mind. Forcing socket reconnect from the client-side has its own set of problems, opening a pandora box. Guess its better to fix it on the server side with clean session / connection close. Only point I could add is, please consider both scenarios:
Hope #1889 works well in all the above scenarios. |
Another case to cover (documenting for the sake of completeness):
Effectively now both users (in two different tabs of same browser instance) are sharing the same JWT in the local storage. Any reAuth or service call from the old tab should be invalidated. |
Steps to reproduce
When
logout
is called on the client side, the server is removing theauthentication
object on theconnection
, but not removing theuser
entity. This is causing the server to return results even after logoutExpected behavior
The
user
entity should not exist anymore on the connection (as well theparams
in the hooks)Actual behavior
The
user
entity exists and any hooks that check for it assume that the user is still logged inSystem configuration
Using socket.io as the transport with authentication backed by Knex DB adapter for local + jwt strategies
Module versions: 4.5.2
NodeJS version: v12.9.1
Operating System: Windows 10
Browser Version: Chrome latest
Module Loader: npm 6.6.0
The text was updated successfully, but these errors were encountered: