-
-
Notifications
You must be signed in to change notification settings - Fork 126
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
[Nextcloud] Impersonate user keeps old Email logged in #561
Comments
There's one important thing to know: were you already logged in SnappyMail? Probably, because Nextcloud search also tries SnappyMail and that auto-login to search. So we need to know if we can hook to the imporsonate plugin and force a logout |
Yes, as soon as I set auto-long credential, SnappyMail will always be logged-in. I would rather not hook to other plugins because you can never know if another plugin will also cause the same behavior. As long as I know that my credentials are not leaked to the impersonated user it is fine for me (and only a small inconvenience). Another thing I noticed – maybe related to the topic – when I logged out of Rainloop it would display the login screen. With SnappyMail, if I click logout, it will immediately log back in. You said something about Search triggering the auto-login? Could this be postponed until you actually perform a search? |
When i open Nextcloud a search is done immediately, it might be a bug.
That's true because you've setup the login credentials. |
Yes, but the logout did work in Rainloop with auto-login enabled. SnappyMail just not displays the login view and instead performs the auto-login. I am actually fine with that behavior. It was just a note on the login/logout process in general. Maybe a hint that could have helped to identify the issue why the login credentials are transferred to the impersonated user.
As I said, I would rather not hook to other plugins. But maybe, instead of hooking to the imporsonate plugin, there is a more general hook to subscribe to changes in user-context? Ideally getting notified if the current user changes? |
The described behaviour can be observed more general. To Reproduce: I think this shouldn't happen. User A should be logged out from SnappyMail as logging out from nextcloud. |
Strange, because SnappyMail should logout due to the following Nextcloud hook: snappymail/integrations/nextcloud/snappymail/lib/AppInfo/Application.php Lines 98 to 102 in 62a14a3
So something goes wrong in Nextcloud OR SnappyMail hook OR browser cache |
Just a shot in the dark: is there some local storage involved, such that the credentials are loaded from disk? |
I tried this on an ubuntu-desktop installation. I deleted the near history and never save passwords in the browsers password manager. |
Found it. The impersonate extension does not logout. That's why SnappyMail does not logout. |
If I understand it the right way, than you found a solution for the originally mentioned problem. |
No solution yet, just found out why SnappyMail stays logged in. |
Sorry for being back again ;-). |
WITHOUT impersonate plugin AND NO credentials stored in Nextcloud -> Settings -> Additional:
WITHOUT impersonate plugin AND NO credentials stored in Nextcloud -> Settings -> Additional:
WITHOUT impersonate plugin but WITH credentials stored in Nextcloud -> Settings -> Additional:
And then same with impersonate, what happens? |
WITH impersonate plugin AND NO credentials stored AND remember=False:
WITH impersonate plugin AND NO credentials stored AND remember=True:
WITH impersonate plugin AND credentials stored:
EDIT: and exact same behavior without impersonate plugin |
@relikd Go to Nextcloud -> Settings -> Administration -> Additional settings Set it to I've also asked without the |
With v2.19.2? That is what I tried. I also tried with the impersonate plugin disabled (I shouldn't have edited the message and instead posted a new reply, my bad) |
As I mentioned previously I tested on two different nextcloud installations. The non-ldap installation shows the same problematic behaviour but under more restrictiv conditions. The emailaccounts for the non-ldap installation are not connected to the usernames, for the ldap-installation the account have the pattern: <username>@nc-server.de. I'm not ready with testing all the 6 situation but found a hint while analyzing the first situation. In fact deleting the cookie did prevent SnappyMail from being logged in false for user B. I had a closer look at the cookies: the value for smaccount did not change. Deleting only the entry smaccount was enough to prevent SnappyMail from being logged in. I#m going to test the other situations I will report. |
As I said, probably a local storage issue. But I think the actual issue is to know when to trigger the logout aka. delete the cookie. It seems that listening to the Also, it seems strange that on my machine, without impersonate, no credentials, no remember login, and no ldap, I am still being logged in again. Even the logout hook seems unreliable. |
Testreport in one post: WITHOUT impersonate plugin AND NO credentials stored in Nextcloud -> Settings -> Additional:
WITHOUT impersonate plugin AND NO credentials stored in Nextcloud -> Settings -> Additional:
WITHOUT impersonate plugin but WITH credentials stored in Nextcloud -> Settings -> Additional:
WITH impersonate |
The only difference being that using impersonate you can change an account without logout. |
I made a check to force logout. Try with v2.19.6 |
Cannot update within Nextcloud: "App with id snappymail has invalid signature". |
Thank you für adressing the bug. The problem is solved, after switching user I'm no longer logged in as the previous user in snappymail. |
Great we have progress! |
Can confirm. Does work for me too. Many thanks!
This, I do not experience. I can see mails, and I can send them. I do not know why it is not working for you. Maybe a caching issue? |
But I believe this broke the admin panel. I cannot open it anymore, it redirects to the "normal" email overview. ... missing /run/ in url? |
v2.19.7 undid the auto-logout changes. Now it keeps the old account active even after logout and impersonate |
Good to know, now i know exactly what happens in Nextcloud. I will make a solution for it. |
The code did ocSession->set('snappymail-uid', 'Nextcloud user id') So now, i just write it to a cookie myself |
uff, storing cookies manually sounds like a security nightmare. Isn't a set operation supposed to return null? I mean, what else should it return? Does it return the correct value if you |
The cookie only contains your uid, but indeed it's not a great solution. If someone with Nextcloud expertise maybe can solve this. |
I found there is also a $uid = \OC::$server->getUserSession()->getUser()->getUID(); Looking at the code of @pierre-alain-b ... but I cannot assess how helpful that is for you. $this->userSession->listen('\OC\User', 'logout', function() {
$this->logout($this->appManager, $this->config, $this->session);
}); public static function LogoutCurrentLogginedUser() {
\RainLoop\Utils::ClearCookie('rlsession');
return true;
} public function SetAuthLogoutToken() {
@\header('X-RainLoop-Action: Logout');
\RainLoop\Utils::SetCookie(self::AUTH_SPEC_LOGOUT_TOKEN_KEY, \md5(APP_START_TIME), 0);
} |
Thanks for the help but the approach is the same. I've reported the issue to Nextcloud |
I've disabled all checks and this issue will be back until Nextcloud and/or Impersonate app solve the issues. |
Released v2.20.0 and the impersonate checks are disabled. When you use impersonate plugin:
|
I've read over the NC thread, does this also affect the logout/login behavior or can we have a version where at least the logout is triggered on NC logout? The problem with the Impersonate plugin has lower priority as I can just take precautions to not leak the login information (always open Snappy and click logout with the impersonated user) |
@relikd i've reported to Impersonate app with an optional solution |
While creating a PR for the Impersonate app, i found out about the NC18+ change. |
Describe the bug
I cannot assess whether this is a security issue or just inconvenience.
When I impersonate another user (plugin) my current auto-login account is still usable within that new user context. This was not the case for Rainloop.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Snappy should display the login mask as it have no E-Mail auto-login configured.
Actual behavior
Instead, Snappy uses the login credentials of email account B and displays all emails. I am not sure if the login information is only restored in my browser session or whether the credentials are somehow transfered to the user. Aka. if I accidentially leak my admin login to another user simply by impersonating him/her.
Please complete the following information:
The text was updated successfully, but these errors were encountered: