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

Roles API + allow setting permissions via share attribues #36024

Merged
merged 2 commits into from
Aug 22, 2019

Conversation

DeepDiver1975
Copy link
Member

@DeepDiver1975 DeepDiver1975 commented Aug 13, 2019

Description

The roles api allows clients to ask the server for supported roles.
Currently only roles for public links are implemented.
Apps can listen to the event dispatcher and add their own roles.

The current concept does not reflect any capability for apps to change roles (core or from other apps)

Here is an example on how to submit permissions via the attributes property
Screenshot from 2019-08-21 10-20-44

Related Issue

How Has This Been Tested?

  • 🤷‍♂️

Screenshots (if appropriate):

curl http://deepdiver:8080/ocs/v1.php/cloud/roles?format=json  -u admin -H 'Accept-Language: de-DE' | json_pp 
Enter host password for user 'admin':
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1301  100  1301    0     0   1848      0 --:--:-- --:--:-- --:--:--  1845
{
   "ocs" : {
      "data" : [
         {
            "id" : "core.viewer",
            "context" : {
               "publicLinks" : {
                  "order" : 10,
                  "permissions" : {
                     "ownCloud" : {
                        "read" : true
                     }
                  },
                  "displayDescription" : "Empfänger können Inhalte sehen und herunterladen.",
                  "resourceTypes" : [
                     "*"
                  ]
               }
            },
            "displayName" : "Herunterladen / Ansehen"
         },
         {
            "displayName" : "Herunterladen / Ansehen / Bearbeiten",
            "context" : {
               "publicLinks" : {
                  "displayDescription" : "Empfänger können Inhalte sehen, herunterladen und bearbeiten.",
                  "resourceTypes" : [
                     "httpd/unix-directory"
                  ],
                  "order" : 20,
                  "permissions" : {
                     "ownCloud" : {
                        "update" : true,
                        "delete" : true,
                        "read" : true,
                        "create" : true
                     }
                  }
               }
            },
            "id" : "core.editor"
         },
         {
            "context" : {
               "publicLinks" : {
                  "order" : 30,
                  "permissions" : {
                     "ownCloud" : {
                        "read" : true,
                        "create" : true
                     }
                  },
                  "displayDescription" : "Empfänger können Inhalte sehen, herunterladen und hochladen.",
                  "resourceTypes" : [
                     "httpd/unix-directory"
                  ]
               }
            },
            "id" : "core.contributor",
            "displayName" : "Herunterladen / Ansehen / Hochladen"
         },
         {
            "displayName" : "Nur Hochladen (File Drop)",
            "context" : {
               "publicLinks" : {
                  "order" : 40,
                  "permissions" : {
                     "ownCloud" : {
                        "create" : true
                     }
                  },
                  "displayDescription" : "Von mehreren Empfängern Dateien empfangen, ohne den Inhalt des Ordners preiszugeben.",
                  "resourceTypes" : [
                     "httpd/unix-directory"
                  ]
               }
            },
            "id" : "core.uploader"
         }
      ],
      "meta" : {
         "status" : "ok",
         "message" : "OK",
         "statuscode" : 100,
         "totalitems" : "",
         "itemsperpage" : ""
      }
   }
}

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Database schema changes (next release will require increase of minor version instead of patch)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

Open tasks:

  • Backport (if applicable set "backport-request" label and remove when the backport was done)

@codecov
Copy link

codecov bot commented Aug 13, 2019

Codecov Report

Merging #36024 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #36024   +/-   ##
=======================================
  Coverage   53.85%   53.85%           
=======================================
  Files          63       63           
  Lines        7377     7377           
  Branches     1301     1301           
=======================================
  Hits         3973     3973           
  Misses       3019     3019           
  Partials      385      385
Flag Coverage Δ
#javascript 53.85% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9898824...e0c449b. Read the comment docs.

@codecov
Copy link

codecov bot commented Aug 13, 2019

Codecov Report

Merging #36024 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #36024   +/-   ##
=======================================
  Coverage   53.85%   53.85%           
=======================================
  Files          63       63           
  Lines        7377     7377           
  Branches     1301     1301           
=======================================
  Hits         3973     3973           
  Misses       3019     3019           
  Partials      385      385
Flag Coverage Δ
#javascript 53.85% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a8d711e...2ef190a. Read the comment docs.

@DeepDiver1975 DeepDiver1975 force-pushed the feature/poc-roles-api branch 2 times, most recently from fdc1924 to d600986 Compare August 19, 2019 10:10
@DeepDiver1975 DeepDiver1975 changed the title [POC] roles api Roles API + allow setting permissions via share attribues Aug 19, 2019
@DeepDiver1975 DeepDiver1975 marked this pull request as ready for review August 19, 2019 13:14
@michaelstingl
Copy link

@felix-schwarz @hosy @TheOneRing Could you have a look?

@felix-schwarz
Copy link

The JSON and Accept-Language-support checks all the boxes from https://github.com/owncloud/enterprise/issues/2742 that are needed by the iOS client. Looks good to me. 👍

Copy link
Contributor

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

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

See minor comments.

I'm missing unit tests for RolesController, at least to check that a few of the roles are returned (does not need to be 100% match).
Also need to test that the AddRoleEvent contents will actually appear in the roles API result.

}

$pathinfo = \pathinfo($pathAttempt);
$ext = (isset($pathinfo['extension'])) ? '.'.$pathinfo['extension'] : '';
$ext = isset($pathinfo['extension']) ? '.'.$pathinfo['extension'] : '';
Copy link
Contributor

Choose a reason for hiding this comment

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

seems the automatic formatter did not decide to add spaces between the "." for concatenation (wenn schon denn schon!)

same for some other reformatting below

core/Controller/RolesController.php Show resolved Hide resolved
Copy link
Contributor

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

@PVince81 PVince81 merged commit ad5d78b into master Aug 22, 2019
@delete-merged-branch delete-merged-branch bot deleted the feature/poc-roles-api branch August 22, 2019 07:38
@settermjd
Copy link
Contributor

@DeepDiver1975, do you have a code example of how apps can listen to the event dispatcher and add their own roles?

@DeepDiver1975
Copy link
Member Author

@DeepDiver1975, do you have a code example of how apps can listen to the event dispatcher and add their own roles?

No app is currently using this - I suggest to leave this undocumented for the time being.
We will extend this - and then really need this - as soon as we are implementing the roles api for collaboration.

I'll let you know as soon as we are at this point. THX

@settermjd
Copy link
Contributor

Thanks for the clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants