Compare commits

...
Author SHA1 Message Date
Roman Perekhod 0151111d59 fix persanal space creating 2026-03-05 14:47:39 +01:00
Roman Perekhod b44091a077 fix responce 2026-03-04 16:20:07 +01:00
Roman Perekhod ad5268dd6f added protected-personal autoprovision
added MFA enforcement for the ocdav and arciver
2026-03-04 16:20:07 +01:00
Roman Perekhod 34f38b8f66 added protected-* spaces get and create 2026-03-04 16:20:07 +01:00
Roman Perekhod 21310ea0e8 refactor the validation 2026-03-04 16:20:07 +01:00
22 changed files with 480 additions and 156 deletions

No files matched your search

+1
View File
@@ -64,3 +64,4 @@ go.work.sum
.envrc
CLAUDE.md
.claude/
.agents/
+1 -1
View File
@@ -64,7 +64,7 @@ require (
github.com/open-policy-agent/opa v1.12.3
github.com/orcaman/concurrent-map v1.0.0
github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245
github.com/owncloud/reva/v2 v2.0.0-20260223124048-61ee39d95d5f
github.com/owncloud/reva/v2 v2.0.0-20260303153746-059bcdfc4fbb
github.com/pkg/errors v0.9.1
github.com/pkg/xattr v0.4.12
github.com/prometheus/client_golang v1.23.2
+2 -2
View File
@@ -742,8 +742,8 @@ github.com/orcaman/concurrent-map v1.0.0 h1:I/2A2XPCb4IuQWcQhBhSwGfiuybl/J0ev9HD
github.com/orcaman/concurrent-map v1.0.0/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI=
github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245 h1:JRidLTAKhnvyLMRtVtSF4lhBa0NSAOs6fof+d6JnKII=
github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245/go.mod h1:z61VMGAJRtR1nbgXWiNoCkxUXP1B3Je9rMuJbnGd+Og=
github.com/owncloud/reva/v2 v2.0.0-20260223124048-61ee39d95d5f h1:M935ztFcjtRbP3ns8Fgb2XL5jalNd3sXYMUXf0kAwTQ=
github.com/owncloud/reva/v2 v2.0.0-20260223124048-61ee39d95d5f/go.mod h1:+rCy6oGYb2/qs5gmQa8y/pHARw634vB73MZGDY2SBIQ=
github.com/owncloud/reva/v2 v2.0.0-20260303153746-059bcdfc4fbb h1:+g9i1ZCb5EAufhjX967R2Zkw3UtgKk6XfXNQ4LQg9iE=
github.com/owncloud/reva/v2 v2.0.0-20260303153746-059bcdfc4fbb/go.mod h1:+rCy6oGYb2/qs5gmQa8y/pHARw634vB73MZGDY2SBIQ=
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw=
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0=
github.com/pablodz/inotifywaitgo v0.0.9 h1:njquRbBU7fuwIe5rEvtaniVBjwWzcpdUVptSgzFqZsw=
@@ -160,6 +160,14 @@ func spacesProviders(cfg *config.Config, logger log.Logger) map[string]map[strin
"mount_point": "/projects",
"path_template": "/projects/{{.Space.Name}}",
},
"protected-personal": map[string]interface{}{
"mount_point": "/protected-users",
"path_template": "/protected-users/{{.Space.Name}}",
},
"protected-project": map[string]interface{}{
"mount_point": "/protected-projects",
"path_template": "/protected-projects/{{.Space.Name}}",
},
},
},
cfg.StorageSharesEndpoint: {
+45 -22
View File
@@ -37,11 +37,13 @@ import (
)
const (
_spaceTypePersonal = "personal"
_spaceTypeProject = "project"
_spaceTypeVirtual = "virtual"
_spaceTypeMountpoint = "mountpoint"
_spaceStateTrashed = "trashed"
_spaceTypePersonal = "personal"
_spaceTypeProject = "project"
_spaceTypeProtectedPersonal = "protected-personal"
_spaceTypeProtectedProject = "protected-project"
_spaceTypeVirtual = "virtual"
_spaceTypeMountpoint = "mountpoint"
_spaceStateTrashed = "trashed"
_sortDescending = "desc"
)
@@ -78,7 +80,7 @@ func (g Graph) GetDrives(version APIVersion) http.HandlerFunc {
// GetDrivesV1 attempts to retrieve the current users drives;
// it lists all drives the current user has access to.
func (g Graph) GetDrivesV1(w http.ResponseWriter, r *http.Request) {
spaces, errCode := g.getDrives(r, false, APIVersion_1)
spaces, errCode := g.getDrives(w, r, false, APIVersion_1)
if errCode != nil {
errorcode.RenderError(w, r, errCode)
return
@@ -99,7 +101,7 @@ func (g Graph) GetDrivesV1(w http.ResponseWriter, r *http.Request) {
// it includes the grantedtoV2 property
// it uses unified roles instead of the cs3 representations
func (g Graph) GetDrivesV1Beta1(w http.ResponseWriter, r *http.Request) {
spaces, errCode := g.getDrives(r, false, APIVersion_1_Beta_1)
spaces, errCode := g.getDrives(w, r, false, APIVersion_1_Beta_1)
if errCode != nil {
errorcode.RenderError(w, r, errCode)
return
@@ -133,14 +135,11 @@ func (g Graph) GetAllDrives(version APIVersion) http.HandlerFunc {
// GetAllDrivesV1 attempts to retrieve the current users drives;
// it includes another user's drives, if the current user has the permission.
func (g Graph) GetAllDrivesV1(w http.ResponseWriter, r *http.Request) {
if !mfa.Has(r.Context()) {
logger := g.logger.SubloggerWithRequestID(r.Context())
logger.Error().Str("path", r.URL.Path).Msg("MFA required but not satisfied")
mfa.SetRequiredStatus(w)
if !g.validateMFA(r, w) {
return
}
spaces, errCode := g.getDrives(r, true, APIVersion_1)
spaces, errCode := g.getDrives(w, r, true, APIVersion_1)
if errCode != nil {
errorcode.RenderError(w, r, errCode)
return
@@ -160,14 +159,11 @@ func (g Graph) GetAllDrivesV1(w http.ResponseWriter, r *http.Request) {
// it includes the grantedtoV2 property
// it uses unified roles instead of the cs3 representations
func (g Graph) GetAllDrivesV1Beta1(w http.ResponseWriter, r *http.Request) {
if !mfa.Has(r.Context()) {
logger := g.logger.SubloggerWithRequestID(r.Context())
logger.Error().Str("path", r.URL.Path).Msg("MFA required but not satisfied")
mfa.SetRequiredStatus(w)
if !g.validateMFA(r, w) {
return
}
drives, errCode := g.getDrives(r, true, APIVersion_1_Beta_1)
drives, errCode := g.getDrives(w, r, true, APIVersion_1_Beta_1)
if errCode != nil {
errorcode.RenderError(w, r, errCode)
return
@@ -184,7 +180,7 @@ func (g Graph) GetAllDrivesV1Beta1(w http.ResponseWriter, r *http.Request) {
}
// getDrives implements the Service interface.
func (g Graph) getDrives(r *http.Request, unrestricted bool, apiVersion APIVersion) ([]*libregraph.Drive, error) {
func (g Graph) getDrives(w http.ResponseWriter, r *http.Request, unrestricted bool, apiVersion APIVersion) ([]*libregraph.Drive, error) {
logger := g.logger.SubloggerWithRequestID(r.Context())
logger.Info().
Interface("query", r.URL.Query()).
@@ -197,6 +193,10 @@ func (g Graph) getDrives(r *http.Request, unrestricted bool, apiVersion APIVersi
logger.Debug().Err(err).Interface("query", r.URL.Query()).Msg("could not get drives: query error")
return nil, errorcode.New(errorcode.InvalidRequest, err.Error())
}
if !g.validateQueryMFA(r, w, odataReq.Query, DriveTypeValidator{}) {
return nil, errorcode.New(errorcode.AccessDenied, "")
}
ctx := r.Context()
filters, err := generateCs3Filters(odataReq)
@@ -409,6 +409,8 @@ func (g Graph) createDrive(w http.ResponseWriter, r *http.Request, apiVersion AP
switch driveType {
case "", _spaceTypeProject:
driveType = _spaceTypeProject
case _spaceTypeProtectedProject:
driveType = _spaceTypeProtectedProject
default:
logger.Debug().Str("type", driveType).Msg("could not create drive: drives of this type cannot be created via this api")
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, "drives of this type cannot be created via this api")
@@ -468,7 +470,7 @@ func (g Graph) createDrive(w http.ResponseWriter, r *http.Request, apiVersion AP
}
space := resp.GetStorageSpace()
if t := r.URL.Query().Get(TemplateParameter); t != "" && driveType == _spaceTypeProject {
if t := r.URL.Query().Get(TemplateParameter); t != "" && (driveType == _spaceTypeProject || driveType == _spaceTypeProtectedProject) {
loc := l10n.MustGetUserLocale(ctx, us.GetId().GetOpaqueId(), r.Header.Get(HeaderAcceptLanguage), g.valueService)
if err := g.applySpaceTemplate(ctx, gatewayClient, space.GetRoot(), t, loc); err != nil {
logger.Error().Err(err).Msg("could not apply template to space")
@@ -596,7 +598,7 @@ func (g Graph) updateDrive(w http.ResponseWriter, r *http.Request, apiVersion AP
for _, sp := range res.StorageSpaces {
id, _ := storagespace.ParseID(sp.GetId().GetOpaqueId())
if id.GetSpaceId() == rid.GetSpaceId() {
dt = _spaceTypeProject
dt = sp.SpaceType
}
}
}
@@ -781,7 +783,25 @@ func (g Graph) ListStorageSpacesWithFilters(ctx context.Context, filters []*stor
return nil, err
}
res, err := gatewayClient.ListStorageSpaces(ctx, lReq)
return res, err
if err != nil {
return nil, err
}
if res.GetStatus().GetCode() != cs3rpc.Code_CODE_OK {
return res, nil
}
// Filter out protected spaces if MFA is not enabled
if !mfa.Has(ctx) {
var filtered []*storageprovider.StorageSpace
for _, s := range res.StorageSpaces {
if s.SpaceType != _spaceTypeProtectedPersonal && s.SpaceType != _spaceTypeProtectedProject {
filtered = append(filtered, s)
}
}
res.StorageSpaces = filtered
}
return res, nil
}
func (g Graph) cs3StorageSpaceToDrive(ctx context.Context, baseURL *url.URL, space *storageprovider.StorageSpace, apiVersion APIVersion) (*libregraph.Drive, error) {
@@ -1016,9 +1036,12 @@ func getQuota(quota *libregraph.Quota, defaultQuota string) *storageprovider.Quo
func (g Graph) canSetSpaceQuota(ctx context.Context, _ *userv1beta1.User, typ string) (bool, error) {
permID := settingsServiceExt.SetPersonalSpaceQuotaPermission(0).Id
if typ == _spaceTypeProject {
if typ == _spaceTypeProject || typ == _spaceTypeProtectedProject {
permID = settingsServiceExt.SetProjectSpaceQuotaPermission(0).Id
}
if typ == _spaceTypeProtectedPersonal {
permID = settingsServiceExt.SetPersonalSpaceQuotaPermission(0).Id
}
_, err := g.permissionsService.GetPermissionByID(ctx, &settingssvc.GetPermissionByIDRequest{PermissionId: permID})
if err != nil {
merror := merrors.FromError(err)
+111 -13
View File
@@ -21,6 +21,7 @@ import (
"github.com/owncloud/reva/v2/pkg/storagespace"
"github.com/owncloud/ocis/v2/ocis-pkg/keycloak"
"github.com/owncloud/ocis/v2/ocis-pkg/mfa"
ehsvc "github.com/owncloud/ocis/v2/protogen/gen/ocis/services/eventhistory/v0"
searchsvc "github.com/owncloud/ocis/v2/protogen/gen/ocis/services/search/v0"
settingssvc "github.com/owncloud/ocis/v2/protogen/gen/ocis/services/settings/v0"
@@ -154,38 +155,135 @@ func parseIDParam(r *http.Request, param string) (storageprovider.ResourceId, er
return id, nil
}
// regular users can only search for terms with a minimum length
func hasAcceptableSearch(query *godata.GoDataQuery, minSearchLength int) bool {
// QueryValidator defines a strategy for validating godata queries.
type QueryValidator interface {
Validate(query *godata.GoDataQuery) error
}
// SearchValidator validates the search query.
type SearchValidator struct {
MinLength int
}
// Validate checks if the search term is acceptable.
func (v SearchValidator) Validate(query *godata.GoDataQuery) error {
if query == nil || query.Search == nil {
return false
return errors.New("search term too short")
}
minSearchLength := v.MinLength
if strings.HasPrefix(query.Search.RawValue, "\"") {
// if search starts with double quotes then it must finish with double quotes
// add +2 to the minimum search length in this case
minSearchLength += 2
}
return len(query.Search.RawValue) >= minSearchLength
if len(query.Search.RawValue) < minSearchLength {
return errors.New("search term too short")
}
return nil
}
// regular users can only filter by userType
func hasAcceptableFilter(query *godata.GoDataQuery) bool {
// FilterValidator validates the filter query.
type FilterValidator struct{}
// Validate checks if the filter applies forbidden elements.
func (v FilterValidator) Validate(query *godata.GoDataQuery) error {
switch {
case query == nil || query.Filter == nil:
return true
return nil
case query.Filter.Tree.Token.Type != godata.ExpressionTokenLogical:
return false
return errors.New("filter has forbidden elements for regular users")
case query.Filter.Tree.Token.Value != "eq":
return false
return errors.New("filter has forbidden elements for regular users")
case query.Filter.Tree.Children[0].Token.Value != "userType":
return false
return errors.New("filter has forbidden elements for regular users")
}
return nil
}
// BasicQueryValidator validates basic queries.
type BasicQueryValidator struct{}
// Validate checks if the query contains unsupported operations like apply, expand, or compute.
func (v BasicQueryValidator) Validate(query *godata.GoDataQuery) error {
if query != nil && (query.Apply != nil || query.Expand != nil || query.Compute != nil) {
return errors.New("query has forbidden elements for regular users")
}
return nil
}
// DriveTypeValidator validates if the driveType filter contains protected types.
type DriveTypeValidator struct{}
// Validate checks if the driveType filter contains protected types.
func (v DriveTypeValidator) Validate(query *godata.GoDataQuery) error {
if query == nil || query.Filter == nil {
return nil
}
if query.Filter.Tree.Token.Value == "eq" && query.Filter.Tree.Children[0].Token.Value == "driveType" {
driveType := strings.Trim(query.Filter.Tree.Children[1].Token.Value, "'")
if driveType == _spaceTypeProtectedProject || driveType == _spaceTypeProtectedPersonal {
return errors.New("mfa required for protected spaces")
}
}
return nil
}
// validateQuery validates the godata query based on provided validators.
// It handles user permissions and MFA requirements centrally.
func (g Graph) validateQuery(r *http.Request, w http.ResponseWriter, query *godata.GoDataQuery, validators ...QueryValidator) bool {
ctxHasFullPerms := g.contextUserHasFullAccountPerms(r.Context())
hasMFA := mfa.Has(r.Context())
logger := g.logger.SubloggerWithRequestID(r.Context())
for _, v := range validators {
if err := v.Validate(query); err != nil {
if !ctxHasFullPerms {
logger.Debug().Interface("query", r.URL.Query()).Msg(err.Error())
errorcode.AccessDenied.Render(w, r, http.StatusForbidden, err.Error())
return false
}
if !hasMFA {
logger.Error().Str("path", r.URL.Path).Msg("MFA required but not satisfied")
mfa.SetRequiredStatus(w)
return false
}
}
}
return true
}
// regular users can only use basic queries without any expansions, computes or applies
func hasAcceptableQuery(query *godata.GoDataQuery) bool {
return query != nil && query.Apply == nil && query.Expand == nil && query.Compute == nil
// validateQueryMFA validates the godata query based on provided validators.
// It only handles MFA requirements and does not check for user permissions.
func (g Graph) validateQueryMFA(r *http.Request, w http.ResponseWriter, query *godata.GoDataQuery, validators ...QueryValidator) bool {
hasMFA := mfa.Has(r.Context())
logger := g.logger.SubloggerWithRequestID(r.Context())
for _, v := range validators {
if err := v.Validate(query); err != nil {
if !hasMFA {
logger.Error().Str("path", r.URL.Path).Msg("MFA required but not satisfied")
mfa.SetRequiredStatus(w)
return false
}
}
}
return true
}
// validateMFA validates the MFA requirement.
func (g Graph) validateMFA(r *http.Request, w http.ResponseWriter) bool {
hasMFA := mfa.Has(r.Context())
logger := g.logger.SubloggerWithRequestID(r.Context())
if !hasMFA {
logger.Error().Str("path", r.URL.Path).Msg("MFA required but not satisfied")
mfa.SetRequiredStatus(w)
return false
}
return true
}
+104
View File
@@ -192,6 +192,63 @@ var _ = Describe("Graph", func() {
}
`))
})
It("filters out protected spaces when not having mfa", func() {
gatewayClient.On("ListStorageSpaces", mock.Anything, mock.Anything).Times(1).Return(&provider.ListStorageSpacesResponse{
Status: status.NewOK(ctx),
StorageSpaces: []*provider.StorageSpace{
{
Id: &provider.StorageSpaceId{OpaqueId: "p-personal"},
SpaceType: "protected-personal",
Root: &provider.ResourceId{
StorageId: "pro-1",
SpaceId: "p-personal",
OpaqueId: "p-personal",
},
Name: "Protected Personal",
},
{
Id: &provider.StorageSpaceId{OpaqueId: "p-project"},
SpaceType: "protected-project",
Root: &provider.ResourceId{
StorageId: "pro-1",
SpaceId: "p-project",
OpaqueId: "p-project",
},
Name: "Protected Project",
},
{
Id: &provider.StorageSpaceId{OpaqueId: "normal"},
SpaceType: "personal",
Root: &provider.ResourceId{
StorageId: "pro-1",
SpaceId: "normal",
OpaqueId: "normal",
},
Name: "Normal Personal",
},
},
}, nil)
gatewayClient.On("InitiateFileDownload", mock.Anything, mock.Anything).Return(&gateway.InitiateFileDownloadResponse{
Status: status.NewNotFound(ctx, "not found"),
}, nil)
gatewayClient.On("GetQuota", mock.Anything, mock.Anything).Return(&provider.GetQuotaResponse{
Status: status.NewUnimplemented(ctx, fmt.Errorf("not supported"), "not supported"),
}, nil)
r := httptest.NewRequest(http.MethodGet, "/graph/v1.0/me/drives", nil)
r = r.WithContext(ctx)
rr := httptest.NewRecorder()
svc.GetDrivesV1(rr, r)
Expect(rr.Code).To(Equal(http.StatusOK))
body, _ := io.ReadAll(rr.Body)
var response map[string][]libregraph.Drive
err := json.Unmarshal(body, &response)
Expect(err).ToNot(HaveOccurred())
Expect(len(response["value"])).To(Equal(1))
Expect(*response["value"][0].DriveType).To(Equal("personal"))
})
It("can list a spaces with sort", func() {
gatewayClient.On("ListStorageSpaces", mock.Anything, mock.Anything).Return(&provider.ListStorageSpacesResponse{
Status: status.NewOK(ctx),
@@ -811,6 +868,53 @@ var _ = Describe("Graph", func() {
Expect(*response.DriveAlias).To(Equal("project/testspace"))
Expect(*response.Description).To(Equal("This space is for testing"))
})
It("can create a protected-project space", func() {
gatewayClient.On("CreateStorageSpace", mock.Anything, mock.Anything).Return(&provider.CreateStorageSpaceResponse{
Status: status.NewOK(ctx),
StorageSpace: &provider.StorageSpace{
Id: &provider.StorageSpaceId{OpaqueId: "newID"},
Name: "Top Secret Project",
SpaceType: "protected-project",
Root: &provider.ResourceId{
StorageId: "pro-1",
SpaceId: "newID",
OpaqueId: "newID",
},
Opaque: &typesv1beta1.Opaque{
Map: map[string]*typesv1beta1.OpaqueEntry{
"description": {Decoder: "plain", Value: []byte("This space is protected")},
"spaceAlias": {Decoder: "plain", Value: []byte("protected-project/topsecretproject")},
},
},
},
}, nil)
permissionService.On("GetPermissionByID", mock.Anything, mock.Anything).Return(&settingssvc.GetPermissionByIDResponse{
Permission: &v0.Permission{
Operation: v0.Permission_OPERATION_READWRITE,
Constraint: v0.Permission_CONSTRAINT_ALL,
},
}, nil)
gatewayClient.On("GetQuota", mock.Anything, mock.Anything).Return(&provider.GetQuotaResponse{
Status: status.NewOK(ctx),
TotalBytes: 500,
}, nil)
jsonBody := []byte(`{"name": "Top Secret Project", "driveType": "protected-project", "description": "This space is protected"}`)
r := httptest.NewRequest(http.MethodPost, "/graph/v1.0/drives", bytes.NewBuffer(jsonBody)).WithContext(ctx)
rr := httptest.NewRecorder()
svc.CreateDrive(rr, r)
Expect(rr.Code).To(Equal(http.StatusCreated))
body, _ := io.ReadAll(rr.Body)
var response libregraph.Drive
err := json.Unmarshal(body, &response)
Expect(err).ToNot(HaveOccurred())
Expect(response.Name).To(Equal("Top Secret Project"))
Expect(*response.DriveType).To(Equal("protected-project"))
Expect(*response.Description).To(Equal("This space is protected"))
})
It("Incomplete space", func() {
gatewayClient.On("CreateStorageSpace", mock.Anything, mock.Anything).Return(&provider.CreateStorageSpaceResponse{
Status: status.NewOK(ctx),
+3 -30
View File
@@ -10,7 +10,6 @@ import (
"github.com/CiscoM31/godata"
libregraph "github.com/owncloud/libre-graph-api-go"
"github.com/owncloud/ocis/v2/ocis-pkg/mfa"
"github.com/owncloud/ocis/v2/services/graph/pkg/errorcode"
"github.com/go-chi/chi/v5"
@@ -32,35 +31,9 @@ func (g Graph) GetGroups(w http.ResponseWriter, r *http.Request) {
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, err.Error())
return
}
ctxHasFullPerms := g.contextUserHasFullAccountPerms(r.Context())
hasMFA := mfa.Has(r.Context())
if !hasAcceptableSearch(odataReq.Query, g.config.API.IdentitySearchMinLength) {
if !ctxHasFullPerms {
// for regular user the search term must have a minimum length
logger.Debug().Interface("query", r.URL.Query()).Msgf("search with less than %d chars for a regular user", g.config.API.IdentitySearchMinLength)
errorcode.AccessDenied.Render(w, r, http.StatusForbidden, "search term too short")
return
}
if !hasMFA {
logger.Error().Str("path", r.URL.Path).Msg("MFA required but not satisfied")
mfa.SetRequiredStatus(w)
return
}
}
if !hasAcceptableQuery(odataReq.Query) {
if !ctxHasFullPerms {
// regular users can't use filter, apply, expand and compute
logger.Debug().Interface("query", r.URL.Query()).Msg("forbidden query elements for a regular user")
errorcode.AccessDenied.Render(w, r, http.StatusForbidden, "query has forbidden elements for regular users")
return
}
if !hasMFA {
logger.Error().Str("path", r.URL.Path).Msg("MFA required but not satisfied")
mfa.SetRequiredStatus(w)
return
}
if !g.validateQuery(r, w, odataReq.Query, SearchValidator{MinLength: g.config.API.IdentitySearchMinLength}, BasicQueryValidator{}) {
return
}
groups, err := g.identityBackend.GetGroups(r.Context(), odataReq)
@@ -70,7 +43,7 @@ func (g Graph) GetGroups(w http.ResponseWriter, r *http.Request) {
return
}
// If the user isn't admin, we'll show just the minimum group attibutes
if !ctxHasFullPerms {
if !g.contextUserHasFullAccountPerms(r.Context()) {
finalGroups := make([]*libregraph.Group, len(groups))
for i, grp := range groups {
finalGroups[i] = &libregraph.Group{
+4 -46
View File
@@ -22,7 +22,6 @@ import (
"github.com/go-chi/render"
"github.com/google/uuid"
libregraph "github.com/owncloud/libre-graph-api-go"
"github.com/owncloud/ocis/v2/ocis-pkg/mfa"
settingsmsg "github.com/owncloud/ocis/v2/protogen/gen/ocis/messages/settings/v0"
settingssvc "github.com/owncloud/ocis/v2/protogen/gen/ocis/services/settings/v0"
"github.com/owncloud/ocis/v2/services/graph/pkg/errorcode"
@@ -324,51 +323,8 @@ func (g Graph) GetUsers(w http.ResponseWriter, r *http.Request) {
return
}
ctxHasFullPerms := g.contextUserHasFullAccountPerms(r.Context())
hasMFA := mfa.Has(r.Context())
if !hasAcceptableSearch(odataReq.Query, g.config.API.IdentitySearchMinLength) {
if !ctxHasFullPerms {
// for regular user the search term must have a minimum length
logger.Debug().Interface("query", r.URL.Query()).Msgf("search with less than %d chars for a regular user", g.config.API.IdentitySearchMinLength)
errorcode.AccessDenied.Render(w, r, http.StatusForbidden, "search term too short")
return
}
if !hasMFA {
logger.Error().Str("path", r.URL.Path).Msg("MFA required but not satisfied")
mfa.SetRequiredStatus(w)
return
}
}
if !hasAcceptableFilter(odataReq.Query) {
if !ctxHasFullPerms {
// regular users are allowed to filter only by userType
logger.Debug().Interface("query", r.URL.Query()).Msg("forbidden filter for a regular user")
errorcode.AccessDenied.Render(w, r, http.StatusForbidden, "filter has forbidden elements for regular users")
return
}
if !hasMFA {
logger.Error().Str("path", r.URL.Path).Msg("MFA required but not satisfied")
mfa.SetRequiredStatus(w)
return
}
}
if !hasAcceptableQuery(odataReq.Query) {
if !ctxHasFullPerms {
// regular users can't use filter, apply, expand and compute
logger.Debug().Interface("query", r.URL.Query()).Msg("forbidden query elements for a regular user")
errorcode.AccessDenied.Render(w, r, http.StatusForbidden, "query has forbidden elements for regular users")
return
}
if !hasMFA {
logger.Error().Str("path", r.URL.Path).Msg("MFA required but not satisfied")
mfa.SetRequiredStatus(w)
return
}
if !g.validateQuery(r, w, odataReq.Query, SearchValidator{MinLength: g.config.API.IdentitySearchMinLength}, FilterValidator{}, BasicQueryValidator{}) {
return
}
logger.Debug().Interface("query", r.URL.Query()).Msg("calling get users on backend")
@@ -435,6 +391,8 @@ func (g Graph) GetUsers(w http.ResponseWriter, r *http.Request) {
usersWithAttributes := make([]*UserWithAttributes, 0, len(users))
displayedAttributes := g.config.API.UserSearchDisplayedAttributes
ctxHasFullPerms := g.contextUserHasFullAccountPerms(r.Context())
for _, user := range users {
attributes, err := getUsersAttributes(displayedAttributes, user)
if err != nil {
+36 -5
View File
@@ -8,10 +8,10 @@ import (
userv1beta1 "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/google/uuid"
"github.com/owncloud/ocis/v2/ocis-pkg/log"
"github.com/owncloud/ocis/v2/services/graph/pkg/errorcode"
revactx "github.com/owncloud/reva/v2/pkg/ctx"
"github.com/owncloud/reva/v2/pkg/rgrpc/status"
"github.com/owncloud/reva/v2/pkg/rgrpc/todo/pool"
"github.com/owncloud/reva/v2/pkg/utils"
"google.golang.org/grpc/metadata"
@@ -72,10 +72,41 @@ func (m createHome) ServeHTTP(w http.ResponseWriter, req *http.Request) {
createHomeRes, err := client.CreateHome(ctx, createHomeReq)
if err != nil {
m.logger.Err(err).Msg("error calling CreateHome")
} else if createHomeRes.Status.Code != rpc.Code_CODE_OK {
err := status.NewErrorFromCode(createHomeRes.Status.Code, "gateway")
if createHomeRes.Status.Code != rpc.Code_CODE_ALREADY_EXISTS {
m.logger.Err(err).Msg("error when calling Createhome")
}
switch {
case createHomeRes.GetStatus().GetCode() == rpc.Code_CODE_OK:
m.logger.Info().Interface("userID", u.GetId().GetOpaqueId()).Msg("personal space created")
case createHomeRes.GetStatus().GetCode() != rpc.Code_CODE_ALREADY_EXISTS:
m.logger.Error().Interface("userID", u.GetId().GetOpaqueId()).Interface("status", createHomeRes.GetStatus()).Msg("personal space creation failed")
}
if spaceID := u.GetId().GetOpaqueId(); spaceID != "" {
// Create the "protected-personal" space.
// Use the user ID as the space ID if it is a valid uuid or generate a new one.
// Replace last 4 chars of the space id with "0000" to make it visible.
if err := uuid.Validate(spaceID); err != nil {
spaceID = uuid.New().String()
}
spaceID = spaceID[:len(spaceID)-4] + "0000"
createProtectedSpaceReq := &provider.CreateStorageSpaceRequest{
Type: "protected-personal",
Name: "Protected Personal",
Owner: &userv1beta1.User{
Id: u.Id,
},
Opaque: utils.AppendPlainToOpaque(nil, "spaceid", spaceID),
}
cpsRes, err := client.CreateStorageSpace(ctx, createProtectedSpaceReq)
if err != nil {
m.logger.Err(err).Msg("error calling CreateStorageSpace for protected-personal")
}
switch {
case cpsRes.GetStatus().GetCode() == rpc.Code_CODE_OK:
m.logger.Info().Interface("userID", u.GetId().GetOpaqueId()).Msg("protected-personal space created")
case cpsRes.GetStatus().GetCode() != rpc.Code_CODE_ALREADY_EXISTS:
m.logger.Error().Interface("userID", u.GetId().GetOpaqueId()).Interface("status", cpsRes.GetStatus()).Msg("protected-personal space creation failed")
}
}
}
+12 -6
View File
@@ -35,12 +35,14 @@ import (
)
const (
_spaceStateTrashed = "trashed"
_spaceTypeMountpoint = "mountpoint"
_spaceTypePersonal = "personal"
_spaceTypeProject = "project"
_spaceTypeGrant = "grant"
_slowQueryDuration = 500 * time.Millisecond
_spaceStateTrashed = "trashed"
_spaceTypeMountpoint = "mountpoint"
_spaceTypePersonal = "personal"
_spaceTypeProject = "project"
_spaceTypeProtectedPersonal = "protected-personal"
_spaceTypeProtectedProject = "protected-project"
_spaceTypeGrant = "grant"
_slowQueryDuration = 500 * time.Millisecond
)
var (
@@ -168,6 +170,10 @@ func (s *Service) Search(ctx context.Context, req *searchsvc.SearchRequest) (*se
// We still need the mountpoint in order to map the result paths to the according share
continue
}
if space.SpaceType == _spaceTypeProtectedPersonal || space.SpaceType == _spaceTypeProtectedProject {
// Exclude protected spaces from search results
continue
}
spaces = append(spaces, space)
}
@@ -105,6 +105,10 @@ func (c *cachedSpacesAPIClient) CreateStorageSpace(ctx context.Context, in *prov
if key != "" {
s := &provider.CreateStorageSpaceResponse{}
if err := c.createPersonalSpaceCache.PullFromCache(key, s); err == nil {
if s.Status == nil {
s.Status = &rpc.Status{}
}
s.Status.Code = rpc.Code_CODE_ALREADY_EXISTS
return s, nil
}
}
@@ -163,6 +167,10 @@ func (c *cachedAPIClient) CreateHome(ctx context.Context, in *provider.CreateHom
if key != "" {
s := &provider.CreateHomeResponse{}
if err := c.createPersonalSpaceCache.PullFromCache(key, s); err == nil {
if s.Status == nil {
s.Status = &rpc.Status{}
}
s.Status.Code = rpc.Code_CODE_ALREADY_EXISTS
return s, nil
}
}
@@ -33,6 +33,7 @@ import (
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
typesv1beta1 "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
"github.com/mitchellh/mapstructure"
"github.com/owncloud/reva/v2/pkg/appctx"
"github.com/owncloud/reva/v2/pkg/conversions"
ctxpkg "github.com/owncloud/reva/v2/pkg/ctx"
@@ -47,7 +48,6 @@ import (
"github.com/owncloud/reva/v2/pkg/storage/fs/registry"
"github.com/owncloud/reva/v2/pkg/storagespace"
"github.com/owncloud/reva/v2/pkg/utils"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"go.opentelemetry.io/otel/attribute"
@@ -519,7 +519,7 @@ func (s *Service) CreateStorageSpace(ctx context.Context, req *provider.CreateSt
// if trying to create a user home fall back to CreateHome
if u, ok := ctxpkg.ContextGetUser(ctx); ok && req.Type == "personal" && utils.UserEqual(req.GetOwner().Id, u.Id) {
if err := s.Storage.CreateHome(ctx); err != nil {
st = status.NewInternal(ctx, "error creating home")
st = status.NewStatusFromErrType(ctx, "error creating home", err)
} else {
st = status.NewOK(ctx)
// TODO we cannot return a space, but the gateway currently does not expect one...
@@ -31,6 +31,8 @@ import (
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/gdexlab/go-render/render"
"github.com/mitchellh/mapstructure"
"github.com/owncloud/reva/v2/internal/http/services/archiver/manager"
"github.com/owncloud/reva/v2/pkg/errtypes"
"github.com/owncloud/reva/v2/pkg/rgrpc/todo/pool"
@@ -40,11 +42,17 @@ import (
"github.com/owncloud/reva/v2/pkg/storage/utils/downloader"
"github.com/owncloud/reva/v2/pkg/storage/utils/walker"
"github.com/owncloud/reva/v2/pkg/storagespace"
"github.com/gdexlab/go-render/render"
"github.com/mitchellh/mapstructure"
"github.com/rs/zerolog"
)
const (
mfaHeader = "X-Multi-Factor-Authentication"
mfaRequiredHeader = "X-Ocis-Mfa-Required"
_spaceTypeProtectedPersonal = "protected-personal"
_spaceTypeProtectedProject = "protected-project"
)
type svc struct {
config *Config
gatewaySelector pool.Selectable[gateway.GatewayAPIClient]
@@ -251,6 +259,38 @@ func (s *svc) Handler() http.Handler {
return
}
// MFA check
gatewayClient, err := s.gatewaySelector.Next()
if err != nil {
s.log.Error().Err(err).Msg("failed to get gateway client")
s.writeHTTPError(rw, err)
return
}
for _, resource := range resources {
res, err := gatewayClient.Stat(ctx, &provider.StatRequest{
Ref: &provider.Reference{
ResourceId: resource,
Path: ".",
},
})
if err != nil {
s.log.Error().Err(err).Interface("resource", resource).Msg("failed to stat resource")
s.writeHTTPError(rw, err)
return
}
if res.Status.Code != rpc.Code_CODE_OK {
s.log.Error().Interface("resource", resource).Str("status", res.Status.Message).Msg("failed to stat resource")
s.writeHTTPError(rw, errors.New(res.Status.Message))
return
}
if isProtectedSpaceType(res.Info.GetSpace().GetSpaceType()) && !isMfaSet(r) {
s.log.Debug().Interface("resource", resource).Str("spacetype", res.Info.GetSpace().GetSpaceType()).Msg("MFA required for protected space")
rw.Header().Set(mfaRequiredHeader, "true")
rw.WriteHeader(http.StatusForbidden)
return
}
}
archName := s.config.Name
if format == "tar" {
archName += ".tar"
@@ -291,3 +331,11 @@ func (s *svc) Close() error {
func (s *svc) Unprotected() []string {
return nil
}
func isMfaSet(r *http.Request) bool {
return r.Header.Get(mfaHeader) == "true"
}
func isProtectedSpaceType(spaceType string) bool {
return spaceType == _spaceTypeProtectedPersonal || spaceType == _spaceTypeProtectedProject
}
@@ -671,6 +671,13 @@ func (s *svc) prepareCopy(ctx context.Context, w http.ResponseWriter, r *http.Re
return nil
}
// Disallow copying from poctected space to unprotected space
if isUnprotectedSpaceType(dstStatRes.GetInfo().GetSpace().GetSpaceType()) && isProtectedSpaceType(srcStatRes.GetInfo().GetSpace().GetSpaceType()) {
log.Error().Msg("the unprotected destination is disallowed")
w.WriteHeader(http.StatusBadRequest)
return nil
}
successCode := http.StatusCreated // 201 if new resource was created, see https://tools.ietf.org/html/rfc4918#section-9.8.5
if dstStatRes.Status.Code == rpc.Code_CODE_OK {
successCode = http.StatusNoContent // 204 if target already existed, see https://tools.ietf.org/html/rfc4918#section-9.8.5
@@ -50,6 +50,17 @@ const (
// WwwAuthenticate captures the Www-Authenticate header string.
WwwAuthenticate = "Www-Authenticate"
// mfaHeader is the header used to forward the MFA authentication status.
mfaHeader = "X-Multi-Factor-Authentication"
// mfaRequiredHeader is the response header indicating that MFA step-up authentication is required.
mfaRequiredHeader = "X-Ocis-Mfa-Required"
_spaceTypePersonal = "personal"
_spaceTypeProject = "project"
_spaceTypeProtectedPersonal = "protected-personal"
_spaceTypeProtectedProject = "protected-project"
)
const (
@@ -455,3 +466,17 @@ func handleOCMAuth(ctx context.Context, c gatewayv1beta1.GatewayAPIClient, ocmsh
ClientSecret: sharedSecret,
})
}
func isMfaSet(r *http.Request) bool {
return r.Header.Get(mfaHeader) == "true"
}
// isUnprotectedSpaceType returns true if the space type is unprotected.
func isUnprotectedSpaceType(spaceType string) bool {
return spaceType == _spaceTypePersonal || spaceType == _spaceTypeProject
}
// isProtectedSpaceType returns true if the space type requires MFA authentication.
func isProtectedSpaceType(spaceType string) bool {
return spaceType == _spaceTypeProtectedPersonal || spaceType == _spaceTypeProtectedProject
}
@@ -79,6 +79,14 @@ func (s *svc) handleGet(ctx context.Context, w http.ResponseWriter, r *http.Requ
return
}
// MFA enforcement.
if isProtectedSpaceType(sRes.GetInfo().GetSpace().GetSpaceType()) && !isMfaSet(r) {
log.Debug().Interface("ref", ref).Str("spacetype", sRes.GetInfo().GetSpace().GetSpaceType()).Msg("MFA required for protected space")
w.Header().Set(mfaRequiredHeader, "true")
w.WriteHeader(http.StatusForbidden)
return
}
if sRes.Info.Type != provider.ResourceType_RESOURCE_TYPE_FILE {
w.Header().Set("Content-Length", "0")
w.WriteHeader(http.StatusOK)
@@ -23,11 +23,13 @@ import (
"path"
"strings"
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/owncloud/reva/v2/internal/http/services/owncloud/ocdav/config"
"github.com/owncloud/reva/v2/internal/http/services/owncloud/ocdav/errors"
"github.com/owncloud/reva/v2/internal/http/services/owncloud/ocdav/net"
"github.com/owncloud/reva/v2/internal/http/services/owncloud/ocdav/propfind"
"github.com/owncloud/reva/v2/internal/http/services/owncloud/ocdav/spacelookup"
"github.com/owncloud/reva/v2/pkg/appctx"
"github.com/owncloud/reva/v2/pkg/rhttp/router"
"github.com/owncloud/reva/v2/pkg/storagespace"
@@ -53,8 +55,8 @@ func (h *SpacesHandler) init(c *config.Config) error {
func (h *SpacesHandler) Handler(s *svc, trashbinHandler *TrashbinHandler) http.Handler {
config := s.Config()
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// ctx := r.Context()
// log := appctx.GetLogger(ctx)
ctx := r.Context()
log := appctx.GetLogger(ctx)
if r.Method == http.MethodOptions {
s.handleOptions(w, r)
@@ -76,6 +78,22 @@ func (h *SpacesHandler) Handler(s *svc, trashbinHandler *TrashbinHandler) http.H
spaceID := segment
// MFA enforcement: look up the space type and require MFA for protected spaces.
if client, err := s.gatewaySelector.Next(); err == nil {
space, st, err := spacelookup.LookUpStorageSpaceByID(ctx, client, spaceID)
if err != nil {
log.Error().Err(err).Str("spaceid", spaceID).Msg("error looking up space for MFA check")
w.WriteHeader(http.StatusInternalServerError)
return
}
if st.GetCode() == rpc.Code_CODE_OK && isProtectedSpaceType(space.GetSpaceType()) && !isMfaSet(r) {
log.Debug().Str("spaceid", spaceID).Str("spacetype", space.GetSpaceType()).Msg("MFA required for protected space")
w.Header().Set(mfaRequiredHeader, "true")
w.WriteHeader(http.StatusForbidden)
return
}
}
// TODO initialize status with http.StatusBadRequest
// TODO initialize err with errors.ErrUnsupportedMethod
var status int // status 0 means the handler already sent the response
@@ -124,7 +142,7 @@ func (h *SpacesHandler) Handler(s *svc, trashbinHandler *TrashbinHandler) http.H
}
}
if err != nil {
appctx.GetLogger(r.Context()).Error().Err(err).Msg(err.Error())
log.Error().Err(err).Msg(err.Error())
}
})
}
+9 -7
View File
@@ -34,6 +34,7 @@ import (
providerpb "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
registrypb "github.com/cs3org/go-cs3apis/cs3/storage/registry/v1beta1"
typesv1beta1 "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
"github.com/mitchellh/mapstructure"
"github.com/owncloud/reva/v2/pkg/appctx"
ctxpkg "github.com/owncloud/reva/v2/pkg/ctx"
"github.com/owncloud/reva/v2/pkg/errtypes"
@@ -44,7 +45,6 @@ import (
pkgregistry "github.com/owncloud/reva/v2/pkg/storage/registry/registry"
"github.com/owncloud/reva/v2/pkg/storagespace"
"github.com/owncloud/reva/v2/pkg/utils"
"github.com/mitchellh/mapstructure"
"google.golang.org/grpc"
)
@@ -101,12 +101,14 @@ func (c *config) init() {
c.Providers = map[string]*Provider{
sharedconf.GetGatewaySVC(""): {
Spaces: map[string]*spaceConfig{
"personal": {MountPoint: "/users", PathTemplate: "/users/{{.Space.Owner.Id.OpaqueId}}"},
"project": {MountPoint: "/projects", PathTemplate: "/projects/{{.Space.Name}}"},
"virtual": {MountPoint: "/users/{{.CurrentUser.Id.OpaqueId}}/Shares"},
"grant": {MountPoint: "."},
"mountpoint": {MountPoint: "/users/{{.CurrentUser.Id.OpaqueId}}/Shares", PathTemplate: "/users/{{.CurrentUser.Id.OpaqueId}}/Shares/{{.Space.Name}}"},
"public": {MountPoint: "/public"},
"personal": {MountPoint: "/users", PathTemplate: "/users/{{.Space.Owner.Id.OpaqueId}}"},
"project": {MountPoint: "/projects", PathTemplate: "/projects/{{.Space.Name}}"},
"protected-personal": {MountPoint: "/protected-users", PathTemplate: "/protected-users/{{.Space.Owner.Id.OpaqueId}}"},
"protected-project": {MountPoint: "/protected-projects", PathTemplate: "/protected-projects/{{.Space.Name}}"},
"virtual": {MountPoint: "/users/{{.CurrentUser.Id.OpaqueId}}/Shares"},
"grant": {MountPoint: "."},
"mountpoint": {MountPoint: "/users/{{.CurrentUser.Id.OpaqueId}}/Shares", PathTemplate: "/users/{{.CurrentUser.Id.OpaqueId}}/Shares/{{.Space.Name}}"},
"public": {MountPoint: "/public"},
},
},
}
@@ -25,8 +25,10 @@ func init() {
}
const (
_spaceTypePersonal = "personal"
_spaceTypeProject = "project"
_spaceTypePersonal = "personal"
_spaceTypeProject = "project"
_spaceTypeProtectedPersonal = "protected-personal"
_spaceTypeProtectedProject = "protected-project"
)
// PermissionsChecker defines an interface for checking permissions on a Node
@@ -75,9 +77,9 @@ func (p Permissions) SetSpaceQuota(ctx context.Context, spaceid string, spaceTyp
switch spaceType {
default:
return false // only quotas of personal and project space may be changed
case _spaceTypePersonal:
case _spaceTypePersonal, _spaceTypeProtectedPersonal:
return p.checkPermission(ctx, "Drives.ReadWritePersonalQuota", spaceRef(spaceid))
case _spaceTypeProject:
case _spaceTypeProject, _spaceTypeProtectedProject:
return p.checkPermission(ctx, "Drives.ReadWriteProjectQuota", spaceRef(spaceid))
}
}
+16 -12
View File
@@ -56,11 +56,13 @@ import (
)
const (
_spaceTypePersonal = "personal"
_spaceTypeProject = "project"
spaceTypeShare = "share"
spaceTypeAny = "*"
spaceIDAny = "*"
_spaceTypePersonal = "personal"
_spaceTypeProject = "project"
_spaceTypeProtectedPersonal = "protected-personal"
_spaceTypeProtectedProject = "protected-project"
spaceTypeShare = "share"
spaceTypeAny = "*"
spaceIDAny = "*"
quotaUnrestricted = 0
)
@@ -82,7 +84,7 @@ func (fs *Decomposedfs) CreateStorageSpace(ctx context.Context, req *provider.Cr
// Check if space already exists
rootPath := ""
switch req.Type {
case _spaceTypePersonal:
case _spaceTypePersonal, _spaceTypeProtectedPersonal:
if fs.o.PersonalSpacePathTemplate != "" {
rootPath = filepath.Join(fs.o.Root, templates.WithUser(u, fs.o.PersonalSpacePathTemplate))
}
@@ -102,7 +104,7 @@ func (fs *Decomposedfs) CreateStorageSpace(ctx context.Context, req *provider.Cr
if alias == "" {
alias = templates.WithSpacePropertiesAndUser(u, req.Type, req.Name, spaceID, fs.o.GeneralSpaceAliasTemplate)
}
if req.Type == _spaceTypePersonal {
if req.Type == _spaceTypePersonal || req.Type == _spaceTypeProtectedPersonal {
alias = templates.WithSpacePropertiesAndUser(u, req.Type, req.Name, spaceID, fs.o.PersonalSpaceAliasTemplate)
}
@@ -199,7 +201,7 @@ func (fs *Decomposedfs) CreateStorageSpace(ctx context.Context, req *provider.Cr
ctx = storageprovider.WithSpaceType(ctx, req.Type)
if req.Type != _spaceTypePersonal {
if req.Type != _spaceTypePersonal && req.Type != _spaceTypeProtectedPersonal {
if err := fs.AddGrant(ctx, &provider.Reference{
ResourceId: &provider.ResourceId{
SpaceId: spaceID,
@@ -375,9 +377,11 @@ func (fs *Decomposedfs) ListStorageSpaces(ctx context.Context, filter []*provide
if _, ok := spaceTypes[spaceTypeAny]; ok {
// TODO do not hardcode dirs
spaceTypes = map[string]struct{}{
"personal": {},
"project": {},
"share": {},
"personal": {},
"project": {},
"share": {},
"protected-personal": {},
"protected-project": {},
}
}
@@ -1164,7 +1168,7 @@ func (fs *Decomposedfs) getSpaceRoot(spaceID string) string {
// - a project space can always be enabled/disabled/deleted by its manager (i.e. users have the "remove" grant)
func canDeleteSpace(ctx context.Context, spaceID string, typ string, purge bool, n *node.Node, p permissions.Permissions) error {
// delete-all-home spaces allows to disable and delete a personal space
if typ == "personal" {
if typ == _spaceTypePersonal || typ == _spaceTypeProtectedPersonal {
if p.DeleteAllHomeSpaces(ctx) {
return nil
}
+1 -1
View File
@@ -1316,7 +1316,7 @@ github.com/orcaman/concurrent-map
# github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245
## explicit; go 1.18
github.com/owncloud/libre-graph-api-go
# github.com/owncloud/reva/v2 v2.0.0-20260223124048-61ee39d95d5f
# github.com/owncloud/reva/v2 v2.0.0-20260303153746-059bcdfc4fbb
## explicit; go 1.24.0
github.com/owncloud/reva/v2/cmd/revad/internal/grace
github.com/owncloud/reva/v2/cmd/revad/runtime