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

OCS Share API - "permissions" parameter has no effect #23146

Closed
kepon85 opened this issue Oct 2, 2020 · 9 comments
Closed

OCS Share API - "permissions" parameter has no effect #23146

kepon85 opened this issue Oct 2, 2020 · 9 comments
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug needs info

Comments

@kepon85
Copy link

kepon85 commented Oct 2, 2020

Hello,

Thank's for Nextcloud !

I am the documentation : https://docs.nextcloud.com/server/stable/developer_manual/client_apis/OCS/ocs-share-api.html#create-a-new-share

I'm looking to create the share of a write-enabled file with the OCS Share API

But the "permissions" parameter seems to have no effect ...

My code :

$cURLConnection = curl_init();
$params=array (
    'path' => './t1.md',
    'shareType' => 3,
    'permissions' => 19,
    'password' => ''
);
curl_setopt($cURLConnection, CURLOPT_URL, 'https://'.$username.':'.$password.'@'.$nextcloud_hostname.'/ocs/v2.php/apps/files_sharing/api/v1/shares?format=json');
curl_setopt($cURLConnection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cURLConnection, CURLOPT_HTTPHEADER, array(
    'OCS-APIRequest: true'
));
curl_setopt($cURLConnection, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($cURLConnection, CURLOPT_POSTFIELDS, $params);
$phoneList = curl_exec($cURLConnection);
curl_close($cURLConnection);
$jsonArrayResponse = json_decode($phoneList);
var_dump($jsonArrayResponse);

The var_dump say permissions = 17 :-/

object(stdClass)#4 (1) {
  ["ocs"]=>
  object(stdClass)#2 (2) {
    ["meta"]=>
    object(stdClass)#1 (3) {
      ["status"]=>
      string(2) "ok"
      ["statuscode"]=>
      int(200)
      ["message"]=>
      string(2) "OK"
    }
    ["data"]=>
    array(1) {
      [0]=>
      object(stdClass)#3 (31) {
        ["id"]=>
        string(2) "57"
        ["share_type"]=>
        int(3)
        ["uid_owner"]=>
        string(5) "david"
        ["displayname_owner"]=>
        string(5) "david"
        ["permissions"]=>
        int(17)
[...]
}

If I manually change the file permission in nextcloud (write permission), then I GET the share (https://docs.nextcloud.com/server/stable/developer_manual/client_apis/OCS/ocs-share- api.html # get-information-about-a-known-share) I get permissions = 19 :

object(stdClass)#4 (1) {
  ["ocs"]=>
  object(stdClass)#2 (2) {
    ["meta"]=>
    object(stdClass)#1 (3) {
      ["status"]=>
      string(2) "ok"
      ["statuscode"]=>
      int(200)
      ["message"]=>
      string(2) "OK"
    }
    ["data"]=>
    array(1) {
      [0]=>
      object(stdClass)#3 (31) {
        ["id"]=>
        string(2) "57"
        ["share_type"]=>
        int(3)
        ["uid_owner"]=>
        string(5) "david"
        ["displayname_owner"]=>
        string(5) "david"
        ["permissions"]=>
        int(19)

I tried with the value 1, 2, 10, 31 ... none seems to have an effect ... yet the rest of the arguments have an effect (password for example)

I guess it's a bug ...

Nextcloud 19.0.3 / Apache / PHP 7.3 / Mysql

@kepon85 kepon85 added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Oct 2, 2020
@vahem2lu
Copy link

vahem2lu commented Mar 9, 2021

I can add that some of check is done, because when entering arbitary number (permissons=100) i get error

<?xml version="1.0"?>
<ocs>
 <meta>
  <status>failure</status>
  <statuscode>404</statuscode>
  <message>invalid permissions</message>
 </meta>
 <data/>
</ocs>

Otherwise Share permission is always 1 (read only)

Same experience in Nextcloud 20.0.8RC1.

Have you tried 20.0.8 stable release, @kepon85 ?

@szaimen
Copy link
Contributor

szaimen commented Jun 25, 2021

Hi there, can you please post your question in https://help.nextcloud.com/c/dev/11 thats the better place for this.
Thanks!

@vahem2lu
Copy link

It's rather than a bug, no?

@aremesch
Copy link

aremesch commented Aug 2, 2021

Did you find any solution for this?

@aremesch
Copy link

aremesch commented Aug 2, 2021

If you do an unshare first and the share, the permissions will be set correctly. If you just re-share an existing share the permissions will stay as set the first time without returning an error. Observed in NC 21.0.2

@nachter
Copy link

nachter commented May 4, 2022

I had the same issue with different versions of nextcloud.

As a workaround, I'm creating the share and set the permissions with Update Share PUT command afterwards.
But you have to get the share_id from the output of the creation command

That works fine.
I hope this helps some of you!

@timowevel1
Copy link

Not solved yet, hello? Why closed?

@Tarun123-kittu
Copy link

but the ocs update api is also not working

@jplitza
Copy link
Contributor

jplitza commented Nov 16, 2022

FTR, there is a new version of this bug report: #32611

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug needs info
Projects
None yet
Development

No branches or pull requests

8 participants