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

Add EditorListGrantsWithVersions and FileEditorListGrantsWithVersions roles. #5063

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
25 changes: 25 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 Expand Up @@ -595,6 +617,9 @@ func RoleFromResourcePermissions(rp *provider.ResourcePermissions, islink bool)
if rp.ListGrants {
r.Name = RoleEditorListGrants
}
if rp.RemoveGrant && rp.ListFileVersions {
r.Name = RoleEditorListGrantsWithVersions
}
if rp.RemoveGrant {
r.Name = RoleManager
}
Expand Down
Loading