Post by by mona » Tue May 25, 2021 11:42 pm

ribalnet wrote:
Tue May 25, 2021 4:58 pm
Hello. I tested the OC Demo in my home with my Internet and it keeps happening. I dont know if you guys are understanding my point, but its like, I need +2 tabs opened in opencart, because I need it to add products and it will be easier for me of course. But everytime I try to have +2 open tabs I went down ...
This is because the user_token is propagated via a get variable and checked against the one stored in the session.
If you open two or more admin sessions in different tabs, your next tab will not have a get variable user_token and as such you will get that message.

You need to make sure the token is the same in both tabs in the address bar.
Then you won't even need to sign in and share the user_token between two tabs and all is fine.

You could also alter admin/controller/common/login.php

after:

Code: Select all

public function index() {
add:

Code: Select all

		if (!empty($this->session->data['user_token'])) {
			$this->response->redirect($this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true));
		}

Then you are automatically signed in on any other tab once you have signed in on the first.
Signing out on one tab signs out all tabs.


scenario:

tab1
1) go to admin and you will get the login page, no message as there is no user_token in the session yet
2) login, user_token A is set in the session and added to all urls as a get variable (check the browser address bar)

tab2
1) go to admin and you will get the login page with a message that the session token is not valid.
This is because you have a user_token A in your session but no user_token get variable in the url (they do not match)
2) login, you get a new user_token B which is stored in the session and added to the urls

tab1
1) click any link and you go to the login page again with the session token error message as your user_token in the session is now B while the user_token in the url is still A (they no longer match)
In other words, you are sharing the session and therefore the user_token in the session but you are not sharing the get variable user_token across tabs.
etc. etc. etc.

So if you make sure that you are also sharing the get variable user_token across your tabs, you can have as many admin tabs as you like.

Attachments

Screen-Shot-2021-05-25-at-17.23.06.jpg

Screen-Shot-2021-05-25-at-17.23.06.jpg (11.98 KiB) Viewed 805 times


DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by straightlight » Wed May 26, 2021 2:17 am

by mona wrote:
Tue May 25, 2021 11:42 pm
ribalnet wrote:
Tue May 25, 2021 4:58 pm
Hello. I tested the OC Demo in my home with my Internet and it keeps happening. I dont know if you guys are understanding my point, but its like, I need +2 tabs opened in opencart, because I need it to add products and it will be easier for me of course. But everytime I try to have +2 open tabs I went down ...
This is because the user_token is propagated via a get variable and checked against the one stored in the session.
If you open two or more admin sessions in different tabs, your next tab will not have a get variable user_token and as such you will get that message.

You need to make sure the token is the same in both tabs in the address bar.
Then you won't even need to sign in and share the user_token between two tabs and all is fine.

You could also alter admin/controller/common/login.php

after:

Code: Select all

public function index() {
add:

Code: Select all

		if (!empty($this->session->data['user_token'])) {
			$this->response->redirect($this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true));
		}

Then you are automatically signed in on any other tab once you have signed in on the first.
Signing out on one tab signs out all tabs.


scenario:

tab1
1) go to admin and you will get the login page, no message as there is no user_token in the session yet
2) login, user_token A is set in the session and added to all urls as a get variable (check the browser address bar)

tab2
1) go to admin and you will get the login page with a message that the session token is not valid.
This is because you have a user_token A in your session but no user_token get variable in the url (they do not match)
2) login, you get a new user_token B which is stored in the session and added to the urls

tab1
1) click any link and you go to the login page again with the session token error message as your user_token in the session is now B while the user_token in the url is still A (they no longer match)
In other words, you are sharing the session and therefore the user_token in the session but you are not sharing the get variable user_token across tabs.
etc. etc. etc.

So if you make sure that you are also sharing the get variable user_token across your tabs, you can have as many admin tabs as you like.
An event could accomplish this without the need to override core files.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by ribalnet » Wed May 26, 2021 5:20 pm

Dude thank you so much. I tried this and now its working sharing the same token!
I really appreciate all the time taken in this post just to help me :)
by mona wrote:
Tue May 25, 2021 11:42 pm
ribalnet wrote:
Tue May 25, 2021 4:58 pm
Hello. I tested the OC Demo in my home with my Internet and it keeps happening. I dont know if you guys are understanding my point, but its like, I need +2 tabs opened in opencart, because I need it to add products and it will be easier for me of course. But everytime I try to have +2 open tabs I went down ...
This is because the user_token is propagated via a get variable and checked against the one stored in the session.
If you open two or more admin sessions in different tabs, your next tab will not have a get variable user_token and as such you will get that message.

You need to make sure the token is the same in both tabs in the address bar.
Then you won't even need to sign in and share the user_token between two tabs and all is fine.

You could also alter admin/controller/common/login.php

after:

Code: Select all

public function index() {
add:

Code: Select all

		if (!empty($this->session->data['user_token'])) {
			$this->response->redirect($this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true));
		}

Then you are automatically signed in on any other tab once you have signed in on the first.
Signing out on one tab signs out all tabs.


scenario:

tab1
1) go to admin and you will get the login page, no message as there is no user_token in the session yet
2) login, user_token A is set in the session and added to all urls as a get variable (check the browser address bar)

tab2
1) go to admin and you will get the login page with a message that the session token is not valid.
This is because you have a user_token A in your session but no user_token get variable in the url (they do not match)
2) login, you get a new user_token B which is stored in the session and added to the urls

tab1
1) click any link and you go to the login page again with the session token error message as your user_token in the session is now B while the user_token in the url is still A (they no longer match)
In other words, you are sharing the session and therefore the user_token in the session but you are not sharing the get variable user_token across tabs.
etc. etc. etc.

So if you make sure that you are also sharing the get variable user_token across your tabs, you can have as many admin tabs as you like.

Newbie

Posts

Joined
Thu May 20, 2021 6:13 pm

Post by ADD Creative » Tue Mar 15, 2022 8:07 pm

For anyone finding this topic. The token in the URL is a security measure. I would also strongly advise against implementing the workaround posted. OpenCart 3.x has no protection against session fixation and earlier 3.x versions have issues removing sessions . If an attacker could set your session ID (which there are ways) they could gain access to your admin.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom
Who is online

Users browsing this forum: No registered users and 399 guests