From 1f68321acc2341ddf9167bbeda0f9ee2058916f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Fri, 9 Sep 2022 13:04:46 +0200 Subject: [PATCH] Add support for the jsoncs3 public share manager --- ocis/pkg/command/migrate.go | 7 +++++++ services/sharing/pkg/config/config.go | 15 ++++++++++++--- .../sharing/pkg/config/defaults/defaultconfig.go | 4 ++++ services/sharing/pkg/revaconfig/config.go | 7 +++++++ 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/ocis/pkg/command/migrate.go b/ocis/pkg/command/migrate.go index 4aa2889fd3..56df5ac867 100644 --- a/ocis/pkg/command/migrate.go +++ b/ocis/pkg/command/migrate.go @@ -275,6 +275,13 @@ func revaPublicShareConfig(cfg *sharing.Config) map[string]interface{} { "file": cfg.PublicSharingDrivers.JSON.File, "gateway_addr": cfg.Reva.Address, }, + "jsoncs3": map[string]interface{}{ + "gateway_addr": cfg.PublicSharingDrivers.JSONCS3.ProviderAddr, + "provider_addr": cfg.PublicSharingDrivers.JSONCS3.ProviderAddr, + "service_user_id": cfg.PublicSharingDrivers.JSONCS3.SystemUserID, + "service_user_idp": cfg.PublicSharingDrivers.JSONCS3.SystemUserIDP, + "machine_auth_apikey": cfg.PublicSharingDrivers.JSONCS3.SystemUserAPIKey, + }, "sql": map[string]interface{}{ "db_username": cfg.PublicSharingDrivers.SQL.DBUsername, "db_password": cfg.PublicSharingDrivers.SQL.DBPassword, diff --git a/services/sharing/pkg/config/config.go b/services/sharing/pkg/config/config.go index fc285665c2..f9f0913625 100644 --- a/services/sharing/pkg/config/config.go +++ b/services/sharing/pkg/config/config.go @@ -110,8 +110,9 @@ type UserSharingJSONCS3Driver struct { } type PublicSharingDrivers struct { - JSON PublicSharingJSONDriver `yaml:"json"` - CS3 PublicSharingCS3Driver `yaml:"cs3"` + JSON PublicSharingJSONDriver `yaml:"json"` + CS3 PublicSharingCS3Driver `yaml:"cs3"` + JSONCS3 PublicSharingJSONCS3Driver `yaml:"jsoncs3"` SQL PublicSharingSQLDriver `yaml:"sql,omitempty"` // not supported by the oCIS product, therefore not part of docs } @@ -136,7 +137,15 @@ type PublicSharingCS3Driver struct { ProviderAddr string `yaml:"provider_addr" env:"SHARING_PUBLIC_CS3_PROVIDER_ADDR" desc:"GRPC address of the STORAGE-SYSTEM service."` SystemUserID string `yaml:"system_user_id" env:"OCIS_SYSTEM_USER_ID;SHARING_PUBLIC_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_PUBLIC_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."` + SystemUserAPIKey string `yaml:"system_user_api_key" env:"OCIS_SYSTEM_USER_API_KEY;SHARING_PUBLIC_CS3_SYSTEM_USER_API_KEY" desc:"API key for the STORAGE-SYSTEM system user."` +} + +// PublicSharingJSONCS3Driver holds the jsoncs3 driver config +type PublicSharingJSONCS3Driver struct { + ProviderAddr string `yaml:"provider_addr" env:"SHARING_PUBLIC_CS3_PROVIDER_ADDR" desc:"GRPC address of the STORAGE-SYSTEM service."` + SystemUserID string `yaml:"system_user_id" env:"OCIS_SYSTEM_USER_ID;SHARING_PUBLIC_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_PUBLIC_CS3_SYSTEM_USER_ID" desc:"IDP of the oCIS STORAGE-SYSTEM system user."` + SystemUserAPIKey string `yaml:"system_user_api_key" env:"OCIS_SYSTEM_USER_API_KEY;SHARING_PUBLIC_CS3_SYSTEM_USER_API_KEY" desc:"API key for the STORAGE-SYSTEM system user."` } type Events struct { diff --git a/services/sharing/pkg/config/defaults/defaultconfig.go b/services/sharing/pkg/config/defaults/defaultconfig.go index 7590e28690..668e532127 100644 --- a/services/sharing/pkg/config/defaults/defaultconfig.go +++ b/services/sharing/pkg/config/defaults/defaultconfig.go @@ -62,6 +62,10 @@ func DefaultConfig() *config.Config { ProviderAddr: "127.0.0.1:9215", // system storage SystemUserIDP: "internal", }, + JSONCS3: config.PublicSharingJSONCS3Driver{ + ProviderAddr: "127.0.0.1:9215", // system storage + SystemUserIDP: "internal", + }, // TODO implement and add owncloudsql publicshare driver }, Events: config.Events{ diff --git a/services/sharing/pkg/revaconfig/config.go b/services/sharing/pkg/revaconfig/config.go index 926c84e3b7..2ecc3ade3d 100644 --- a/services/sharing/pkg/revaconfig/config.go +++ b/services/sharing/pkg/revaconfig/config.go @@ -89,6 +89,13 @@ func SharingConfigFromStruct(cfg *config.Config) map[string]interface{} { "service_user_idp": cfg.PublicSharingDrivers.CS3.SystemUserIDP, "machine_auth_apikey": cfg.PublicSharingDrivers.CS3.SystemUserAPIKey, }, + "jsoncs3": map[string]interface{}{ + "gateway_addr": cfg.PublicSharingDrivers.JSONCS3.ProviderAddr, + "provider_addr": cfg.PublicSharingDrivers.JSONCS3.ProviderAddr, + "service_user_id": cfg.PublicSharingDrivers.JSONCS3.SystemUserID, + "service_user_idp": cfg.PublicSharingDrivers.JSONCS3.SystemUserIDP, + "machine_auth_apikey": cfg.PublicSharingDrivers.JSONCS3.SystemUserAPIKey, + }, }, }, },