Skip to content

Commit

Permalink
removed redundant roles
Browse files Browse the repository at this point in the history
  • Loading branch information
2403905 committed Oct 19, 2023
1 parent 085f5ee commit 442d315
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 59 deletions.
2 changes: 1 addition & 1 deletion changelog/unreleased/implement-sharing-roles.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ Enhancement: Implement sharing roles

Implement libre graph sharing roles

https://github.com/cs3org/reva/pull/4267
https://github.com/cs3org/reva/pull/4268
https://github.com/owncloud/ocis/issues/7418
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ require (
github.com/onsi/ginkgo v1.16.5
github.com/onsi/ginkgo/v2 v2.11.0
github.com/onsi/gomega v1.27.8
github.com/owncloud/libre-graph-api-go v1.0.5-0.20230512172639-d458ad6b300b
github.com/owncloud/libre-graph-api-go v1.0.5-0.20231019070917-17ae03ef40e4
github.com/owncloud/ocis/v2 v2.0.1-0.20230606150602-25d7dae4667b
github.com/pkg/errors v0.9.1
github.com/pkg/xattr v0.4.9
Expand Down Expand Up @@ -230,5 +230,3 @@ require (

// the replacement build is based on https://github.com/dragonchaser/cs3apis/tree/master
replace github.com/cs3org/go-cs3apis => github.com/aduffeck/go-cs3apis v0.0.0-20231009082215-ad45e19edac0

replace github.com/owncloud/libre-graph-api-go => github.com/owncloud/libre-graph-api-go v1.0.5-0.20231013101137-2757d88d116d
5 changes: 2 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1058,8 +1058,8 @@ github.com/onsi/gomega v1.27.8 h1:gegWiwZjBsf2DgiSbf5hpokZ98JVDMcWkUiigk6/KXc=
github.com/onsi/gomega v1.27.8/go.mod h1:2J8vzI/s+2shY9XHRApDkdgPo1TKT7P2u6fXeJKFnNQ=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
github.com/owncloud/libre-graph-api-go v1.0.5-0.20231013101137-2757d88d116d h1:CDmOfOkS0Yu0O+EAmshJzm6LWnV4pxQAkguykuB9I7o=
github.com/owncloud/libre-graph-api-go v1.0.5-0.20231013101137-2757d88d116d/go.mod h1:iKdVH6nYpI8RBeK9sjeLfzrPByST6r9d+NG2IJHoJmU=
github.com/owncloud/libre-graph-api-go v1.0.5-0.20231019070917-17ae03ef40e4 h1:W2X4DGGEuNUeGCKOUK8c2NAC4kva8jq9knuv5ePLUiE=
github.com/owncloud/libre-graph-api-go v1.0.5-0.20231019070917-17ae03ef40e4/go.mod h1:v2aAl5IwEI8t+GmcWvBd+bvJMYp9Vf1hekLuRf0UnEs=
github.com/owncloud/ocis/v2 v2.0.1-0.20230606150602-25d7dae4667b h1:Aiou+DcU5B10HSCIumhg9X+2Qaljt6Qc+aIEfM5VsCc=
github.com/owncloud/ocis/v2 v2.0.1-0.20230606150602-25d7dae4667b/go.mod h1:B+5L2ssUvYoy1yDi2PM7/qRAtsHcJ6SGGqC5SvmljjY=
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw=
Expand Down Expand Up @@ -1426,7 +1426,6 @@ golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20210323180902-22b0adad7558/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
Expand Down
57 changes: 5 additions & 52 deletions pkg/conversions/unifiedrole.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,44 +23,14 @@ const (
// UnifiedRoleManagerID Unified role manager id.
UnifiedRoleManagerID = "312c0871-5ef7-4b3a-85b6-0e4074c64049"

// UnifiedRoleUnknownID Unified role unknown id.
UnifiedRoleUnknownID = "d76b1f66-8cd6-4ac1-9769-468cfcb6c683"
// UnifiedRoleLegacyID Unified role legacy id.
UnifiedRoleLegacyID = "9486869a-bfa0-415e-81c4-c15e41b7cb2a"
// UnifiedRoleDeniedID Unified role denied id
UnifiedRoleDeniedID = "91a93759-19a7-41c0-adba-a2f343178b75"

// UnifiedRoleNoneID Unified role none id
UnifiedRoleNoneID = "312c0871-5ef7-4b3a-85b6-0e4074c64049"

// UnifiedRoleConditionSelf TODO defines constraints when the principal is the owner of the target resource
// UnifiedRoleConditionSelf TODO defines constraints
UnifiedRoleConditionSelf = "Self: @Subject.objectId == @Resource.objectId"
// UnifiedRoleConditionOwner TODO defines constraints when the principal is the owner of the target resource
// UnifiedRoleConditionOwner defines constraints when the principal is the owner of the target resource
UnifiedRoleConditionOwner = "Owner: @Subject.objectId Any_of @Resource.owners"
// UnifiedRoleConditionGrantee TODO does not exist in MS Graph, but we use it to express permissions on shared resources
// UnifiedRoleConditionGrantee does not exist in MS Graph, but we use it to express permissions on shared resources
UnifiedRoleConditionGrantee = "Grantee: @Subject.objectId Any_of @Resource.grantee"
)

// NewUnknownUnifiedRole creates an unknown role. An Unknown role has no permissions over a cs3 resource nor any ocs endpoint.
func NewUnknownUnifiedRole() *libregraph.UnifiedRoleDefinition {
return &libregraph.UnifiedRoleDefinition{
Id: proto.String(UnifiedRoleUnknownID),
Description: proto.String("An Unknown role has no permissions over a cs3 resource nor any ocs endpoint"),
DisplayName: displayName(NewUnknownRole()),
LibreGraphWeight: proto.Int32(0),
}
}

// NewDeniedUnifiedRole creates a fully denied role
func NewDeniedUnifiedRole() *libregraph.UnifiedRoleDefinition {
return &libregraph.UnifiedRoleDefinition{
Id: proto.String(UnifiedRoleDeniedID),
Description: proto.String("A fully denied role"),
DisplayName: displayName(NewDeniedRole()),
LibreGraphWeight: proto.Int32(0),
}
}

// NewViewerUnifiedRole creates a viewer role. `sharing` indicates if sharing permission should be added
func NewViewerUnifiedRole(sharing bool) *libregraph.UnifiedRoleDefinition {
r := NewViewerRole(sharing)
Expand Down Expand Up @@ -151,7 +121,7 @@ func NewCoownerUnifiedRole() *libregraph.UnifiedRoleDefinition {
r := NewCoownerRole()
return &libregraph.UnifiedRoleDefinition{
Id: proto.String(UnifiedRoleCoownerID),
Description: proto.String(""), // TODO add the description
Description: proto.String("Grants co-owner permissions on a resource"),
DisplayName: displayName(r),
RolePermissions: []libregraph.UnifiedRolePermission{
{
Expand Down Expand Up @@ -180,23 +150,12 @@ func NewUploaderUnifiedRole() *libregraph.UnifiedRoleDefinition {
}
}

// NewNoneUnifiedRole creates a role with no permissions
// TODO Do we need to map it?
func NewNoneUnifiedRole() *libregraph.UnifiedRoleDefinition {
return &libregraph.UnifiedRoleDefinition{
Id: proto.String(UnifiedRoleNoneID),
Description: proto.String("A role with no permissions"),
DisplayName: displayName(NewNoneRole()),
LibreGraphWeight: proto.Int32(0),
}
}

// NewManagerUnifiedRole creates a manager role
func NewManagerUnifiedRole() *libregraph.UnifiedRoleDefinition {
r := NewManagerRole()
return &libregraph.UnifiedRoleDefinition{
Id: proto.String(UnifiedRoleManagerID),
Description: proto.String(""), // TODO add the description
Description: proto.String("Grants manager permissions on a resource. Semantically equivalent to co-owner"),
DisplayName: displayName(r),
RolePermissions: []libregraph.UnifiedRolePermission{
{
Expand Down Expand Up @@ -230,12 +189,6 @@ func displayName(role *Role) *string {
displayName = "Uploader"
case RoleManager:
displayName = "Manager"
case RoleUnknown:
displayName = "Unknown"
case RoleLegacy:
displayName = "Legacy"
case RoleDenied:
displayName = "Denied"
default:
return nil
}
Expand Down

0 comments on commit 442d315

Please sign in to comment.