From 7ca9e12116dc975f674b8c6d120893e96a4178b9 Mon Sep 17 00:00:00 2001 From: Ishank Arora Date: Mon, 12 Apr 2021 14:52:03 +0200 Subject: [PATCH] Public share SQL driver config --- proxy/pkg/user/backend/cs3.go | 1 + storage/pkg/command/sharing.go | 10 ++++++++++ storage/pkg/config/config.go | 21 ++++++++++++--------- storage/pkg/flagset/sharing.go | 21 +++++++++++++++++++++ storage/pkg/flagset/sharingsql.go | 2 +- 5 files changed, 45 insertions(+), 10 deletions(-) diff --git a/proxy/pkg/user/backend/cs3.go b/proxy/pkg/user/backend/cs3.go index 3dff9c88c9..3443667a8a 100644 --- a/proxy/pkg/user/backend/cs3.go +++ b/proxy/pkg/user/backend/cs3.go @@ -85,6 +85,7 @@ func (c *cs3backend) GetUserByClaims(ctx context.Context, claim, value string, w func (c *cs3backend) Authenticate(ctx context.Context, username string, password string) (*cs3.User, error) { res, err := c.authProvider.Authenticate(ctx, &gateway.AuthenticateRequest{ + Type: "basic", ClientId: username, ClientSecret: password, }) diff --git a/storage/pkg/command/sharing.go b/storage/pkg/command/sharing.go index 264491a504..29c7cb4dcc 100644 --- a/storage/pkg/command/sharing.go +++ b/storage/pkg/command/sharing.go @@ -140,6 +140,16 @@ func sharingConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]inte "json": map[string]interface{}{ "file": cfg.Reva.Sharing.PublicJSONFile, }, + "sql": map[string]interface{}{ + "db_username": cfg.Reva.Sharing.UserSQLUsername, + "db_password": cfg.Reva.Sharing.UserSQLPassword, + "db_host": cfg.Reva.Sharing.UserSQLHost, + "db_port": cfg.Reva.Sharing.UserSQLPort, + "db_name": cfg.Reva.Sharing.UserSQLName, + "password_hash_cost": cfg.Reva.Sharing.PublicPasswordHashCost, + "enable_expired_shares_cleanup": cfg.Reva.Sharing.PublicEnableExpiredSharesCleanup, + "janitor_run_interval": cfg.Reva.Sharing.PublicJanitorRunInterval, + }, }, }, }, diff --git a/storage/pkg/config/config.go b/storage/pkg/config/config.go index 11b395e921..7f048bb920 100644 --- a/storage/pkg/config/config.go +++ b/storage/pkg/config/config.go @@ -41,15 +41,18 @@ type StorageRegistry struct { // Sharing defines the available sharing configuration. type Sharing struct { Port - UserDriver string - UserJSONFile string - UserSQLUsername string - UserSQLPassword string - UserSQLHost string - UserSQLPort int - UserSQLName string - PublicDriver string - PublicJSONFile string + UserDriver string + UserJSONFile string + UserSQLUsername string + UserSQLPassword string + UserSQLHost string + UserSQLPort int + UserSQLName string + PublicDriver string + PublicJSONFile string + PublicPasswordHashCost int + PublicEnableExpiredSharesCleanup bool + PublicJanitorRunInterval int } // Port defines the available port configuration. diff --git a/storage/pkg/flagset/sharing.go b/storage/pkg/flagset/sharing.go index d32d1e6517..b9a1d989e0 100644 --- a/storage/pkg/flagset/sharing.go +++ b/storage/pkg/flagset/sharing.go @@ -71,6 +71,27 @@ func SharingWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"STORAGE_SHARING_PUBLIC_JSON_FILE"}, Destination: &cfg.Reva.Sharing.PublicJSONFile, }, + &cli.IntFlag{ + Name: "public-password-hash-cost", + Value: flags.OverrideDefaultInt(cfg.Reva.Sharing.PublicPasswordHashCost, 11), + Usage: "the cost of hashing the public shares passwords", + EnvVars: []string{"STORAGE_SHARING_PUBLIC_PASSWORD_HASH_COST"}, + Destination: &cfg.Reva.Sharing.PublicPasswordHashCost, + }, + &cli.BoolFlag{ + Name: "public-enable-expired-shares-cleanup", + Value: flags.OverrideDefaultBool(cfg.Reva.Sharing.PublicEnableExpiredSharesCleanup, true), + Usage: "whether to periodically delete expired public shares", + EnvVars: []string{"STORAGE_SHARING_PUBLIC_ENABLE_EXPIRED_SHARES_CLEANUP"}, + Destination: &cfg.Reva.Sharing.PublicEnableExpiredSharesCleanup, + }, + &cli.IntFlag{ + Name: "public-janitor-run-interval", + Value: flags.OverrideDefaultInt(cfg.Reva.Sharing.PublicJanitorRunInterval, 60), + Usage: "the time period in seconds after which to start a janitor run", + EnvVars: []string{"STORAGE_SHARING_PUBLIC_JANITOR_RUN_INTERVAL"}, + Destination: &cfg.Reva.Sharing.PublicJanitorRunInterval, + }, } flags = append(flags, TracingWithConfig(cfg)...) diff --git a/storage/pkg/flagset/sharingsql.go b/storage/pkg/flagset/sharingsql.go index 5aef7ef77c..e4770b4a9a 100644 --- a/storage/pkg/flagset/sharingsql.go +++ b/storage/pkg/flagset/sharingsql.go @@ -41,7 +41,7 @@ func SharingSQLWithConfig(cfg *config.Config) []cli.Flag { Name: "user-sql-name", Value: flags.OverrideDefaultString(cfg.Reva.Sharing.UserSQLName, ""), Usage: "Name of the SQL database", - EnvVars: []string{"STORAGE_SHARING_USER_SQL_Name"}, + EnvVars: []string{"STORAGE_SHARING_USER_SQL_NAME"}, Destination: &cfg.Reva.Sharing.UserSQLName, }, }