diff --git a/storage/pkg/command/sharing.go b/storage/pkg/command/sharing.go index 08958b05868..3a3dd044823 100644 --- a/storage/pkg/command/sharing.go +++ b/storage/pkg/command/sharing.go @@ -113,6 +113,7 @@ func sharingConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]inte }, "shared": map[string]interface{}{ "jwt_secret": cfg.Reva.JWTSecret, + "gatewaysvc": cfg.Reva.Gateway.Endpoint, }, "grpc": map[string]interface{}{ "network": cfg.Reva.Sharing.GRPCNetwork, @@ -125,7 +126,7 @@ func sharingConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]inte "json": map[string]interface{}{ "file": cfg.Reva.Sharing.UserJSONFile, }, - "sql": map[string]interface{}{ + "sql": map[string]interface{}{ // cernbox sql "db_username": cfg.Reva.Sharing.UserSQLUsername, "db_password": cfg.Reva.Sharing.UserSQLPassword, "db_host": cfg.Reva.Sharing.UserSQLHost, @@ -135,6 +136,15 @@ func sharingConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]inte "enable_expired_shares_cleanup": cfg.Reva.Sharing.PublicEnableExpiredSharesCleanup, "janitor_run_interval": cfg.Reva.Sharing.PublicJanitorRunInterval, }, + "oc10-sql": map[string]interface{}{ + "gateway_addr": cfg.Reva.Gateway.Endpoint, + "storage_mount_id": cfg.Reva.Sharing.UserStorageMountId, + "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, + }, }, }, "publicshareprovider": map[string]interface{}{ @@ -153,6 +163,18 @@ func sharingConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]inte "enable_expired_shares_cleanup": cfg.Reva.Sharing.PublicEnableExpiredSharesCleanup, "janitor_run_interval": cfg.Reva.Sharing.PublicJanitorRunInterval, }, + "oc10-sql": map[string]interface{}{ + "gateway_addr": cfg.Reva.Gateway.Endpoint, + "storage_mount_id": cfg.Reva.Sharing.UserStorageMountId, + "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/command/users.go b/storage/pkg/command/users.go index f93171e1eb7..4836afe6d49 100644 --- a/storage/pkg/command/users.go +++ b/storage/pkg/command/users.go @@ -151,6 +151,18 @@ func usersConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]interf "oidc_token_endpoint": cfg.Reva.UserGroupRest.OIDCTokenEndpoint, "target_api": cfg.Reva.UserGroupRest.TargetAPI, }, + "owncloudsql": map[string]interface{}{ + "dbusername": cfg.Reva.UserOwnCloudSQL.DBUsername, + "dbpassword": cfg.Reva.UserOwnCloudSQL.DBPassword, + "dbhost": cfg.Reva.UserOwnCloudSQL.DBHost, + "dbport": cfg.Reva.UserOwnCloudSQL.DBPort, + "dbname": cfg.Reva.UserOwnCloudSQL.DBName, + "idp": cfg.Reva.UserOwnCloudSQL.Idp, + "nobody": cfg.Reva.UserOwnCloudSQL.Nobody, + "join_username": cfg.Reva.UserOwnCloudSQL.JoinUsername, + "join_ownclouduuid": cfg.Reva.UserOwnCloudSQL.JoinOwnCloudUUID, + "enable_medial_search": cfg.Reva.UserOwnCloudSQL.EnableMedialSearch, + }, }, }, }, diff --git a/storage/pkg/config/config.go b/storage/pkg/config/config.go index 23a3ff23af9..7d4e05f53b0 100644 --- a/storage/pkg/config/config.go +++ b/storage/pkg/config/config.go @@ -75,6 +75,7 @@ type Sharing struct { PublicPasswordHashCost int PublicEnableExpiredSharesCleanup bool PublicJanitorRunInterval int + UserStorageMountId string } // Port defines the available port configuration. @@ -361,6 +362,20 @@ type UserGroupRest struct { TargetAPI string } +// UserOwnCloudSQL defines the available ownCloudSQL user provider configuration. +type UserOwnCloudSQL struct { + DBUsername string + DBPassword string + DBHost string + DBPort int + DBName string + Idp string + Nobody int64 + JoinUsername bool + JoinOwnCloudUUID bool + EnableMedialSearch bool +} + // LDAPUserSchema defines the available ldap user schema configuration. type LDAPUserSchema struct { UID string @@ -395,6 +410,7 @@ type Reva struct { OIDC OIDC LDAP LDAP UserGroupRest UserGroupRest + UserOwnCloudSQL UserOwnCloudSQL OCDav OCDav Storages StorageConfig // Ports are used to configure which services to start on which port diff --git a/storage/pkg/flagset/users.go b/storage/pkg/flagset/users.go index b9e6ba127e2..f74796dbda0 100644 --- a/storage/pkg/flagset/users.go +++ b/storage/pkg/flagset/users.go @@ -54,7 +54,7 @@ func UsersWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "driver", Value: flags.OverrideDefaultString(cfg.Reva.Users.Driver, "ldap"), - Usage: "user driver: 'demo', 'json', 'ldap', or 'rest'", + Usage: "user driver: 'demo', 'json', 'ldap', 'owncloudsql' or 'rest'", EnvVars: []string{"STORAGE_USERPROVIDER_DRIVER"}, Destination: &cfg.Reva.Users.Driver, }, @@ -72,6 +72,79 @@ func UsersWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"STORAGE_USER_CACHE_EXPIRATION"}, Destination: &cfg.Reva.Users.UserGroupsCacheExpiration, }, + + // user owncloudsql + + &cli.StringFlag{ + Name: "owncloudsql-dbhost", + Value: flags.OverrideDefaultString(cfg.Reva.UserOwnCloudSQL.DBHost, "mysql"), + Usage: "hostname of the mysql db", + EnvVars: []string{"STORAGE_USERPROVIDER_OWNCLOUDSQL_DBHOST"}, + Destination: &cfg.Reva.UserOwnCloudSQL.DBHost, + }, + &cli.IntFlag{ + Name: "owncloudsql-dbport", + Value: flags.OverrideDefaultInt(cfg.Reva.UserOwnCloudSQL.DBPort, 3306), + Usage: "port of the mysql db", + EnvVars: []string{"STORAGE_USERPROVIDER_OWNCLOUDSQL_DBPORT"}, + Destination: &cfg.Reva.UserOwnCloudSQL.DBPort, + }, + &cli.StringFlag{ + Name: "owncloudsql-dbname", + Value: flags.OverrideDefaultString(cfg.Reva.UserOwnCloudSQL.DBName, "owncloud"), + Usage: "database name of the owncloud db", + EnvVars: []string{"STORAGE_USERPROVIDER_OWNCLOUDSQL_DBNAME"}, + Destination: &cfg.Reva.UserOwnCloudSQL.DBName, + }, + &cli.StringFlag{ + Name: "owncloudsql-dbuser", + Value: flags.OverrideDefaultString(cfg.Reva.UserOwnCloudSQL.DBUsername, "owncloud"), + Usage: "user name to use when connecting to the mysql owncloud db", + EnvVars: []string{"STORAGE_USERPROVIDER_OWNCLOUDSQL_DBUSER"}, + Destination: &cfg.Reva.UserOwnCloudSQL.DBUsername, + }, + &cli.StringFlag{ + Name: "owncloudsql-dbpass", + Value: flags.OverrideDefaultString(cfg.Reva.UserOwnCloudSQL.DBPassword, "secret"), + Usage: "password to use when connecting to the mysql owncloud db", + EnvVars: []string{"STORAGE_USERPROVIDER_OWNCLOUDSQL_DBPASS"}, + Destination: &cfg.Reva.UserOwnCloudSQL.DBPassword, + }, + &cli.StringFlag{ + Name: "owncloudsql-idp", + Value: flags.OverrideDefaultString(cfg.Reva.UserOwnCloudSQL.Idp, "https://localhost:9200"), + Usage: "Identity provider to use for users", + EnvVars: []string{"STORAGE_USERPROVIDER_OWNCLOUDSQL_IDP", "OCIS_URL"}, + Destination: &cfg.Reva.UserOwnCloudSQL.Idp, + }, + &cli.Int64Flag{ + Name: "owncloudsql-nobody", + Value: flags.OverrideDefaultInt64(cfg.Reva.UserOwnCloudSQL.Nobody, 99), + Usage: "fallback user id to use when user has no id", + EnvVars: []string{"STORAGE_USERPROVIDER_OWNCLOUDSQL_NOBODY"}, + Destination: &cfg.Reva.UserOwnCloudSQL.Nobody, + }, + &cli.BoolFlag{ + Name: "owncloudsql-join-username", + Value: flags.OverrideDefaultBool(cfg.Reva.UserOwnCloudSQL.JoinUsername, false), + Usage: "join the username from the oc_preferences table", + EnvVars: []string{"STORAGE_USERPROVIDER_OWNCLOUDSQL_JOIN_USERNAME"}, + Destination: &cfg.Reva.UserOwnCloudSQL.JoinUsername, + }, + &cli.BoolFlag{ + Name: "owncloudsql-join-ownclouduuid", + Value: flags.OverrideDefaultBool(cfg.Reva.UserOwnCloudSQL.JoinOwnCloudUUID, false), + Usage: "join the ownclouduuid from the oc_preferences table", + EnvVars: []string{"STORAGE_USERPROVIDER_OWNCLOUDSQL_JOIN_OWNCLOUDUUID"}, + Destination: &cfg.Reva.UserOwnCloudSQL.JoinOwnCloudUUID, + }, + &cli.BoolFlag{ + Name: "owncloudsql-enable-medial-search", + Value: flags.OverrideDefaultBool(cfg.Reva.UserOwnCloudSQL.EnableMedialSearch, false), + Usage: "enable medial search when finding users", + EnvVars: []string{"STORAGE_USERPROVIDER_OWNCLOUDSQL_ENABLE_MEDIAL_SEARCH"}, + Destination: &cfg.Reva.UserOwnCloudSQL.EnableMedialSearch, + }, } flags = append(flags, TracingWithConfig(cfg)...)