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 config to EOS fs for allowing recycle operations on arbitrary paths #2188

Merged
merged 1 commit into from
Oct 21, 2021
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
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