[go: nahoru, domu]

Skip to content
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

Multiple Tabs, Database connections (auth_type cookie) : Error Token Mismatch #12301

Closed
jamesyooda opened this issue Jun 7, 2016 · 21 comments
Closed
Assignees
Labels
Bug A problem or regression with an existing feature
Milestone

Comments

@jamesyooda
Copy link

I've found other topics on this problem, this problem exists since version 4 of pma at least, and has yet to be fixed.

There are some fix propositions but I don't understand, because there are 3 different fixes, all modifying different files, I have no idea which fix to apply, if not all 3.

That is why i'm reporting this problem again in the hopes of getting a clear answer. Also to be noted I get this error also in version 4.4 as well.

Steps to reproduce

  1. Define mutliple sql servers in config.inc.php with auth_type as cookie
  2. Open up browser, navigate, to PMA, connect to one of the sql servers, open up a second tab, connect to a different sql server
  3. Try to perform any action on the first tab, you should get error : token mismatch

Expected behaviour

Tell us what should happen
Open up mulitple tabs, on each tab connect to a different mysql server with the same user account, when trying to perform any action on either tabs, should be no problems

Actual behaviour

Tell us what happens instead
Open up multiple tabs, on each tab connect to a different mysql server with the same user account, when trying to perform any action on the other tabs, you get Error: Token Mismatch

Server configuration

Operating system:
Debian Jessie

Web server:
Apache2.4.10

Database:
SQL

PHP version:
PHP 7.0

phpMyAdmin version:
PMA 4.6

Client configuration

Browser:
Chrome

Operating system:
Windows 7

@Mattie112
Copy link

I'm not sure if it is related to your issue but I'm getting the token mismatch on every action. I've asked it yesterday on stackoverflow but it might be useful for the devs here, so: https://stackoverflow.com/questions/37682465/phpmyadmin-4-6-2-token-mismatch

@nijel
Copy link
Contributor
nijel commented Jun 8, 2016

@jamesyooda What phpMyAdmin version do you use?

@Mattie112 Your issue will be most likely different, so either keep it on stackoverflow or open separate issue, thanks.

@jamesyooda
Copy link
Author

My phpmyadmin version is written in my original post, 4.6 or to be precise, 4.6.2, the latest version.

@jamesyooda
Copy link
Author

I have noticed recently, that for whatever reason, when you open a new tab and connection, it generates a new token for that connection, which is normal; but what isn't normal, is the previous connections I have already opened on different servers, try to obtain the new token, instead of keeping their original token.

I noticed this by doing a ctrl + F5 on the previous tabs, and noticed that they all obtained the token of the new connection I just opened.

@nijel nijel added the Bug A problem or regression with an existing feature label Jun 8, 2016
@nijel
Copy link
Contributor
nijel commented Jun 8, 2016

Okay, now I understand what happens - we generate new session on login, this includes new token. This overwrites old session cookie and thus the old session data (including token) are not accessible. So I think we need to generate new session only in case user is not already authenticated on different server.

@Mattie112
Copy link

@nijel Allright thx, I will see if I get a reply on stackoverflow and if not I will open a separate issue, thanks!

@jamesyooda
Copy link
Author

So is there a possible fix for this? I'm a systems administrator, not a php coder, so I wouldn't know where to start to debug this.

@jamesyooda
Copy link
Author

Another bit of info, is my collegues use multiple DIFFERENT users on multiple different sql servers. This needs to be possible without any token mismatch problems.

@nijel
Copy link
Contributor
nijel commented Jun 9, 2016

It really doesn't matter what users are that, what matters is one browser session.

@jamesyooda
Copy link
Author

Alright, how do things work here? Does someone have to be assigned to work on the problem? Are you working on the problem?

@nijel
Copy link
Contributor
nijel commented Jun 9, 2016

You can see nobody is assigned, so nobody from our team is working on the fix right now...

@WanWizard
Copy link
Contributor

I've upgraded our management system today (from 4.0.x to the latest version), and where this worked fine before, now it's broken.

This issue has been open for 10 months now, perhaps it's time to bump the priority?

@WanWizard
Copy link
Contributor
WanWizard commented Apr 12, 2017

Workaround (v4.7.0), in ./libraries/plugins/AuthenticationPlugin.php, replace logOut() with:

    public function logOut()
    {
        global $PHP_AUTH_USER, $PHP_AUTH_PW;

        /* Obtain redirect URL (before doing logout) */
        if (! empty($GLOBALS['cfg']['Server']['LogoutURL'])) {
            $redirect_url = $GLOBALS['cfg']['Server']['LogoutURL'];
        } else {
            $redirect_url = $this->getLoginFormURL();
        }

        /* Get a logged-in server count */
        $servers = 0;
        foreach ($GLOBALS['cfg']['Servers'] as $key => $val) {
            if (isset($_COOKIE['pmaAuth-' . $key])) {
                $servers++;
            }
        }

        /* No more servers logged in? */
        if ( ! $servers) {
            // kill the session
            $_SESSION = array();
            session_destroy();
        }

        /* Clear credentials */
        $PHP_AUTH_USER = '';
        $PHP_AUTH_PW = '';

        /* Redirect to login form (or configured URL) */
        PMA_sendHeaderLocation($redirect_url);
    }

It will only delete the session once the last server is logged out, so other open windows will still work when you log out of one server.

Only issue I still have is when I try to login in another server, it sometimes fails and it returns to the login screen, and sometimes it succeeds but opens with the first server in the dropdown, not the one I've logged into (root passwords all the same for all nodes, I'm a lazy tester ;)).

@awright424
Copy link

WanWizard will this work for the version below? I have just installed this on a server and we have this issue when doing this for years with prior versions.
Version information: 4.6.6deb1+deb.cihar.com~trusty.2

@WanWizard
Copy link
Contributor

From what I can see in a quick code scan, the logOut() method was introduced in 4.6.2, so it should work.

Just replace

       /* delete user's choices that were stored in session */
        $_SESSION = array();
        if (!defined('TESTSUITE')) {
            session_destroy();
        }

by

        /* Get a logged-in server count */
        $servers = 0;
        foreach ($GLOBALS['cfg']['Servers'] as $key => $val) {
            if (isset($_COOKIE['pmaAuth-' . $key])) {
                $servers++;
            }
        }

        /* No more servers logged in? */
        if ( ! $servers and ! defined('TESTSUITE')) {
            // kill the session
            $_SESSION = array();
            session_destroy();
        }

don't forget to make a backup of the file, before you change it. Just in case... ;-)

@nijel
Copy link
Contributor
nijel commented Apr 28, 2017

@WanWizard You fix makes sense, can you please create pull request for that?

WanWizard added a commit to WanWizard/phpmyadmin that referenced this issue Apr 28, 2017
…in#12301

If you are logged-in into multiple database servers, logOut() logs you out of all of them. This fix will prevent that, and will only destroy the session when you log out of the last server.
@WanWizard
Copy link
Contributor

No problem, PR created.

@nijel
Copy link
Contributor
nijel commented Apr 28, 2017

Thanks, I will improve it a bit and merge. But that works only in case LoginCookieDeleteAll is set to false, what nobody of you have mentioned before...

@nijel nijel closed this as completed in cde775b Apr 28, 2017
nijel added a commit that referenced this issue Apr 28, 2017
- avoid removing session for cookie auth if LoginCookieDeleteAll is
  disabled
- redirect user to other server rather than to login page
- show message about partial logout
- adjust tests
- this is based on #13221

Fixes #12301

Signed-off-by: Michal Čihař <michal@cihar.com>
@nijel nijel self-assigned this Apr 28, 2017
@nijel nijel added this to the 4.7.1 milestone Apr 28, 2017
@WanWizard
Copy link
Contributor

Didn't even know that flag existed. Thanks for the update.

@stalker37
Copy link
stalker37 commented Jun 20, 2019

some problem on phpmyadmin 4.9.0.1
after log in to one database phpmyadmin is logout from another database in second tab in browser

@williamdes
Copy link
Member

@stalker37 You are right but this is more #14235 for now

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A problem or regression with an existing feature
Projects
None yet
Development

No branches or pull requests

7 participants