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

Central membership and group table #29107

Closed
wants to merge 14 commits into from
Closed

Central membership and group table #29107

wants to merge 14 commits into from

Conversation

mrow4a
Copy link
Contributor

@mrow4a mrow4a commented Sep 27, 2017

Related Issue

fixes #27623

Plan

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
    • currently new methods are added to OCP\GroupInterface

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

How to test it:

https://github.com/owncloud/core/wiki/How-to-test-user_ldap

Main feature:

core/Migrations/Version20170927145820.php

lib/private/Group/BackendGroup.php
lib/public/AppFramework/Db/Mapper.php
lib/private/Group/GroupMapper.php
lib/private/MembershipManager.php

lib/private/Group/Group.php

lib/public/IGroupManager.php
lib/private/Group/Manager.php
lib/private/SubAdmin.php

Main sync feature:

lib/private/Group/SyncService.php
core/Command/Group/SyncBackend.php
core/register_command.php

Main changes:

lib/private/Group/Database.php
lib/private/User/Account.php
lib/private/User/AccountMapper.php
lib/private/User/Manager.php
lib/private/User/User.php

Required changes:

lib/base.php
lib/private/Server.php
lib/private/Setup.php
lib/private/Share/Share.php

settings/ajax/togglegroups.php
settings/users.php

core/Command/Group/ListGroups.php

Tests:

apps/federatedfilesharing/tests/TestCase.php
apps/files_sharing/tests/SharedMountTest.php
apps/files_sharing/tests/TestCase.php
apps/files_trashbin/tests/StorageTest.php
apps/provisioning_api/tests/AppsTest.php
apps/provisioning_api/tests/TestCase.php
tests/Core/Command/Group/AddMemberTest.php
tests/Core/Command/Group/AddTest.php
tests/Core/Command/Group/ListGroupMembersTest.php
tests/Core/Command/Group/ListGroupsTest.php
tests/Core/Command/Group/RemoveMemberTest.php
tests/Core/Command/Group/SyncBackendTest.php
tests/Core/Command/User/ListUserGroupsTest.php
tests/lib/App/ManagerTest.php
tests/lib/AppTest.php
tests/lib/Files/Config/UserMountCacheTest.php
tests/lib/Files/ViewTest.php
tests/lib/Group/Backend.php
tests/lib/Group/DatabaseTest.php
tests/lib/Group/DummyTest.php
tests/lib/Group/GroupMapperTest.php
tests/lib/Group/GroupTest.php
tests/lib/Group/ManagerTest.php
tests/lib/Group/SyncServiceTest.php
tests/lib/MembershipManagerTest.php
tests/lib/Share/ShareTest.php
tests/lib/SubAdminTest.php
tests/lib/Traits/GroupTrait.php
tests/lib/Traits/UserTrait.php
tests/lib/User/AccountMapperTest.php
tests/lib/User/ManagerTest.php
tests/lib/User/SyncServiceTest.php
tests/lib/User/UserTest.php
tests/lib/Util/Group/Dummy.php
tests/lib/Util/Group/MemoryGroupMapper.php
tests/lib/Util/MemoryMembershipManager.php
tests/lib/Util/User/MemoryAccountMapper.php

@mrow4a mrow4a force-pushed the centr_groups branch 3 times, most recently from 2059e50 to f3dc66e Compare September 27, 2017 17:43
}

return \OC::$server->getGroupManager()->getBackend($backendClass);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

will we support a displayname as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it requirement for LDAP?

@mrow4a mrow4a force-pushed the centr_groups branch 2 times, most recently from a2d2fdf to 8c6131d Compare September 27, 2017 19:14
@tomneedham tomneedham added this to the development milestone Sep 27, 2017
@mrow4a mrow4a force-pushed the centr_groups branch 5 times, most recently from 9540ea0 to 84340ed Compare September 28, 2017 22:47
*/
class BackendGroup extends Entity {

protected $groupId;
Copy link
Member

Choose a reason for hiding this comment

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

not needed

Copy link
Member

Choose a reason for hiding this comment

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

why? the table has id, group_id, display_name and backend
I intend to add a uuid column because group_id is more like a group_name. groups might be renamed. Display name is different, typically being more verbose.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think because the entity class handles these properties for you. Not that you don't need a groupId

Copy link
Member

Choose a reason for hiding this comment

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

the entity only handles id, group_id is something different. a lot of the other things could be removed though.

class BackendGroup extends Entity {

protected $groupId;
protected $displayName;
Copy link
Member

Choose a reason for hiding this comment

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

not needed

Copy link
Member

Choose a reason for hiding this comment

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

why?


protected $groupId;
protected $displayName;
protected $backend;
Copy link
Member

Choose a reason for hiding this comment

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

phpdoc missing


//TODO: Do it later since it requires changes here for Oracle https://github.com/owncloud/core/blob/master/lib/private/DB/OracleMigrator.php#L158-L160
// Add foreign keys on backend_group and accounts tables
//$table->addForeignKeyConstraint("{$prefix}backend_groups",array('backend_group_id'), array('id'));
Copy link
Member

Choose a reason for hiding this comment

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

please add right away

'notnull' => true,
'length' => 64,
]);
$table->setPrimaryKey(['id']);
Copy link
Member

Choose a reason for hiding this comment

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

no further indexes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not decide on it yet.

}

public static function tearDownAfterClass () {
\OC::$server->getDatabaseConnection()->rollBack();
Copy link
Member

Choose a reason for hiding this comment

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

I see - hmmmm - does this work?

*/
public function testGet() {
$result = $this->mapper->getGroup("TestFind1");
$this->assertInstanceOf("OC\Group\BackendGroup", $result);
Copy link
Member

Choose a reason for hiding this comment

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

BackendGroup::class

$backendGroup->setDisplayName("TestFind5");
$backendGroup->setBackend(self::class);

$mapper = \OC::$server->getGroupMapper();
Copy link
Member

Choose a reason for hiding this comment

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

use this->mapper

version.php Outdated

// The human readable string
$OC_VersionString = '10.0.3';
$OC_VersionString = '10.0.4';
Copy link
Member

Choose a reason for hiding this comment

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

no - keep 10.0.3

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think if you change the schema, you need to increment version.

Copy link
Member

Choose a reason for hiding this comment

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

Not the version string but oc_version

version.php Outdated
@@ -25,10 +25,10 @@
// We only can count up. The 4. digit is only for the internal patchlevel to trigger DB upgrades
// between betas, final and RCs. This is _not_ the public version number. Reset minor/patchlevel
// when updating major/minor version number.
$OC_Version = [10, 0, 3, 3];
Copy link
Member

Choose a reason for hiding this comment

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

no - 10.0.3.4

$migrator->migrate($startSchema);
$migrator->migrate($startFKSchema);

$this->assertTrue(true);
Copy link
Member

Choose a reason for hiding this comment

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

we should assert that the fk was set

return $this->quoteIndex($index);
}, $tableDiff->addedForeignKeys);

$tableDiff->changedForeignKeys = array_map(function(Index $index) {
Copy link
Member

Choose a reason for hiding this comment

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

ForeignKeyConstraint not Index

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, yes, sorry

@DeepDiver1975
Copy link
Member

foreign key pr is merged to master - please rebase - THX

@mrow4a
Copy link
Contributor Author

mrow4a commented Oct 5, 2017

One of the approaches proposed in #29154

@mrow4a
Copy link
Contributor Author

mrow4a commented Oct 9, 2017

@jvillafanez

@mrow4a mrow4a requested a review from jvillafanez October 9, 2017 13:10
@@ -232,13 +233,16 @@ public function __construct($webRoot, \OC\Config $config) {
$this->registerService('AccountMapper', function(Server $c) {
return new AccountMapper($c->getConfig(), $c->getDatabaseConnection(), new AccountTermMapper($c->getDatabaseConnection()));
});
$this->registerService('GroupMapper', function(Server $c) {
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if this should be here. The groupMapper isn't intended to be used isolated and it will depend on the groupManager.
I guess we can let it pass because the accountMapper is also exposed...

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 not exposed because as per definition developers are only allowed to work on interface which are in the OCP namespace.

* may be subject to change in the future
* @since 10.0.0
*/
abstract class Access {
Copy link
Member

Choose a reason for hiding this comment

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

I'm unsure of the purpose of this class... maybe it's the name what doesn't fit...

Just some personal recommendations to recheck:

  • Make sure the purpose of this class is clear. This implies that only the specific methods to fufill its purpose should be there.
  • Make sure the abstract class has clear extension points, and evaluate how subclasses will complete this abstract class.

I guess this second point is what bothers me: abstract classes should have at least an abstract method that subclasses should implement. This isn't the case here.
Inheritance doesn't seem the way to go in this case. I'd rather use composition: just create the "Access" class and inject it wherever its needed.

parent::setUpBeforeClass();
$mapper = \OC::$server->getGroupMapper();

\OC::$server->getDatabaseConnection()->beginTransaction();
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 add a comment to make sure the trick won't be forgotten, otherwise it's quite weird that you have one transaction hanging around.

@mrow4a
Copy link
Contributor Author

mrow4a commented Mar 11, 2018

@PVince81 @DeepDiver1975 @butonic @tomneedham I have been on the customgroups and guest, and I can see that they will need sync on login also.. thus I remove the requirement of the flag isSyncMaintained. LDAP will work out of the box with this PR since all the things will be synced on user login. Custom Groups also works, but will require small adjustment to work better

@mrow4a
Copy link
Contributor Author

mrow4a commented May 6, 2018

Updated the checklist for the discussions later if we want to go the direction proposed here.

@PVince81
Copy link
Contributor

lots of conflicts, PR needs reviving

@PVince81 PVince81 modified the milestones: development, backlog Jul 24, 2018
@mrow4a
Copy link
Contributor Author

mrow4a commented Aug 7, 2018

@PVince81 I will resolve the conflicts and summarize advantages of this solution and disadvantages - last time I posted a report was in March (https://cloud.owncloud.com/index.php/s/eUajBR59vQNUEq1#pdfviewer), and there was no review. But by then central accounts were also fresh

@DeepDiver1975
Copy link
Member

As discussed in #35777 the master branch will from now on hold the ownCloud 10 codebase.

This PR targetted ownCloud 11 which is postponed to a far distant future.

Because of that I'm closing this PR and kindly ask you to re-submit this PR in a few days.

Thanks a lot for your patience

@DeepDiver1975 DeepDiver1975 deleted the centr_groups branch July 30, 2019 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 - To Review enhancement Hacktoberfest p2-high Escalation, on top of current planning, release blocker settings:users
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Central group and membership tables
10 participants