Skip to content

Commit

Permalink
Merge pull request #2411 from owncloud/userprovider-owncloudsql
Browse files Browse the repository at this point in the history
add userprovider owncloudsql
  • Loading branch information
butonic authored Sep 3, 2021
2 parents 859aab8 + 990dd8d commit bb1b50c
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 2 deletions.
24 changes: 23 additions & 1 deletion storage/pkg/command/sharing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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{}{
Expand All @@ -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,
},
},
},
},
Expand Down
12 changes: 12 additions & 0 deletions storage/pkg/command/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
},
},
Expand Down
16 changes: 16 additions & 0 deletions storage/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ type Sharing struct {
PublicPasswordHashCost int
PublicEnableExpiredSharesCleanup bool
PublicJanitorRunInterval int
UserStorageMountID string
}

// Port defines the available port configuration.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
75 changes: 74 additions & 1 deletion storage/pkg/flagset/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand All @@ -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)...)
Expand Down

0 comments on commit bb1b50c

Please sign in to comment.