Skip to content

Commit

Permalink
fix(ocs): ignore resharing permissions when sharing
Browse files Browse the repository at this point in the history
Signed-off-by: jkoberg <[email protected]>
  • Loading branch information
kobergj committed Aug 22, 2024
1 parent 774910f commit a66ed3a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/ignore-resharing-requests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Ignore resharing requests

We now ignore resharing permissions. Instead of returning BadRequest we just reduce the permissions.

https://github.com/cs3org/reva/pull/4816
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,34 @@ func (h *Handler) CreateShare(w http.ResponseWriter, r *http.Request) {
reqRole, reqPermissions := r.FormValue("role"), r.FormValue("permissions")
switch shareType {
case int(conversions.ShareTypeUser), int(conversions.ShareTypeGroup):
// user collaborations default to Manager (=all permissions)
role, val, ocsErr := h.extractPermissions(reqRole, reqPermissions, statRes.Info, conversions.NewManagerRole())
// NOTE: clients tend to send "31" as permissions but they mean "15".
// This is because it adds the "16" for sharing , but that is now no longer allowed.
// We could now have some fancy mechanism that casts the string to an int, subtracts 16 and casts it back to a string.
// Or we could change the role later and hope everything works out.
// Or:
if reqRole == "" {
switch reqPermissions {
case "31":
reqPermissions = "15"
case "29":
reqPermissions = "13"
case "27":
reqPermissions = "11"
case "23":
reqPermissions = "7"
case "22":
reqPermissions = "6"
case "21":
reqPermissions = "5"
case "19":
reqPermissions = "3"
case "17":
reqPermissions = "1"
}
}

// user collaborations default to Viewer. Sane Default.
role, val, ocsErr := h.extractPermissions(reqRole, reqPermissions, statRes.Info, conversions.NewViewerRole())
if ocsErr != nil {
response.WriteOCSError(w, r, ocsErr.Code, ocsErr.Message, ocsErr.Error)
return
Expand Down

0 comments on commit a66ed3a

Please sign in to comment.