HEPTACOM / HeptacomShopwarePlatformAdminOpenAuth

Shopware plugin to allow open auth logins in the administration
https://www.heptacom.de/
Apache License 2.0
30 stars 10 forks source link

[Bug]: Ensure user is not created as admin first before the update #12

Open AndreasA opened 1 year ago

AndreasA commented 1 year ago

Plugin Version

4.2.1

PHP Version

8.1

Shopware Version

6.4.18.1

Installation method

Composer

Identity provider

Google Cloud

What happened?

The shopware user provisioner creates a user as admin by default. Therefore, the user is first created as admin - as nothing else is specified.

It would probably be better to initially create the user as non admin there and only use updateUser to set admin to true, if specified accordingly.

Relevant log output

No response

JoshuaBehrens commented 1 year ago

I like the approach following least privilege first :) we check whether we will release it as an update or take care of it in our already started 6.5 refactoring process.

AndreasA commented 8 months ago

I have not checked the code but is this still an issue with 6.0 or has this actually been fixed?

wimwenigerkind commented 1 month ago

In the current setup shown in the screenshot where I used plugin version 7, the Shopware user provisioner creates a user without any roles by default. This means that every new user is initially assigned no roles because no other specification is provided. Screenshot As a result, users encounter missing permissions errors, such as “locale” and “language”, which indicate that they do not have the necessary permissions for certain actions. Error

To prevent these errors and ensure that users have the required permissions to perform their tasks, it is advisable to assign a default role that does not include admin rights. This default role should grant the necessary permissions, such as “locale” and “language”, so users can operate without encountering these errors.

AndreasA commented 2 days ago

@JoshuaBehrens Any news when this might be fixed? As currently one could use password forget if the update fails and the user has full admin permissions.

it should also be a simple fix, just add 'admin' => false to https://github.com/HEPTACOM/HeptacomShopwarePlatformAdminOpenAuth/blob/main/src/Service/UserResolver.php#L66

JoshuaBehrens commented 2 days ago

@AndreasA as @wimwenigerkind already mentioned: in the version 7 of the plugin this is fixed by having a different approach on managing roles at all. So this could be the way for you to work with it.

AndreasA commented 17 hours ago

Hi @JoshuaBehrens the issue still exists in theory:

As mentioned it is a bit of an edge case but the fix is quite simple, just call

 $this->userProvisioner->provision($user->primaryEmail, $password, ['admin' => false, 'email' => $user->primaryEmail]);

instead of

 $this->userProvisioner->provision($user->primaryEmail, $password, ['email' => $user->primaryEmail]);

I can create a PR for this. Would also like to see that change in 6.x for extended support Shopware versions.

Maybe even active could be set to false and enabled in the update call, but that is not that important as a user without admin setting and without any other roles has no permissions to do anything whatsoever.