Zen Cart Logo
Forums / Addon Admin Tools / Login restrictions (and possible security problem)

Login restrictions (and possible security problem)

Views: 2,304

Results 1 to 17 of 17
8 May 2023, 3:25 PM
#1
helenewallis avatar

helenewallis

Totally Zenned

Join Date:
Jun 2016
Location:
Suffolk VA
Posts:
625
Plugin Contributions:
0

Login restrictions (and possible security problem)

I'm working on a plugin that will be used by only a small number of employees. They should not see any other aspects of company operation on the admin side, but there appears to be no way to shut them out of everything. I added a test user to find out what they would see, and enabled nothing but a single one of the admin tools (just so something would show up). This test user can see the entire admin dashboard with customer names, phone numbers and email addresses, company statistics, and a lot of things I don't want them to see. I think this could be a security concern for many companies.

The only menu items available to them were Modules, Customers, Locations / Taxes, Localization, Reports, Tools, and Discounts, and there was only a limited number of choices under each of those menus. But I do not want these employees to see anything other than the single plugin that they will be using. Is there some reasonably uncomplicated way to do that, so that when a person with a certain profile logs in, the screen goes directly to the code they need to see and use?

9 May 2023, 9:56 PM
#3
helenewallis avatar

helenewallis

Totally Zenned

Join Date:
Jun 2016
Location:
Suffolk VA
Posts:
625
Plugin Contributions:
0

Re: Login restrictions (and possible security problem)

swguy:

https://docs.zen-cart.com/user/admin/employee_restricted/

I did all of that. But it appears that I inadvertently chose the wrong user profile to assign the test user to. When I went back and corrected that, the test user could still see some company statistics, but nothing else beyond what I had enabled for that profile.

However, that doesn’t solve the underlying problem of wanting this group of employees to go straight to the plug-in I’m writing when they log in, without seeing any other company information. They have no reason or need to do so. I don’t want them to see a message that their login credentials don’t give them access to other things, because they don’t need to know there are other things they might be able to get access to. Is that not possible?

10 May 2023, 12:08 AM
#4
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,708
Plugin Contributions:
56

Re: Login restrictions (and possible security problem)

You'd have to write some custom code to get the behavior you are describing.

10 May 2023, 12:05 PM
#5
helenewallis avatar

helenewallis

Totally Zenned

Join Date:
Jun 2016
Location:
Suffolk VA
Posts:
625
Plugin Contributions:
0

Re: Login restrictions (and possible security problem)

swguy:

You'd have to write some custom code to get the behavior you are describing.

Yes, that is what I asked for help with. Is there some reasonably uncomplicated way to do this? Even a hint in the right direction would be useful. I know that you can enable certain things when an admin is logged in, so I assume the opposite action could be undertaken as well. I'll eventually figure it out on my own, but any assistance would be appreciated.

10 May 2023, 1:25 PM
#6
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,708
Plugin Contributions:
56

Re: Login restrictions (and possible security problem)

A simple change would be just to not show any data on the home page. Edit admin/index_dashboard.php wrap the div with id "colone" with

<?php if (zen_is_superuser()) { ?>

and end it with <?php } ?>

10 May 2023, 1:51 PM
#7
helenewallis avatar

helenewallis

Totally Zenned

Join Date:
Jun 2016
Location:
Suffolk VA
Posts:
625
Plugin Contributions:
0

Re: Login restrictions (and possible security problem)

swguy:

A simple change would be just to not show any data on the home page. Edit admin/index_dashboard.php wrap the div with id "colone" with

<?php if (zen_is_superuser()) { ?>

and end it with <?php } ?>

Thank you very much indeed. That is almost exactly what I need to do. I'll modify that to allow access to all users other than the one who needs to be completely shut out.

I'm slowly figuring out the Zencart architecture, so I may ask what seem like stupid questions sometimes. But I am not a newbie to programming (though I'm still learning PHP). So even a little bit of help is usually enough to get me started in the right direction.

10 May 2023, 5:37 PM
#8
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,708
Plugin Contributions:
56

Re: Login restrictions (and possible security problem)

I may ask what seem like stupid questions sometimes.

Trust me, you're doing fine.

If you want a little project to increase your knowledge, try this:
modify the admin_profiles table and associated screen to provide a "home page" for non-superusers.
(you could also do this by modifying the admin table if you wanted different home pages for different non-superusers.)

If it works out, you can submit it as a plugin so others can benefit from your work

10 May 2023, 7:12 PM
#9
helenewallis avatar

helenewallis

Totally Zenned

Join Date:
Jun 2016
Location:
Suffolk VA
Posts:
625
Plugin Contributions:
0

Re: Login restrictions (and possible security problem)

swguy:

I may ask what seem like stupid questions sometimes.

Trust me, you're doing fine.

If you want a little project to increase your knowledge, try this:
modify the admin_profiles table and associated screen to provide a "home page" for non-superusers.
(you could also do this by modifying the admin table if you wanted different home pages for different non-superusers.)

If it works out, you can submit it as a plugin so others can benefit from your work

Thanks for the suggestion. I hadn't thought of doing anything like that. I may postpone it until after the one I'm working on now is finished. Or I may incorporate it as a configuration setting in the current plugin, which would be a nice refinement.

10 May 2023, 8:20 PM
#10
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,708
Plugin Contributions:
56

Re: Login restrictions (and possible security problem)

OK, just an idea based on your original post, where you asked

when a person with a certain profile logs in, the screen goes directly to the code they need to see and use?

What you (probably) have now - most menus turned off, no home page content - is probably intuitive enough that your staff can figure it out.

10 May 2023, 8:54 PM
#11
helenewallis avatar

helenewallis

Totally Zenned

Join Date:
Jun 2016
Location:
Suffolk VA
Posts:
625
Plugin Contributions:
0

Re: Login restrictions (and possible security problem)

swguy:

OK, just an idea based on your original post, where you asked

when a person with a certain profile logs in, the screen goes directly to the code they need to see and use?

What you (probably) have now - most menus turned off, no home page content - is probably intuitive enough that your staff can figure it out.

I'm sure it is. I just don't want those people to see that there may be more content that they don't have access to. Or get an explicit message that more is present if only they had some other login credentials. But I really like the idea of that being a configuration option as well, because not everyone may feel as strongly about that point as I do. I had an employee who tried to poke around in another employee's computer to see what he could find out about the company. Granted, not being able to see even the home page isn't going to prevent someone from trying that stunt anyway. But it will lessen (I hope) the assumption that someone else might have something more interesting to look at.

The plugin I'm working on is to assist with order packing, to reduce errors in shipping. The people who are doing that will have no other responsibility in the company and there's no reason for them to have access to anything else (or to see that there is anything else).

10 May 2023, 10:18 PM
#12
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,097
Plugin Contributions:
56

Re: Login restrictions (and possible security problem)

An admin with restricted permissions, i.e. they're not allowed to view orders, customers, sales reports or whos-online will only see menu tabs containing their permitted tools and, on the home page, the current traffic as well as the base statistics ... neither of which I think give away sensitive information.

13 May 2023, 11:54 AM
#13
helenewallis avatar

helenewallis

Totally Zenned

Join Date:
Jun 2016
Location:
Suffolk VA
Posts:
625
Plugin Contributions:
0

Re: Login restrictions (and possible security problem)

lat9:

An admin with restricted permissions, i.e. they're not allowed to view orders, customers, sales reports or whos-online will only see menu tabs containing their permitted tools and, on the home page, the current traffic as well as the base statistics ... neither of which I think give away sensitive information.

True, and if I can't do a different home page for them, or take them directly to their login page, that will not be unacceptable. I'm still trying to get my program registered on the admin side so I can test it, so I've had to put the home page part on the back burner for the moment. I'm not sure what I'm doing wrong there yet, but if I still can't figure it out in another day or so, I'll ask for help with that.

13 May 2023, 4:29 PM
#14
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,708
Plugin Contributions:
56

Re: Login restrictions (and possible security problem)

Guidance on adding an admin page:

https://docs.zen-cart.com/dev/code/creating_menu/

13 May 2023, 6:35 PM
#15
helenewallis avatar

helenewallis

Totally Zenned

Join Date:
Jun 2016
Location:
Suffolk VA
Posts:
625
Plugin Contributions:
0

Re: Login restrictions (and possible security problem)

swguy:

Guidance on adding an admin page:

https://docs.zen-cart.com/dev/code/creating_menu/

Yes, that's what I'm using as a guide. I finally figured it out--'TOOLS' was missing from the declaration in ADMIN/includes/language/english/extra_definitions/

As often happens, I learned a lot more by getting an error message 10 times than by getting it right the first time, lol. Now all I have to do is make the program itself work correctly. And then figure out how to fit it into the new plugin format. One step at a time. Thanks for your help.

13 May 2023, 6:53 PM
#16
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,097
Plugin Contributions:
56

Re: Login restrictions (and possible security problem)

... and if you're also looking to conditionally display the tool's output on the admin home-page, check out /admin/includes/modules/dashboard_widgets/RecentOrdersDashboardWidget.php.

That widget restricts its home-page display to either super-user admins or those that have permissions to use the Customers :: Orders tool.

13 May 2023, 7:18 PM
#17
helenewallis avatar

helenewallis

Totally Zenned

Join Date:
Jun 2016
Location:
Suffolk VA
Posts:
625
Plugin Contributions:
0

Re: Login restrictions (and possible security problem)

Thanks, I'll do that.