From 417defdbb912ae7c92c42e6f3f295f367ba5fd4a Mon Sep 17 00:00:00 2001 From: Ishank Arora Date: Thu, 7 Jan 2021 15:06:27 +0530 Subject: [PATCH 1/2] Functionality to map home directory to different storage providers --- changelog/unreleased/home-mapping.md | 9 +++++++++ storage/pkg/command/gateway.go | 1 + storage/pkg/config/config.go | 3 ++- storage/pkg/flagset/gateway.go | 7 +++++++ 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 changelog/unreleased/home-mapping.md diff --git a/changelog/unreleased/home-mapping.md b/changelog/unreleased/home-mapping.md new file mode 100644 index 0000000000..a502381b2d --- /dev/null +++ b/changelog/unreleased/home-mapping.md @@ -0,0 +1,9 @@ +Enhancement: Functionality to map home directory to different storage providers + +We added a parameter in reva that allows us to redirect /home requests to +different storage providers based on a mapping derived from the user attributes, +which was previously not possible since we hardcode the /home path for all +users. This PR adds the config for that parameter. + +https://github.com/owncloud/ocis/pull/1186 +https://github.com/cs3org/reva/pull/1142 diff --git a/storage/pkg/command/gateway.go b/storage/pkg/command/gateway.go index 552a1a97a9..0314d9df92 100644 --- a/storage/pkg/command/gateway.go +++ b/storage/pkg/command/gateway.go @@ -115,6 +115,7 @@ func Gateway(cfg *config.Config) *cli.Command { "datagateway": cfg.Reva.DataGateway.PublicURL, "transfer_shared_secret": cfg.Reva.TransferSecret, "transfer_expires": cfg.Reva.TransferExpires, + "home_mapping": cfg.Reva.Gateway.HomeMapping, }, "authregistry": map[string]interface{}{ "driver": "static", diff --git a/storage/pkg/config/config.go b/storage/pkg/config/config.go index 52a18dae62..02864be827 100644 --- a/storage/pkg/config/config.go +++ b/storage/pkg/config/config.go @@ -20,9 +20,10 @@ type Gateway struct { Port CommitShareToStorageGrant bool CommitShareToStorageRef bool + DisableHomeCreationOnLogin bool ShareFolder string LinkGrants string - DisableHomeCreationOnLogin bool + HomeMapping string } // StorageRegistry defines the available storage registry configuration diff --git a/storage/pkg/flagset/gateway.go b/storage/pkg/flagset/gateway.go index 4103ead538..5c8279eb22 100644 --- a/storage/pkg/flagset/gateway.go +++ b/storage/pkg/flagset/gateway.go @@ -97,6 +97,13 @@ func GatewayWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"STORAGE_GATEWAY_DISABLE_HOME_CREATION_ON_LOGIN"}, Destination: &cfg.Reva.Gateway.DisableHomeCreationOnLogin, }, + &cli.StringFlag{ + Name: "storage-home-mapping", + Value: "", + Usage: "mapping template for user home paths to user-specific mount points", + EnvVars: []string{"STORAGE_GATEWAY_HOME_MAPPING"}, + Destination: &cfg.Reva.Gateway.HomeMapping, + }, // other services From 5f818c6baef7ff1b986fa52cd09509111f0578a0 Mon Sep 17 00:00:00 2001 From: Ishank Arora Date: Thu, 7 Jan 2021 16:30:27 +0530 Subject: [PATCH 2/2] Add example --- changelog/unreleased/home-mapping.md | 4 +++- storage/pkg/flagset/gateway.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/changelog/unreleased/home-mapping.md b/changelog/unreleased/home-mapping.md index a502381b2d..467dec70ba 100644 --- a/changelog/unreleased/home-mapping.md +++ b/changelog/unreleased/home-mapping.md @@ -3,7 +3,9 @@ Enhancement: Functionality to map home directory to different storage providers We added a parameter in reva that allows us to redirect /home requests to different storage providers based on a mapping derived from the user attributes, which was previously not possible since we hardcode the /home path for all -users. This PR adds the config for that parameter. +users. For example, having its value as `/home/{{substr 0 1 .Username}}` can be +used to redirect home requests for different users to different storage +providers. https://github.com/owncloud/ocis/pull/1186 https://github.com/cs3org/reva/pull/1142 diff --git a/storage/pkg/flagset/gateway.go b/storage/pkg/flagset/gateway.go index 5c8279eb22..cc7a546e17 100644 --- a/storage/pkg/flagset/gateway.go +++ b/storage/pkg/flagset/gateway.go @@ -100,7 +100,7 @@ func GatewayWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "storage-home-mapping", Value: "", - Usage: "mapping template for user home paths to user-specific mount points", + Usage: "mapping template for user home paths to user-specific mount points, e.g. /home/{{substr 0 1 .Username}}", EnvVars: []string{"STORAGE_GATEWAY_HOME_MAPPING"}, Destination: &cfg.Reva.Gateway.HomeMapping, },