-
Notifications
You must be signed in to change notification settings - Fork 14
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
DAV endpoint #7
DAV endpoint #7
Conversation
de35e52
to
fed5bef
Compare
Rebased, added lots of tests. A few calls and conditions are missing still. |
fed5bef
to
cb2f959
Compare
Already implemented the main part of the spec #3 for managing groups and memberships. Next step: REPORT |
I've added the REPORT as well: Here is how to get one. <?xml version="1.0" encoding="utf-8" ?>
<oc:filter-members xmlns:a="DAV:" xmlns:oc="http://owncloud.org/ns" >
<oc:filter-rules>
<oc:user-id>user1</oc:user-id>
<!-- <oc:is-admin>1</oc:is-admin> -->
</oc:filter-rules>
</oc:filter-members> Then Gives: <?xml version="1.0"?>
<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:cs="http://calendarserver.org/ns/" xmlns:card="urn:ietf:params:xml:ns:carddav" xmlns:oc="http://owncloud.org/ns">
<d:response>
<d:status>HTTP/1.1 200 OK</d:status>
<d:href>/owncloud/remote.php/dav/customgroups/x/user1</d:href>
<d:propstat>
<d:prop>
<oc:is-admin>0</oc:is-admin>
</d:prop>
<d:status>HTTP/1.1 200 OK</d:status>
</d:propstat>
</d:response>
<d:response>
<d:status>HTTP/1.1 200 OK</d:status>
<d:href>/owncloud/remote.php/dav/customgroups/y/user1</d:href>
<d:propstat>
<d:prop>
<oc:is-admin>0</oc:is-admin>
</d:prop>
<d:status>HTTP/1.1 200 OK</d:status>
</d:propstat>
</d:response>
</d:multistatus> It basically returns the result for the I'd like to refine this separately once we start working on the UI. |
0480c8c
to
68df270
Compare
The sad thing about adding this is that now I need to inject a group manager everywhere... |
lib/Dav/CustomGroupMemberNode.php
Outdated
/** | ||
* @author Vincent Petry <pvince81@owncloud.com> | ||
* | ||
* @copyright Copyright (c) 2016, ownCloud GmbH. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- .
|
||
$memberInfos = $this->node->getChildren(); | ||
|
||
$this->assertInstanceOf('\OCA\CustomGroups\Dav\CustomGroupMemberNode', $memberInfos[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CustomGroupMemberNode::class
lib/Dav/CustomGroupsPlugin.php
Outdated
* | ||
* This method should set up the required event subscriptions. | ||
* | ||
* @param Server $server |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Server is unknown
lib/Dav/CustomGroupsPlugin.php
Outdated
* @param [] $report | ||
* @param string $uri | ||
* @return bool | ||
* @throws NotFound |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NotFound is unknown
lib/Dav/CustomGroupsPlugin.php
Outdated
* @param string $uri | ||
* @return bool | ||
* @throws NotFound | ||
* @throws ReportNotSupported |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ReportNotSupported is unknown
lib/Dav/CustomGroupsPlugin.php
Outdated
public function onReport($reportName, $report, $uri) { | ||
$node = $this->server->tree->getNodeForPath($uri); | ||
if(!$node instanceof RootCollection || $reportName !== self::REPORT_NAME) { | ||
throw new ReportNotSupported(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ReportNotSupported is unknown
lib/Dav/RootCollection.php
Outdated
/** | ||
* @author Vincent Petry <pvince81@owncloud.com> | ||
* | ||
* @copyright Copyright (c) 2016, ownCloud GmbH. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the .
lib/Dav/RootCollection.php
Outdated
*/ | ||
private $userSession; | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PHPDoc missing
lib/Dav/CustomGroupMemberNode.php
Outdated
/** | ||
* Update the admin flag | ||
* | ||
* @param int $isAdminPropValue 1 for true, 0 for false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return tag is missing
please have a look at the carddav query request - there is a node where you select the elements which you expect to be returned ... https://tools.ietf.org/html/rfc6352#section-8.6.3 <D:prop>
<D:getetag/>
<CG:display/>
</D:prop> |
1e16954
to
8ff08b9
Compare
Are you kidding me...
Will need to exclude the composer stuff from the code checker |
8ff08b9
to
628cf27
Compare
Squashed and removed the composer files I checked in by mistake from the other branch. |
ownCloud admins can now also manage groups even when they aren't members. Instead of passing around yet another object |
@DeepDiver1975 please re-review. My next step is to adjust the REPORT to implement pagination, but this could also be done separately if this PR is already mergable. |
I'm feeling a bit lazy with the REPORT + pagination especially if I need to do it for all the different endpoints. So I came up with this generic paginated report idea, please check it out: owncloud/core#26840 |
REPORT will be done in a separate PR. @DeepDiver1975 please review |
lib/Dav/CustomGroupsPlugin.php
Outdated
|
||
$this->server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc'; | ||
$ns = '{' . self::NS_OWNCLOUD . '}'; | ||
$this->server->resourceTypeMapping['OCA\\CustomGroups\\Dav\\MembershipNode'] = $ns . 'customgroups-membership'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tab?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and use ::class
public function createFile($userId, $data = null) { | ||
$groupId = $this->groupInfo['group_id']; | ||
if (!$this->helper->isUserAdmin($groupId)) { | ||
throw new Forbidden('No permission to add members to group "' . $groupId . '"'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd use string interpolation for better readability
throw new Forbidden("No permission to add members to group '$groupId'");
|
This is by design, same like the "users" list principal. You need to know the user name you want to query. |
Okay - in debug mode we allow listing of users in other collections as well |
Yet another code path to test / unit test and maintain. I'd rather not. Unless we make it more useful by enabling user listing for any admins Let me know what you think. |
Adjusted exception formatting. Added missing case: ownCloud admin can now enter the "users/$userId" subcollection even if not a member. @DeepDiver1975 I'd like to not add user listing here, it would require injecting the user manager, etc. I don't think it's useful enough, especially if only used in debug mode. |
628cf27
to
1f2b0e3
Compare
This PR is based on top of #1.
This adds DAV endpoints for #3