mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-03-07 21:40:11 -06:00
Merge pull request #4436 from aduffeck/jsoncs3-share-manager
Jsoncs3 share manager
This commit is contained in:
2
go.mod
2
go.mod
@@ -11,7 +11,7 @@ require (
|
||||
github.com/blevesearch/bleve_index_api v1.0.3
|
||||
github.com/coreos/go-oidc/v3 v3.3.0
|
||||
github.com/cs3org/go-cs3apis v0.0.0-20220818202316-e92afdddac6d
|
||||
github.com/cs3org/reva/v2 v2.8.0
|
||||
github.com/cs3org/reva/v2 v2.8.1-0.20220831103032-f4dd66379b55
|
||||
github.com/disintegration/imaging v1.6.2
|
||||
github.com/ggwhite/go-masker v1.0.9
|
||||
github.com/go-chi/chi/v5 v5.0.7
|
||||
|
||||
6
go.sum
6
go.sum
@@ -229,6 +229,8 @@ github.com/bmizerany/pat v0.0.0-20210406213842-e4b6760bdd6f/go.mod h1:8rLXio+Wji
|
||||
github.com/bombsimon/logrusr/v3 v3.0.0 h1:tcAoLfuAhKP9npBxWzSdpsvKPQt1XV02nSf2lZA82TQ=
|
||||
github.com/bombsimon/logrusr/v3 v3.0.0/go.mod h1:PksPPgSFEL2I52pla2glgCyyd2OqOHAnFF5E+g8Ixco=
|
||||
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
|
||||
github.com/butonic/reva/v2 v2.0.0-20220826140044-449144dfb3a7 h1:I4rvghDz9KjpsKdgs9aexXjorXYXbd5cCjHE+zsKNjE=
|
||||
github.com/butonic/reva/v2 v2.0.0-20220826140044-449144dfb3a7/go.mod h1:+BYVpRV8g1hL8wF3+3BunL9BKPsXVyJYmH8COxq/V7Y=
|
||||
github.com/c-bata/go-prompt v0.2.5/go.mod h1:vFnjEGDIIA/Lib7giyE4E9c50Lvl8j0S+7FVlAwDAVw=
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
|
||||
@@ -292,8 +294,8 @@ github.com/crewjam/saml v0.4.6 h1:XCUFPkQSJLvzyl4cW9OvpWUbRf0gE7VUpU8ZnilbeM4=
|
||||
github.com/crewjam/saml v0.4.6/go.mod h1:ZBOXnNPFzB3CgOkRm7Nd6IVdkG+l/wF+0ZXLqD96t1A=
|
||||
github.com/cs3org/go-cs3apis v0.0.0-20220818202316-e92afdddac6d h1:toyZ7IsXlUdEPZ/IG8fg7hbM8HcLPY0bkX4FKBmgLVI=
|
||||
github.com/cs3org/go-cs3apis v0.0.0-20220818202316-e92afdddac6d/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY=
|
||||
github.com/cs3org/reva/v2 v2.8.0 h1:8QtZ3oQB/96yY6GjvjFF73vbM+YAiSmdje41yHrdFms=
|
||||
github.com/cs3org/reva/v2 v2.8.0/go.mod h1:+BYVpRV8g1hL8wF3+3BunL9BKPsXVyJYmH8COxq/V7Y=
|
||||
github.com/cs3org/reva/v2 v2.8.1-0.20220831103032-f4dd66379b55 h1:1hR0P5aZEp/lQepOli1yYdWWwNClgBoCyLK3RARj4B8=
|
||||
github.com/cs3org/reva/v2 v2.8.1-0.20220831103032-f4dd66379b55/go.mod h1:+BYVpRV8g1hL8wF3+3BunL9BKPsXVyJYmH8COxq/V7Y=
|
||||
github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8 h1:Z9lwXumT5ACSmJ7WGnFl+OMLLjpz5uR2fyz7dC255FI=
|
||||
github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8/go.mod h1:4abs/jPXcmJzYoYGF91JF9Uq9s/KL5n1jvFDix8KcqY=
|
||||
github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4=
|
||||
|
||||
@@ -14,10 +14,10 @@ import (
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/config"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/config/configlog"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/config/parser"
|
||||
oclog "github.com/owncloud/ocis/v2/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/v2/ocis/pkg/register"
|
||||
sharing "github.com/owncloud/ocis/v2/services/sharing/pkg/config"
|
||||
sharingparser "github.com/owncloud/ocis/v2/services/sharing/pkg/config/parser"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
@@ -65,7 +65,7 @@ func MigrateShares(cfg *config.Config) *cli.Command {
|
||||
return configlog.ReturnError(sharingparser.ParseConfig(cfg.Sharing))
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
log := zerolog.New(zerolog.ConsoleWriter{Out: os.Stderr}).With().Timestamp().Logger()
|
||||
log := oclog.LoggerFromConfig("migrate", cfg.Log)
|
||||
ctx := log.WithContext(context.Background())
|
||||
rcfg := revaShareConfig(cfg.Sharing)
|
||||
oldDriver := c.String("from")
|
||||
@@ -160,7 +160,7 @@ func MigratePublicShares(cfg *config.Config) *cli.Command {
|
||||
return configlog.ReturnError(sharingparser.ParseConfig(cfg.Sharing))
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
log := zerolog.New(zerolog.ConsoleWriter{Out: os.Stderr}).With().Timestamp().Logger()
|
||||
log := oclog.LoggerFromConfig("migrate", cfg.Log)
|
||||
ctx := log.WithContext(context.Background())
|
||||
|
||||
rcfg := revaPublicShareConfig(cfg.Sharing)
|
||||
@@ -259,6 +259,13 @@ func revaShareConfig(cfg *sharing.Config) map[string]interface{} {
|
||||
"service_user_idp": cfg.UserSharingDrivers.CS3.SystemUserIDP,
|
||||
"machine_auth_apikey": cfg.UserSharingDrivers.CS3.SystemUserAPIKey,
|
||||
},
|
||||
"jsoncs3": map[string]interface{}{
|
||||
"gateway_addr": cfg.UserSharingDrivers.JSONCS3.ProviderAddr,
|
||||
"provider_addr": cfg.UserSharingDrivers.JSONCS3.ProviderAddr,
|
||||
"service_user_id": cfg.UserSharingDrivers.JSONCS3.SystemUserID,
|
||||
"service_user_idp": cfg.UserSharingDrivers.JSONCS3.SystemUserIDP,
|
||||
"machine_auth_apikey": cfg.UserSharingDrivers.JSONCS3.SystemUserAPIKey,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ type GRPCConfig struct {
|
||||
}
|
||||
|
||||
type UserSharingDrivers struct {
|
||||
JSONCS3 UserSharingJSONCS3Driver `yaml:"jsoncs3"`
|
||||
JSON UserSharingJSONDriver `yaml:"json"`
|
||||
CS3 UserSharingCS3Driver `yaml:"cs3"`
|
||||
OwnCloudSQL UserSharingOwnCloudSQLDriver `yaml:"owncloudsql"`
|
||||
@@ -100,6 +101,14 @@ type UserSharingCS3Driver struct {
|
||||
SystemUserAPIKey string `yaml:"system_user_api_key" env:"OCIS_SYSTEM_USER_API_KEY;SHARING_USER_CS3_SYSTEM_USER_API_KEY" desc:"API key for the STORAGE-SYSTEM system user."`
|
||||
}
|
||||
|
||||
// UserSharingJSONCS3Driver holds the jsoncs3 driver config
|
||||
type UserSharingJSONCS3Driver struct {
|
||||
ProviderAddr string `yaml:"provider_addr" env:"SHARING_USER_CS3_PROVIDER_ADDR" desc:"GRPC address of the STORAGE-SYSTEM service."`
|
||||
SystemUserID string `yaml:"system_user_id" env:"OCIS_SYSTEM_USER_ID;SHARING_USER_CS3_SYSTEM_USER_ID" desc:"ID of the oCIS STORAGE-SYSTEM system user. Admins need to set the ID for the STORAGE-SYSTEM system user in this config option which is then used to reference the user. Any reasonable long string is possible, preferably this would be an UUIDv4 format."`
|
||||
SystemUserIDP string `yaml:"system_user_idp" env:"OCIS_SYSTEM_USER_IDP;SHARING_USER_CS3_SYSTEM_USER_IDP" desc:"IDP of the oCIS STORAGE-SYSTEM system user."`
|
||||
SystemUserAPIKey string `yaml:"system_user_api_key" env:"OCIS_SYSTEM_USER_API_KEY;SHARING_USER_CS3_SYSTEM_USER_API_KEY" desc:"API key for the STORAGE-SYSTEM system user."`
|
||||
}
|
||||
|
||||
type PublicSharingDrivers struct {
|
||||
JSON PublicSharingJSONDriver `yaml:"json"`
|
||||
CS3 PublicSharingCS3Driver `yaml:"cs3"`
|
||||
|
||||
@@ -33,7 +33,7 @@ func DefaultConfig() *config.Config {
|
||||
Reva: &config.Reva{
|
||||
Address: "127.0.0.1:9142",
|
||||
},
|
||||
UserSharingDriver: "cs3",
|
||||
UserSharingDriver: "jsoncs3",
|
||||
UserSharingDrivers: config.UserSharingDrivers{
|
||||
JSON: config.UserSharingJSONDriver{
|
||||
File: filepath.Join(defaults.BaseDataPath(), "storage", "shares.json"),
|
||||
@@ -42,6 +42,10 @@ func DefaultConfig() *config.Config {
|
||||
ProviderAddr: "127.0.0.1:9215", // system storage
|
||||
SystemUserIDP: "internal",
|
||||
},
|
||||
JSONCS3: config.UserSharingJSONCS3Driver{
|
||||
ProviderAddr: "127.0.0.1:9215", // system storage
|
||||
SystemUserIDP: "internal",
|
||||
},
|
||||
OwnCloudSQL: config.UserSharingOwnCloudSQLDriver{
|
||||
DBUsername: "owncloud",
|
||||
DBHost: "mysql",
|
||||
@@ -115,6 +119,14 @@ func EnsureDefaults(cfg *config.Config) {
|
||||
cfg.UserSharingDrivers.CS3.SystemUserID = cfg.Commons.SystemUserID
|
||||
}
|
||||
|
||||
if cfg.UserSharingDrivers.JSONCS3.SystemUserAPIKey == "" && cfg.Commons != nil && cfg.Commons.SystemUserAPIKey != "" {
|
||||
cfg.UserSharingDrivers.JSONCS3.SystemUserAPIKey = cfg.Commons.SystemUserAPIKey
|
||||
}
|
||||
|
||||
if cfg.UserSharingDrivers.JSONCS3.SystemUserID == "" && cfg.Commons != nil && cfg.Commons.SystemUserID != "" {
|
||||
cfg.UserSharingDrivers.JSONCS3.SystemUserID = cfg.Commons.SystemUserID
|
||||
}
|
||||
|
||||
if cfg.PublicSharingDrivers.CS3.SystemUserAPIKey == "" && cfg.Commons != nil && cfg.Commons.SystemUserAPIKey != "" {
|
||||
cfg.PublicSharingDrivers.CS3.SystemUserAPIKey = cfg.Commons.SystemUserAPIKey
|
||||
}
|
||||
|
||||
@@ -56,6 +56,13 @@ func SharingConfigFromStruct(cfg *config.Config) map[string]interface{} {
|
||||
"service_user_idp": cfg.UserSharingDrivers.CS3.SystemUserIDP,
|
||||
"machine_auth_apikey": cfg.UserSharingDrivers.CS3.SystemUserAPIKey,
|
||||
},
|
||||
"jsoncs3": map[string]interface{}{
|
||||
"gateway_addr": cfg.UserSharingDrivers.JSONCS3.ProviderAddr,
|
||||
"provider_addr": cfg.UserSharingDrivers.JSONCS3.ProviderAddr,
|
||||
"service_user_id": cfg.UserSharingDrivers.JSONCS3.SystemUserID,
|
||||
"service_user_idp": cfg.UserSharingDrivers.JSONCS3.SystemUserIDP,
|
||||
"machine_auth_apikey": cfg.UserSharingDrivers.JSONCS3.SystemUserAPIKey,
|
||||
},
|
||||
},
|
||||
},
|
||||
"publicshareprovider": map[string]interface{}{
|
||||
|
||||
Reference in New Issue
Block a user