Skip to content

Commit

Permalink
feat: Add roles EditorListGrantsWithVersions, FileEditorListGrantsWit…
Browse files Browse the repository at this point in the history
…hVersions
  • Loading branch information
bastianbeier committed Feb 3, 2025
1 parent 7db0c82 commit 4702e79
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/add-roles-with-versions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: Add roles

Add EditorListGrantsWithVersions and FileEditorListGrantsWithVersions roles.

https://github.com/cs3org/reva/pull/5063
https://github.com/owncloud/ocis/issues/10747
22 changes: 22 additions & 0 deletions pkg/conversions/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const (
RoleEditor = "editor"
// RoleEditorListGrants grants editor permission on a resource, including folders.
RoleEditorListGrants = "editor-list-grants"
// RoleEditorListGrantsWithVersions grants editor permission on a resource, including folders.
RoleEditorListGrantsWithVersions = "editor-list-grants-with-versions"
// RoleSpaceEditor grants editor permission on a space.
RoleSpaceEditor = "spaceeditor"
// RoleSpaceEditorWithoutVersions grants editor permission without list/restore versions on a space.
Expand All @@ -53,6 +55,8 @@ const (
RoleFileEditor = "file-editor"
// RoleFileEditorListGrants grants editor permission on a single file.
RoleFileEditorListGrants = "file-editor-list-grants"
// RoleFileEditorListGrantsWithVersions grants editor permission on a single file.
RoleFileEditorListGrantsWithVersions = "file-editor-list-grants-with-versions"
// RoleCoowner grants co-owner permissions on a resource.
RoleCoowner = "coowner"
// RoleEditorLite grants permission to upload and download to a resource.
Expand Down Expand Up @@ -171,12 +175,16 @@ func RoleFromName(name string) *Role {
return NewEditorRole()
case RoleEditorListGrants:
return NewEditorListGrantsRole()
case RoleEditorListGrantsWithVersions:
return NewEditorListGrantsWithVersionsRole()
case RoleSpaceEditor:
return NewSpaceEditorRole()
case RoleFileEditor:
return NewFileEditorRole()
case RoleFileEditorListGrants:
return NewFileEditorListGrantsRole()
case RoleFileEditorListGrantsWithVersions:
return NewFileEditorListGrantsWithVersionsRole()
case RoleUploader:
return NewUploaderRole()
case RoleManager:
Expand Down Expand Up @@ -276,6 +284,13 @@ func NewEditorListGrantsRole() *Role {
return role
}

// NewEditorListGrantsWithVersionsRole creates an editor role. `sharing` indicates if sharing permission should be added
func NewEditorListGrantsWithVersionsRole() *Role {
role := NewEditorListGrantsRole()
role.cS3ResourcePermissions.ListFileVersions = true
return role
}

// NewSpaceEditorRole creates an editor role
func NewSpaceEditorRole() *Role {
return &Role{
Expand Down Expand Up @@ -348,6 +363,13 @@ func NewFileEditorListGrantsRole() *Role {
return role
}

// NewFileEditorListGrantsWithVersionsRole creates a file-editor role
func NewFileEditorListGrantsWithVersionsRole() *Role {
role := NewFileEditorListGrantsRole()
role.cS3ResourcePermissions.ListFileVersions = true
return role
}

// NewCoownerRole creates a coowner role.
func NewCoownerRole() *Role {
return &Role{
Expand Down

0 comments on commit 4702e79

Please sign in to comment.