Separation of concerns
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
Enhancement: Add config for group provider service and sharing SQL driver
|
||||
Enhancement: Enable group sharing and add config for sharing SQL driver
|
||||
|
||||
https://github.com/owncloud/ocis/pull/1626/files
|
||||
This PR adds config to support sharing with groups. It also introduces a
|
||||
breaking change for the CS3APIs definitions since grantees can now refer to both
|
||||
users as well as groups. Since we store the grantee information in a json file,
|
||||
`/var/tmp/ocis/storage/shares.json`, its previous version needs to be removed as
|
||||
we won't be able to unmarshal data corresponding to the previous definitions.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/1626
|
||||
https://github.com/cs3org/reva/pull/1453
|
||||
|
||||
@@ -64,85 +64,20 @@ func GroupsWithConfig(cfg *config.Config) []cli.Flag {
|
||||
EnvVars: []string{"STORAGE_GROUPPROVIDER_JSON"},
|
||||
Destination: &cfg.Reva.Groups.JSON,
|
||||
},
|
||||
&cli.IntFlag{
|
||||
&cli.IntFlag{
|
||||
Name: "group-members-cache-expiration",
|
||||
Value: 5,
|
||||
Usage: "Time in minutes for redis cache expiration.",
|
||||
EnvVars: []string{"STORAGE_GROUP_CACHE_EXPIRATION"},
|
||||
Destination: &cfg.Reva.Groups.GroupMembersCacheExpiration,
|
||||
},
|
||||
|
||||
// rest driver
|
||||
|
||||
&cli.StringFlag{
|
||||
Name: "rest-client-id",
|
||||
Value: "",
|
||||
Usage: "User/group rest driver Client ID",
|
||||
EnvVars: []string{"STORAGE_REST_CLIENT_ID"},
|
||||
Destination: &cfg.Reva.UserGroupRest.ClientID,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "rest-client-secret",
|
||||
Value: "",
|
||||
Usage: "User/group rest driver Client Secret",
|
||||
EnvVars: []string{"STORAGE_REST_CLIENT_SECRET"},
|
||||
Destination: &cfg.Reva.UserGroupRest.ClientSecret,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "rest-redis-address",
|
||||
Value: "localhost:6379",
|
||||
Usage: "Address for redis server",
|
||||
EnvVars: []string{"STORAGE_REST_REDIS_ADDRESS"},
|
||||
Destination: &cfg.Reva.UserGroupRest.RedisAddress,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "rest-redis-username",
|
||||
Value: "",
|
||||
Usage: "Username for redis server",
|
||||
EnvVars: []string{"STORAGE_REST_REDIS_USERNAME"},
|
||||
Destination: &cfg.Reva.UserGroupRest.RedisUsername,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "rest-redis-password",
|
||||
Value: "",
|
||||
Usage: "Password for redis server",
|
||||
EnvVars: []string{"STORAGE_REST_REDIS_PASSWORD"},
|
||||
Destination: &cfg.Reva.UserGroupRest.RedisPassword,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "rest-id-provider",
|
||||
Value: "",
|
||||
Usage: "The OIDC Provider",
|
||||
EnvVars: []string{"STORAGE_REST_ID_PROVIDER"},
|
||||
Destination: &cfg.Reva.UserGroupRest.IDProvider,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "rest-api-base-url",
|
||||
Value: "",
|
||||
Usage: "Base API Endpoint",
|
||||
EnvVars: []string{"STORAGE_REST_API_BASE_URL"},
|
||||
Destination: &cfg.Reva.UserGroupRest.APIBaseURL,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "rest-oidc-token-endpoint",
|
||||
Value: "",
|
||||
Usage: "Endpoint to generate token to access the API",
|
||||
EnvVars: []string{"STORAGE_REST_OIDC_TOKEN_ENDPOINT"},
|
||||
Destination: &cfg.Reva.UserGroupRest.OIDCTokenEndpoint,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "rest-target-api",
|
||||
Value: "",
|
||||
Usage: "The target application",
|
||||
EnvVars: []string{"STORAGE_REST_TARGET_API"},
|
||||
Destination: &cfg.Reva.UserGroupRest.TargetAPI,
|
||||
},
|
||||
}
|
||||
|
||||
flags = append(flags, TracingWithConfig(cfg)...)
|
||||
flags = append(flags, DebugWithConfig(cfg)...)
|
||||
flags = append(flags, SecretWithConfig(cfg)...)
|
||||
flags = append(flags, LDAPWithConfig(cfg)...)
|
||||
flags = append(flags, RestWithConfig(cfg)...)
|
||||
|
||||
return flags
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package flagset
|
||||
|
||||
import (
|
||||
"github.com/micro/cli/v2"
|
||||
"github.com/owncloud/ocis/storage/pkg/config"
|
||||
)
|
||||
|
||||
// RestWithConfig applies REST user/group provider cfg to the flagset
|
||||
func RestWithConfig(cfg *config.Config) []cli.Flag {
|
||||
return []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "rest-client-id",
|
||||
Value: "",
|
||||
Usage: "User/group rest driver Client ID",
|
||||
EnvVars: []string{"STORAGE_REST_CLIENT_ID"},
|
||||
Destination: &cfg.Reva.UserGroupRest.ClientID,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "rest-client-secret",
|
||||
Value: "",
|
||||
Usage: "User/group rest driver Client Secret",
|
||||
EnvVars: []string{"STORAGE_REST_CLIENT_SECRET"},
|
||||
Destination: &cfg.Reva.UserGroupRest.ClientSecret,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "rest-redis-address",
|
||||
Value: "localhost:6379",
|
||||
Usage: "Address for redis server",
|
||||
EnvVars: []string{"STORAGE_REST_REDIS_ADDRESS"},
|
||||
Destination: &cfg.Reva.UserGroupRest.RedisAddress,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "rest-redis-username",
|
||||
Value: "",
|
||||
Usage: "Username for redis server",
|
||||
EnvVars: []string{"STORAGE_REST_REDIS_USERNAME"},
|
||||
Destination: &cfg.Reva.UserGroupRest.RedisUsername,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "rest-redis-password",
|
||||
Value: "",
|
||||
Usage: "Password for redis server",
|
||||
EnvVars: []string{"STORAGE_REST_REDIS_PASSWORD"},
|
||||
Destination: &cfg.Reva.UserGroupRest.RedisPassword,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "rest-id-provider",
|
||||
Value: "",
|
||||
Usage: "The OIDC Provider",
|
||||
EnvVars: []string{"STORAGE_REST_ID_PROVIDER"},
|
||||
Destination: &cfg.Reva.UserGroupRest.IDProvider,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "rest-api-base-url",
|
||||
Value: "",
|
||||
Usage: "Base API Endpoint",
|
||||
EnvVars: []string{"STORAGE_REST_API_BASE_URL"},
|
||||
Destination: &cfg.Reva.UserGroupRest.APIBaseURL,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "rest-oidc-token-endpoint",
|
||||
Value: "",
|
||||
Usage: "Endpoint to generate token to access the API",
|
||||
EnvVars: []string{"STORAGE_REST_OIDC_TOKEN_ENDPOINT"},
|
||||
Destination: &cfg.Reva.UserGroupRest.OIDCTokenEndpoint,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "rest-target-api",
|
||||
Value: "",
|
||||
Usage: "The target application",
|
||||
EnvVars: []string{"STORAGE_REST_TARGET_API"},
|
||||
Destination: &cfg.Reva.UserGroupRest.TargetAPI,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -56,41 +56,6 @@ func SharingWithConfig(cfg *config.Config) []cli.Flag {
|
||||
EnvVars: []string{"STORAGE_SHARING_USER_JSON_FILE"},
|
||||
Destination: &cfg.Reva.Sharing.UserJSONFile,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "user-sql-username",
|
||||
Value: "",
|
||||
Usage: "Username to be used to connect to the SQL database",
|
||||
EnvVars: []string{"STORAGE_SHARING_USER_SQL_USERNAME"},
|
||||
Destination: &cfg.Reva.Sharing.UserSQLUsername,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "user-sql-password",
|
||||
Value: "",
|
||||
Usage: "Password to be used to connect to the SQL database",
|
||||
EnvVars: []string{"STORAGE_SHARING_USER_SQL_PASSWORD"},
|
||||
Destination: &cfg.Reva.Sharing.UserSQLPassword,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "user-sql-host",
|
||||
Value: "",
|
||||
Usage: "Hostname of the SQL database",
|
||||
EnvVars: []string{"STORAGE_SHARING_USER_SQL_HOST"},
|
||||
Destination: &cfg.Reva.Sharing.UserSQLHost,
|
||||
},
|
||||
&cli.IntFlag{
|
||||
Name: "user-sql-port",
|
||||
Value: 1433,
|
||||
Usage: "The port on which the SQL database is exposed",
|
||||
EnvVars: []string{"STORAGE_SHARING_USER_SQL_PORT"},
|
||||
Destination: &cfg.Reva.Sharing.UserSQLPort,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "user-sql-name",
|
||||
Value: "",
|
||||
Usage: "Name of the SQL database",
|
||||
EnvVars: []string{"STORAGE_SHARING_USER_SQL_Name"},
|
||||
Destination: &cfg.Reva.Sharing.UserSQLName,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "public-driver",
|
||||
Value: "json",
|
||||
@@ -110,6 +75,7 @@ func SharingWithConfig(cfg *config.Config) []cli.Flag {
|
||||
flags = append(flags, TracingWithConfig(cfg)...)
|
||||
flags = append(flags, DebugWithConfig(cfg)...)
|
||||
flags = append(flags, SecretWithConfig(cfg)...)
|
||||
flags = append(flags, SharingSQLWithConfig(cfg)...)
|
||||
|
||||
return flags
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package flagset
|
||||
|
||||
import (
|
||||
"github.com/micro/cli/v2"
|
||||
"github.com/owncloud/ocis/storage/pkg/config"
|
||||
)
|
||||
|
||||
// SharingSQLWithConfig applies the Shring SQL driver cfg to the flagset
|
||||
func SharingSQLWithConfig(cfg *config.Config) []cli.Flag {
|
||||
return []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "user-sql-username",
|
||||
Value: "",
|
||||
Usage: "Username to be used to connect to the SQL database",
|
||||
EnvVars: []string{"STORAGE_SHARING_USER_SQL_USERNAME"},
|
||||
Destination: &cfg.Reva.Sharing.UserSQLUsername,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "user-sql-password",
|
||||
Value: "",
|
||||
Usage: "Password to be used to connect to the SQL database",
|
||||
EnvVars: []string{"STORAGE_SHARING_USER_SQL_PASSWORD"},
|
||||
Destination: &cfg.Reva.Sharing.UserSQLPassword,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "user-sql-host",
|
||||
Value: "",
|
||||
Usage: "Hostname of the SQL database",
|
||||
EnvVars: []string{"STORAGE_SHARING_USER_SQL_HOST"},
|
||||
Destination: &cfg.Reva.Sharing.UserSQLHost,
|
||||
},
|
||||
&cli.IntFlag{
|
||||
Name: "user-sql-port",
|
||||
Value: 1433,
|
||||
Usage: "The port on which the SQL database is exposed",
|
||||
EnvVars: []string{"STORAGE_SHARING_USER_SQL_PORT"},
|
||||
Destination: &cfg.Reva.Sharing.UserSQLPort,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "user-sql-name",
|
||||
Value: "",
|
||||
Usage: "Name of the SQL database",
|
||||
EnvVars: []string{"STORAGE_SHARING_USER_SQL_Name"},
|
||||
Destination: &cfg.Reva.Sharing.UserSQLName,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -71,78 +71,13 @@ func UsersWithConfig(cfg *config.Config) []cli.Flag {
|
||||
EnvVars: []string{"STORAGE_USER_CACHE_EXPIRATION"},
|
||||
Destination: &cfg.Reva.Users.UserGroupsCacheExpiration,
|
||||
},
|
||||
|
||||
// rest driver
|
||||
|
||||
&cli.StringFlag{
|
||||
Name: "rest-client-id",
|
||||
Value: "",
|
||||
Usage: "User/group rest driver Client ID",
|
||||
EnvVars: []string{"STORAGE_REST_CLIENT_ID"},
|
||||
Destination: &cfg.Reva.UserGroupRest.ClientID,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "rest-client-secret",
|
||||
Value: "",
|
||||
Usage: "User/group rest driver Client Secret",
|
||||
EnvVars: []string{"STORAGE_REST_CLIENT_SECRET"},
|
||||
Destination: &cfg.Reva.UserGroupRest.ClientSecret,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "rest-redis-address",
|
||||
Value: "localhost:6379",
|
||||
Usage: "Address for redis server",
|
||||
EnvVars: []string{"STORAGE_REST_REDIS_ADDRESS"},
|
||||
Destination: &cfg.Reva.UserGroupRest.RedisAddress,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "rest-redis-username",
|
||||
Value: "",
|
||||
Usage: "Username for redis server",
|
||||
EnvVars: []string{"STORAGE_REST_REDIS_USERNAME"},
|
||||
Destination: &cfg.Reva.UserGroupRest.RedisUsername,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "rest-redis-password",
|
||||
Value: "",
|
||||
Usage: "Password for redis server",
|
||||
EnvVars: []string{"STORAGE_REST_REDIS_PASSWORD"},
|
||||
Destination: &cfg.Reva.UserGroupRest.RedisPassword,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "rest-id-provider",
|
||||
Value: "",
|
||||
Usage: "The OIDC Provider",
|
||||
EnvVars: []string{"STORAGE_REST_ID_PROVIDER"},
|
||||
Destination: &cfg.Reva.UserGroupRest.IDProvider,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "rest-api-base-url",
|
||||
Value: "",
|
||||
Usage: "Base API Endpoint",
|
||||
EnvVars: []string{"STORAGE_REST_API_BASE_URL"},
|
||||
Destination: &cfg.Reva.UserGroupRest.APIBaseURL,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "rest-oidc-token-endpoint",
|
||||
Value: "",
|
||||
Usage: "Endpoint to generate token to access the API",
|
||||
EnvVars: []string{"STORAGE_REST_OIDC_TOKEN_ENDPOINT"},
|
||||
Destination: &cfg.Reva.UserGroupRest.OIDCTokenEndpoint,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "rest-target-api",
|
||||
Value: "",
|
||||
Usage: "The target application",
|
||||
EnvVars: []string{"STORAGE_REST_TARGET_API"},
|
||||
Destination: &cfg.Reva.UserGroupRest.TargetAPI,
|
||||
},
|
||||
}
|
||||
|
||||
flags = append(flags, TracingWithConfig(cfg)...)
|
||||
flags = append(flags, DebugWithConfig(cfg)...)
|
||||
flags = append(flags, SecretWithConfig(cfg)...)
|
||||
flags = append(flags, LDAPWithConfig(cfg)...)
|
||||
flags = append(flags, RestWithConfig(cfg)...)
|
||||
|
||||
return flags
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user