owncloud / ios-legacy

:iphone: iOS app for ownCloud
https://itunes.apple.com/app/owncloud/id543672169
GNU General Public License v3.0
624 stars 686 forks source link

Problem sharing a Shared Folder #704

Closed daorte closed 8 years ago

daorte commented 8 years ago

Hi! i found an unexpected behavior trying to create a share link from a shared folder

Steps to reproduce

  1. i have two users, userOne and userTwo
  2. userOne shares a folder with full permissions to userTwo
  3. userTwo tries to create a share link on a file of his shared folder using the iOS app
  4. the iOS app does nothing

    Expected behaviour

the iOS app should create the share link

Actual behaviour

the iOS app does nothing

Server configuration

Web server: Apache 2.4 Database: MySQL PHP version: 7 Client: User-Agent: Mozilla/5.0 (iOS) ownCloud-iOS/3.4.9 OwnCloud: 9.0.2.2 Device model: iPhone 6 Plus iOS 9.3.2

Some help

the app is validating if the user is the owner of the file, in the share API response XML, this <uid_file_owner>userOne</uid_file_owner> and this <displayname_file_owner>userOne</displayname_file_owner> tags refers to userOne. If i try to create a share in a NOT shared folder it works correctly

---edited by @nasli, added tasks:

TASKS

PR: #726 , https://github.com/owncloud/ios-library/pull/134

nasli commented 8 years ago

Hi @daorte, thanks for your feedback!! It seems a bug with that server version, if you enter through the website you can see that this file it is shared but it is not reflected in the iOS UI. Will fix it within next release.

nasli commented 8 years ago

cc @rullzer This is related to the response of share api, ex: user1 share /folder1shareTo2 that it is inside: /test/folder1shareTo2/ user2 receive /folder1shareto2/ and share a file inside: /folder1shareto2/file.txt to user3

the share api in user2 it is return:

<path>  /test/folder1shareTo2/file.txt (path of the owner)
<file_target> /file.txt (path of the destiny)

neither of them exists in user1, so for user1 is shown as no shared could we add the path for user1?

related https://github.com/owncloud/core/issues/25302

nasli commented 8 years ago

@rullzer , @PVince81 any input here?

davivel commented 8 years ago

Also failing in Android.

As user2, the call GET [server]:[share_path]/shares?path=/folder1shareto2/file.txt&reshares=false returns an empty list.

The same call with reshares=truereturn the expected share with user3.

This is not what we would expect from the Share API documentation: URL Arguments: reshares - (boolean) returns not only the shares from the current user but all shares from the given file.

From this I understand that the first call should return the share, that was created by user2. Is not user2 the owner of the share with user3, though it's resharing a file owned by user1?

PVince81 commented 8 years ago

The web UI of 9.0.2 also uses the OCS Share API for sharing and it works there to reshare a received folder with link share.

My steps:

  1. Login as admin
  2. Create two users "user1" and "user2"
  3. Login as "user1"
  4. Create a folder "test"
  5. Share "test" with "user2" with full permissions
  6. Login as "user2"
  7. Create a link share for the received folder "test" in the sharing panel

This is the POST request as observed in the network console (copy as curl, stripped down a bit):

curl 'http://localhost/owncloud/ocs/v2.php/apps/files_sharing/api/v1/shares?format=json' -H 'OCS-APIREQUEST: true' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' --data 'password=&passwordChanged=false&permissions=31&expireDate=&shareType=3&path=%2Ftest' --compressed

Then after refreshing the page, to display the status in the sidebar, it does this request: http://localhost/owncloud/ocs/v2.php/apps/files_sharing/api/v1/shares?format=json&path=%2Ftest&reshares=true and that one returns

It returns:

{
  "ocs": {
    "meta": {
      "status": "ok",
      "statuscode": 200,
      "message": null
    },
    "data": [
      {
        "id": 3,
        "share_type": 3,
        "uid_owner": "user2",
        "displayname_owner": "user2",
        "permissions": 1,
        "stime": 1467794355,
        "parent": null,
        "expiration": null,
        "token": "5xpjhpUZrUkrRf9",
        "uid_file_owner": "user1",
        "displayname_file_owner": "user1",
        "path": "\\/test",
        "item_type": "folder",
        "mimetype": "httpd\\/unix-directory",
        "storage_id": "home::user1",
        "storage": "3",
        "item_source": 19,
        "file_source": 19,
        "file_parent": 13,
        "file_target": "\\/test",
        "share_with": null,
        "share_with_displayname": null,
        "url": "http:\\/\\/localhost\\/owncloud\\/index.php\\/s\\/5xpjhpUZrUkrRf9",
        "mail_send": 0
      }
    ]
  }
}

Same result if I set "reshares=false".

Not sure who that "user3" is @davivel ? Mind describing the use case / sharing situation you tested with more details ? (ideally with steps to reproduce).

davivel commented 8 years ago

Something strange happened in my environment... after calling with reshares=true, reshares=false responds as expected. Now I'm not sure if I made a mistake in the test and all that I told before is useless.

I'll double check, sorry for the noise.

davivel commented 8 years ago

@PVince81, just to clarify: instead of creating a link share in the step 7, I shared with user3; problem in mobile is the same no matter if the last share is public or private.

PVince81 commented 8 years ago

Also another question is whether 8.2.6 behaves differently or this bug hasn't been discovered until now. If you think there is a problem with the API, please make a ticket in core with reproduction steps. (and ideally regression status) Thanks.

davivel commented 8 years ago

After more (and better) testing, I'd say this is fixed with 9.0.3, here: https://github.com/owncloud/core/pull/25067

@nasli, could you confirm for iOS?

nasli commented 8 years ago

@PVince81 to notice the error you must share a folder inside another one: ex: user1 share /folder1shareTo2 that it is inside: /test/folder1shareTo2/ user2 receives /folder1shareto2/ and share a file inside: /folder1shareto2/file.txt to user3 Because if share a root folder all works.

Tested over Works : 9.1.0.11, 9.0.3.2, 8.2.6.2, 8.2.4.2, Fails : 9.0.2.2, 9.0.1.3, 9.0.0.19 -->in the path return the path of user1

PVince81 commented 8 years ago

Ah, I see. Does it work with 9.0.3 ? (with https://github.com/owncloud/core/pull/25067)

nasli commented 8 years ago

Yes @PVince81, with this PR works!

nasli commented 8 years ago

For Android nothing more is needed, but for the iOS app we need to revert a fix made to use file_target instead path in these cases for latest server version.

@daorte, this will be fixed with the next release of iOS 3.5.0 that is expected in next weeks and also you need to update your server to 9.0.3.2

daorte commented 8 years ago

Tested with OwnCloud 9.1.0.15 and iOS Client 3.5.0 and it works now...

Thanks

nasli commented 8 years ago

Great! Thanks for your feedback! ;)