Skip to content

Commit

Permalink
Add config to EOS fs for allowing recycle operations on arbitrary pat…
Browse files Browse the repository at this point in the history
…hs (#2188)
  • Loading branch information
ishank011 authored Oct 21, 2021
1 parent 2fcbe16 commit d094bb6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
3 changes: 2 additions & 1 deletion changelog/unreleased/recycle-bin-arbitrary-paths.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Enhancement: Allow access to recycle bin for arbitrary paths outside homes

https://github.com/cs3org/reva/pull/2165
https://github.com/cs3org/reva/pull/2165
https://github.com/cs3org/reva/pull/2188
2 changes: 1 addition & 1 deletion pkg/cbox/storage/eoshomewrapper/eoshomewrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

package eoshome
package eoshomewrapper

import (
"bytes"
Expand Down
7 changes: 6 additions & 1 deletion pkg/cbox/storage/eoswrapper/eoswrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

package eoshome
package eoswrapper

import (
"bytes"
Expand Down Expand Up @@ -65,6 +65,11 @@ func parseConfig(m map[string]interface{}) (*eosfs.Config, string, error) {
c.VersionInvariant = true
}

// allow recycle operations for project spaces
if !c.EnableHome && strings.HasPrefix(c.Namespace, eosProjectsNamespace) {
c.AllowPathRecycleOperations = true
}

t, ok := m["mount_id_template"].(string)
if !ok || t == "" {
t = "eoshome-{{ trimAll \"/\" .Path | substr 0 1 }}"
Expand Down
6 changes: 6 additions & 0 deletions pkg/storage/utils/eosfs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ type Config struct {
// the HTTP chunked encoding
WriteUsesLocalTemp bool `mapstructure:"write_uses_local_temp"`

// Whether to allow recycle operations on base paths.
// If set to true, we'll look up the owner of the passed path and perform
// operations on that user's recycle bin.
// Only considered when EnableHome is false.
AllowPathRecycleOperations bool `mapstructure:"allow_path_recycle_operations"`

// HTTP connections to EOS: max number of idle conns
MaxIdleConns int `mapstructure:"max_idle_conns"`

Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/utils/eosfs/eosfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1469,7 +1469,7 @@ func (fs *eosfs) EmptyRecycle(ctx context.Context) error {
func (fs *eosfs) ListRecycle(ctx context.Context, basePath, key, relativePath string) ([]*provider.RecycleItem, error) {
var auth eosclient.Authorization

if !fs.conf.EnableHome && basePath != "/" {
if !fs.conf.EnableHome && fs.conf.AllowPathRecycleOperations && basePath != "/" {
// We need to access the recycle bin for a non-home reference.
// We'll get the owner of the particular resource and impersonate them
// if we have access to it.
Expand Down Expand Up @@ -1520,7 +1520,7 @@ func (fs *eosfs) ListRecycle(ctx context.Context, basePath, key, relativePath st
func (fs *eosfs) RestoreRecycleItem(ctx context.Context, basePath, key, relativePath string, restoreRef *provider.Reference) error {
var auth eosclient.Authorization

if !fs.conf.EnableHome && basePath != "/" {
if !fs.conf.EnableHome && fs.conf.AllowPathRecycleOperations && basePath != "/" {
// We need to access the recycle bin for a non-home reference.
// We'll get the owner of the particular resource and impersonate them
// if we have access to it.
Expand Down

0 comments on commit d094bb6

Please sign in to comment.