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

ImpersonateUser fix #893

Merged
merged 1 commit into from
Dec 27, 2017
Merged

ImpersonateUser fix #893

merged 1 commit into from
Dec 27, 2017

Conversation

bscheshirwork
Copy link
Contributor

* Tokens enclosed within curly brackets are treated as controller action IDs (also called *button names*
* in the context of action column). They will be replaced by the corresponding button rendering callbacks
* specified in [[buttons]]. For example, the token `{view}` will be replaced by the result of
* the callback `buttons['view']`. If a callback cannot be found, the token will be replaced with an empty string.
Q A
Is bugfix? yes
New feature? no
Breaks BC? yes/no
Fixed issues #890

@thyseus
Copy link
Contributor

thyseus commented Mar 17, 2017

+1 - please merge :)

@thyseus
Copy link
Contributor

thyseus commented May 23, 2017

@bscheshirwork Hey - could you please copy your PR over to https://github.com/dabilite/yii2-user/pulls ? We currently have an fork of dektrium/yii2-user ongoing. Thanks !

bscheshirwork added a commit to bscheshirwork/yii2-user that referenced this pull request May 24, 2017
@bscheshirwork
Copy link
Contributor Author

You are clearly not doing the right thing.

17 opened PR.

3 new Member... 759 stars!

Can resolve problem in this project.

@thyseus
Copy link
Contributor

thyseus commented May 24, 2017

The Idea is to do a "temporary fork" of the dektrium module collection that can be merged back into dektrium once @dmeroff or @thiagotalma have enough resources again to manage the project.

@bscheshirwork
Copy link
Contributor Author

Sure? A nightmare for combining and verifying which of the PRs were combined to you branch and which are not.

@thyseus
Copy link
Contributor

thyseus commented May 24, 2017

Git is decentral by design, i don´t see any problems with it.

@YiiRocks
Copy link
Contributor

I don't feel much for moving over to another fork for the moment and having to move back later in my projects. You are not only dealing with a decentral system, but also with user implementations.

@thiagotalma thiagotalma merged commit 751e7ab into dektrium:master Dec 27, 2017
@thiagotalma
Copy link
Member

Merged. Thanks!

@schmunk42
Copy link
Contributor

Sorry I haven't checked this in detail, but it looks to me like only the button is hidden. There should be additional checks in the controller or not?

@thiagotalma
Copy link
Member

@schmunk42 Can you create a new PR with the changes that you think necessary?

@bscheshirwork bscheshirwork deleted the patch-2 branch January 9, 2018 07:43
@bscheshirwork
Copy link
Contributor Author

I can't remember...

So.. this action allow to all for design reason (one action to masquerade and to go out)

'rules' => [
[
'allow' => true,
'actions' => ['switch'],
'roles' => ['@'],
],
[
'allow' => true,
'roles' => ['admin'],
],
],

and check access inside

if (!Yii::$app->user->identity->isAdmin) {
throw new ForbiddenHttpException;
}

@bscheshirwork
Copy link
Contributor Author

@schmunk42 look at this ^

@schmunk42
Copy link
Contributor

Ah, I remember :) Actually, we have this permission set.

Our problem comes from the fact that we have ie. three roles for users: admin, developer and editor. A developer should be able to use the user-module, but if we set the adminPermission he can also become an admin.

So giving the adminPermission of the user-module to a user is equivalent to giving him full access to the application, even though he has no access to RBAC.
Thinking about this, there would have to be also an additional check for assignments.

I guess we need to implement this via events or is this something you would like to address in the user-module?

@bscheshirwork
Copy link
Contributor Author

bscheshirwork commented Jan 9, 2018

@schmunk42 yes

Yii::$app->user->identity->isAdmin

will be customize throw adminPermission property of this module. But adminPermission property is not role only.
For example we can create permission administrateUser and assign it to admin role only

    'modules' => [
        'user' => [
            'class' => 'dektrium\user\Module',
            'enableRegistration' => false,
            'adminPermission' => 'administrateUser',
...

@bscheshirwork
Copy link
Contributor Author

bscheshirwork commented Jan 9, 2018

or we have developer who can masquerade into user?

@thyseus
Copy link
Contributor

thyseus commented Jan 9, 2018

Using a 'developer' role could be misleading. We use the impersonate user function also on the live system, for the administrators to see what the user has done. We use a own role 'can-impersonate' for this to fine-grain which administrators should get this (very powerful!) access right.

@schmunk42
Copy link
Contributor

We use a own role 'can-impersonate' ...

I thought about a similar thing.

Moreover, although I haven't check this in detail ... a user should only be able to assign permissions/roles he has Yii::$app->user->can(), maybe in conjunction with a property can-assign-revoke?

@bscheshirwork
Copy link
Contributor Author

So... This is argument for redesign it.

@thyseus
Copy link
Contributor

thyseus commented Jan 9, 2018

Big +1 for the can-assign-revoke idea. Being able to fine-grain the administrator access rights is really important. One should also not be able to impersonate into any other administrator user ! Currently this is possible, so every admin could do everything, when he knows how. We definitely need some huge redesign for this feature.

I am still not sure if all our work and love should better go into yii2-usuario though... will this fork ever be merged into dektrium again?

@bscheshirwork
Copy link
Contributor Author

@thyseus @schmunk42 how about separate administrate and impersonate?

    'modules' => [
        'user' => [
            'class' => 'dektrium\user\Module',
            'adminPermission' => 'administrateUser',
            'impersonatePermission' => 'impersonateUser',

@bscheshirwork
Copy link
Contributor Author

will this fork ever be merged into dektrium again?

I can see some merged PR

@thyseus
Copy link
Contributor

thyseus commented Jan 9, 2018

I mean: in the long term its bad to have dektrium/yii2-user and yii2-usuario in parallel with the same codebase but different features... there should be one, great user module for yii2.

@schmunk42
Copy link
Contributor

I'd be also very interested in a common code-base.

@thiagotalma Are you a maintainer of this project now? Looks to me like this is the case from commits and releases.

@tonydspaniard Will you or someone of your team be able to support yii2-usuario in the long term?

@thyseus
Copy link
Contributor

thyseus commented Jan 9, 2018

Furthermore (just collecting ideas): all impersonating actions should be logged very precisely (login+logout time) so one can determine which action was done by the "real" user, and which one by the "admin".

For example, we use yii\behaviors\BlameableBehavior a lot, and the created_by column would be set to the user id in Yii::app->user->id - the "real" user, even when impersonated through the admin. We should think about how we handle this.

What happens when the real user and the impersonating administrator are logged in simultaneously (not uncommon when the admin tries to support the user in real-time) ? How do we avoid conflicts (row lock, ...)

@thiagotalma
Copy link
Member

I'd be also very interested in a common code-base.

@thiagotalma Are you a maintainer of this project now? Looks to me like this is the case from commits and releases.

@tonydspaniard Will you or someone of your team be able to support yii2-usuario in the long term?

@schmunk42 Please, join here

@thyseus
Copy link
Contributor

thyseus commented Mar 1, 2018

I just found the time to add some security improvements to the impersonating feature:

#1014

@thiagotalma @schmunk42 @bscheshirwork @tonydspaniard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants