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

Add occ commands to enable and disable a user + a disabled user can n… #23844

Merged
merged 6 commits into from
May 3, 2016

Conversation

DeepDiver1975
Copy link
Member

…o longer login - fixes #23838

@rullzer @LukasReschke @MorrisJobke

@DeepDiver1975 DeepDiver1975 added this to the 9.1-current milestone Apr 7, 2016
@mention-bot
Copy link

By analyzing the blame information on this pull request, we identified @icewind1991, @butonic and @xoen to be potential reviewers

* @param bool $value
* @return OC_OCS_Result
*/
private function setEnabled($parameters, $value) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like some integration tests on this covering the following scenarios:

  1. Subadmin should be able to enable or disable an user in their group
  2. Subadmins should NOT be able to enable or disable an user not in their group
  3. Subadmins should not be able to disable users that have admin permissions even if they are in their group
  4. Admins can enable and disable any user
  5. Regular users will get an exception
  6. It should not be possible to disable or enable ones own account, neither as admin nor as subadmin

cc @owncloud/qa

Copy link
Contributor

@nickvergessen nickvergessen Apr 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\3. is not covered by the code?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is. Check L370

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. Bloody GitHub, if I click on edit it shows "3." instead of "1."

Yes. 3, is not covered yet.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SergioBertolinSG do we have this covered now ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it works fine.

@DeepDiver1975
Copy link
Member Author

Additional integration tests to be implemented:

  1. disable user
  2. 503 is received via dav
  3. 503 is received via ocs api calls
  4. 503 is received via web requests

@rullzer
Copy link
Contributor

rullzer commented Apr 7, 2016

I did not check yet. But does this somehow yield the users shares invalid?

@LukasReschke
Copy link
Member

I did not check yet. But does this somehow yield the users shares invalid?

Is this really required? I mean if you disable an user on an Active Directory server one can also still access files that belonged to them  🙈

Edit: Ah… Right… The migration scenario, my bad :)

@@ -229,7 +235,7 @@ public function login($uid, $password) {
throw new LoginException('Login canceled by app');
}
} else {
return false;
throw new LoginException('User disabled');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do we localize the string so the user can be shown a proper message when he tries to login?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be done here - thanks for the pointer

@@ -241,3 +241,10 @@ Feature: webdav-related
| 0 |
| 1 |
| 3 |

Scenario: A disabled user cannot use webdav
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to fail 🙈

@DeepDiver1975 DeepDiver1975 force-pushed the disable-user branch 3 times, most recently from 9124c18 to 2a94fd2 Compare April 12, 2016 07:34
@DeepDiver1975
Copy link
Member Author

😠

Checked 4387 files in 45.2 seconds
Syntax error found in 1 file
------------------------------------------------------------
Parse error: ./lib/composer/composer/autoload_static.php:22
    20|         'OC\\Settings\\' => 
    21|         array (
  > 22|             0 => __DIR__ . '/../../..' . '/settings',
    23|         ),
    24|         'OC\\Core\\' => Unexpected '.', expecting ')'

@DeepDiver1975
Copy link
Member Author

@nickvergessen @LukasReschke @MorrisJobke any idea why in this pr the composer generated file is causing trouble?

@DeepDiver1975
Copy link
Member Author

issues seem to be related to php 5.4 and 5.5

@DeepDiver1975
Copy link
Member Author

same fun in #23708 - master broken?

@LukasReschke
Copy link
Member

Mhm. We don't ship any /lib/composer/composer/autoload_static.php, seems like composer on Travis generates this automatically… Let's see why it does that 😉

@LukasReschke
Copy link
Member

Mhm…

Composer version 1.1-dev (4f0f8779cb6db67d2186e3480f5ca2243e9916e5) 2016-04-11 18:36:39

Caused by composer/composer@fd2f51cea8e5f1ef978cd8f90b87b69dc1778976… Let me see what one can do about that …

@LukasReschke
Copy link
Member

Ok. autoload_static.php is only loaded when PHP >= 5.6 is used. #23935 adjusts the linter accordingly.

@DeepDiver1975
Copy link
Member Author

@MorrisJobke @LukasReschke @rullzer please review and test once more - basic integration test added - needs further work @SergioBertolinSG

THX

@@ -59,7 +59,7 @@ protected function tearDown() {
}

protected function setup() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camelCase missing as well

@nickvergessen
Copy link
Contributor

Btw in terms of tracking, would be nice to have a hook for the admin_audit app

@DeepDiver1975
Copy link
Member Author

Btw in terms of tracking, would be nice to have a hook for the admin_audit app

agreed - please open a ticket in core and enterprise so that we can consume it. THX

@PVince81
Copy link
Contributor

Integration tests failing:

06:19:13     /ssd/jenkins/workspace/ocs-api-integration-tests-ci@3/build/integration/features/provisioning-v1.feature:503
06:19:13     /ssd/jenkins/workspace/ocs-api-integration-tests-ci@3/build/integration/features/sharing-v1.feature:700

(log is too big)

@DeepDiver1975
Copy link
Member Author

Oh shit ... I guess I fucked up the rebase .....

@PVince81
Copy link
Contributor

PVince81 commented May 3, 2016

So much bad luck. Now that I was determined to review and test this, LDAP login is broken on this branch and master also... #24409

@PVince81
Copy link
Contributor

PVince81 commented May 3, 2016

  • TEST: sync client stops syncing after disabling user (note: sync client shows no error at all, might need additional fixing there @dragotin)
  • TEST: disable local user
  • TEST: can still share with disabled user
  • TEST: can still access received local shares from disabled user
  • TEST: can still access received fed shares from disabled user
  • TEST: reenable user => sync client resumes without restart
  • TEST: delete file as recipient still moves file to disabled user's trashbin
  • TEST: edit file as recipient still creates versions for disabled user
  • TEST: encryption still works as recipient to disabled user's folder
  • TEST: web UI (ajax) reloads page when user disabled with open session
  • TEST: logout as disabled user
  • TEST: disable LDAP user
  • TEST: subadmin enable/disable
  • BUG: CSRF mess up:
  1. Clear cookies
  2. Login as "user1" (when enabled)
  3. On the CLI, disable "user1"
  4. In the web UI as "user1", click "Log out"
  5. Login as "admin" again
    => "CSRF check failed" page.

@DeepDiver1975
Copy link
Member Author

Clear cookies
Login as "user1" (when enabled)
On the CLI, disable "user1"
In the web UI as "user1", click "Log out"
Login as "admin" again => "CSRF check failed" page.

@LukasReschke mind taking a look? THX

@@ -41,6 +44,8 @@
API::register('get', '/cloud/users/{userid}', [$users, 'getUser'], 'provisioning_api', API::USER_AUTH);
API::register('put', '/cloud/users/{userid}', [$users, 'editUser'], 'provisioning_api', API::USER_AUTH);
API::register('delete', '/cloud/users/{userid}', [$users, 'deleteUser'], 'provisioning_api', API::SUBADMIN_AUTH);
API::register('put', '/cloud/users/{userid}/enable', [$users, 'enableUser'], 'provisioning_api', API::SUBADMIN_AUTH);
API::register('put', '/cloud/users/{userid}/disable', [$users, 'disableUser'], 'provisioning_api', API::SUBADMIN_AUTH);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general to be more RESTful another idea would be to still do a "PUT" on "/cloud/users/{userid}" and set the "enabled" attribute to true or false. (PUT being an "edit" operation)

This also means that the GET operation would return the "enabled" flag as well with the user's properties.

I'm ok with keeping in that way if that's too much to rework.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that GET already returns the flag. So intuitively as an API consumer, I'd be tempted to try and set it the way I described.

However now I see that it says "displayName" in the response but the PUT value is "display" 😞

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well - true restful would be to have only one GET to retrieve a json object holding all information and one PUT where we can push a full json object to store the new state.

But the whole provisioning api is not REST - so nothing to worry about - in the scope for v1.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙈 agreed

@PVince81
Copy link
Contributor

PVince81 commented May 3, 2016

Looks good from my POV 👍

@DeepDiver1975 did you test this with shib ?

@DeepDiver1975
Copy link
Member Author

@DeepDiver1975 did you test this with shib ?

no - I have currently no working shib test environment at hand - I suggest to merge and test this by QA

@davitol
Copy link
Contributor

davitol commented May 3, 2016

Testing with Shib and Autoprovisioning:

Disabling/Enabling a user seems to work fine. But when disabling a shibboleth user and trying to log in with him, the following page is shown. Not sure if it is intended or not:

screen shot 2016-05-03 at 13 56 44

No logs are written in owncloud.log

Tested using Testshib and autoprovisioning mode

Steps tested:

  1. Apply the patch
  2. Disable a Shib user
  3. Try to log in with this user
  4. Enable the same Shib user
  5. Log in with this user

@DeepDiver1975
Copy link
Member Author

I guess there is not much more we can do from a core pov. I guess we need to capture this situation and display a page like: you are disabled.

This has to be done in the shibboleth app

@PVince81
Copy link
Contributor

PVince81 commented May 3, 2016

"you are disabled" sounds a bit funny 😄

@davitol davitol added the tested label May 3, 2016
@davitol
Copy link
Contributor

davitol commented May 3, 2016

👍 in that case

@DeepDiver1975 DeepDiver1975 merged commit 4b25449 into master May 3, 2016
@DeepDiver1975 DeepDiver1975 deleted the disable-user branch May 3, 2016 13:22
@DeepDiver1975
Copy link
Member Author

@davitol please open an issue in the shibboleth repo - THX

@lock
Copy link

lock bot commented Aug 6, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow disabling of a single user
10 participants