From b70d720ca441ed81e7c1c7f5e949def4871fa0e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Fri, 28 Jun 2024 14:13:34 +0200 Subject: [PATCH] make gateway endpoints configurable again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- ocis/pkg/runtime/service/service.go | 4 +-- services/gateway/pkg/config/config.go | 29 +++++++++---------- services/storage-system/pkg/config/config.go | 10 ++++--- .../pkg/config/defaults/defaultconfig.go | 7 +++-- .../storage-system/pkg/revaconfig/config.go | 18 ++++++------ 5 files changed, 35 insertions(+), 33 deletions(-) diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index a4f3faa2ff0..4576c1d4695 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -523,7 +523,7 @@ func pingNats(cfg *ociscfg.Config) error { return err } -func pingGateway(_ *ociscfg.Config) error { +func pingGateway(cfg *ociscfg.Config) error { // init grpc connection _, err := ogrpc.NewClient() if err != nil { @@ -533,7 +533,7 @@ func pingGateway(_ *ociscfg.Config) error { b := backoff.NewExponentialBackOff() o := func() error { n := b.NextBackOff() - _, err := pool.GetGatewayServiceClient("com.owncloud.api.gateway") + _, err := pool.GetGatewayServiceClient(cfg.Reva.Address) if err != nil && n > time.Second { logger.New().Error().Err(err).Msgf("can't connect to gateway service, retrying in %s", n) } diff --git a/services/gateway/pkg/config/config.go b/services/gateway/pkg/config/config.go index 73b932de740..b3b6db94330 100644 --- a/services/gateway/pkg/config/config.go +++ b/services/gateway/pkg/config/config.go @@ -29,21 +29,20 @@ type Config struct { TransferExpires int `yaml:"transfer_expires" env:"GATEWAY_TRANSFER_EXPIRES" desc:"Expiry for the gateway tokens." introductionVersion:"pre5.0"` Cache Cache `yaml:"cache"` - FrontendPublicURL string `yaml:"frontend_public_url" env:"OCIS_URL;GATEWAY_FRONTEND_PUBLIC_URL" desc:"The public facing URL of the oCIS frontend." introductionVersion:"pre5.0"` - - UsersEndpoint string `yaml:"-"` - GroupsEndpoint string `yaml:"-"` - PermissionsEndpoint string `yaml:"-"` - SharingEndpoint string `yaml:"-"` - AuthBasicEndpoint string `yaml:"-"` - AuthBearerEndpoint string `yaml:"-"` - AuthMachineEndpoint string `yaml:"-"` - AuthServiceEndpoint string `yaml:"-"` - StoragePublicLinkEndpoint string `yaml:"-"` - StorageUsersEndpoint string `yaml:"-"` - StorageSharesEndpoint string `yaml:"-"` - AppRegistryEndpoint string `yaml:"-"` - OCMEndpoint string `yaml:"-"` + FrontendPublicURL string `yaml:"frontend_public_url" env:"OCIS_URL;GATEWAY_FRONTEND_PUBLIC_URL" desc:"The public facing URL of the oCIS frontend." introductionVersion:"%%NEXT%%"` + UsersEndpoint string `yaml:"users_endpoint" env:"GATEWAY_USERS_ENDPOINT" desc:"The USERS API endpoint." introductionVersion:"%%NEXT%%"` + GroupsEndpoint string `yaml:"groups_endpoint" env:"GATEWAY_GROUPS_ENDPOINT" desc:"The GROUPS API endpoint." introductionVersion:"%%NEXT%%"` + PermissionsEndpoint string `yaml:"permissions_endpoint" env:"GATEWAY_PERMISSIONS_ENDPOINT" desc:"The SETTINGS API endpoint." introductionVersion:"%%NEXT%%"` + SharingEndpoint string `yaml:"sharing_endpoint" env:"GATEWAY_SHARING_ENDPOINT" desc:"The SHARE API endpoint." introductionVersion:"%%NEXT%%"` + AuthBasicEndpoint string `yaml:"auth_basic_endpoint" env:"GATEWAY_AUTH_BASIC_ENDPOINT" desc:"The AUTH BASIC API endpoint." introductionVersion:"%%NEXT%%"` + AuthBearerEndpoint string `yaml:"auth_bearer_endpoint" env:"GATEWAY_AUTH_BEARER_ENDPOINT" desc:"The AUTH BEARER API endpoint." introductionVersion:"%%NEXT%%"` + AuthMachineEndpoint string `yaml:"auth_machine_endpoint" env:"GATEWAY_AUTH_MACHINE_ENDPOINT" desc:"The AUTH MACHINE API endpoint." introductionVersion:"%%NEXT%%"` + AuthServiceEndpoint string `yaml:"auth_service_endpoint" env:"GATEWAY_AUTH_SERVICE_ENDPOINT" desc:"The AUTH SERVICE API endpoint." introductionVersion:"%%NEXT%%"` + StoragePublicLinkEndpoint string `yaml:"storage_public_link_endpoint" env:"GATEWAY_STORAGE_PUBLIC_LINK_ENDPOINT" desc:"The STORAGE PUBLICLINK API endpoint." introductionVersion:"%%NEXT%%"` + StorageUsersEndpoint string `yaml:"storage_users_endpoint" env:"GATEWAY_STORAGE_USERS_ENDPOINT" desc:"The STORAGE USERS API endpoint." introductionVersion:"%%NEXT%%"` + StorageSharesEndpoint string `yaml:"storage_shares_endpoint" env:"GATEWAY_STORAGE_SHARES_ENDPOINT" desc:"The STORAGE SHARES API endpoint." introductionVersion:"%%NEXT%%"` + AppRegistryEndpoint string `yaml:"app_registry_endpoint" env:"GATEWAY_APP_REGISTRY_ENDPOINT" desc:"The APP REGISTRY API endpoint." introductionVersion:"%%NEXT%%"` + OCMEndpoint string `yaml:"ocm_endpoint" env:"GATEWAY_OCM_ENDPOINT" desc:"The OCM API endpoint." introductionVersion:"%%NEXT%%"` StorageRegistry StorageRegistry `yaml:"storage_registry"` // TODO: should we even support switching this? diff --git a/services/storage-system/pkg/config/config.go b/services/storage-system/pkg/config/config.go index 360ac9cc78b..d99e2c1ef2a 100644 --- a/services/storage-system/pkg/config/config.go +++ b/services/storage-system/pkg/config/config.go @@ -18,10 +18,12 @@ type Config struct { GRPC GRPCConfig `yaml:"grpc"` HTTP HTTPConfig `yaml:"http"` - TokenManager *TokenManager `yaml:"token_manager"` - Reva *shared.Reva `yaml:"reva"` - SystemUserID string `yaml:"system_user_id" env:"OCIS_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." introductionVersion:"pre5.0"` - SystemUserAPIKey string `yaml:"system_user_api_key" env:"OCIS_SYSTEM_USER_API_KEY" desc:"API key for the STORAGE-SYSTEM system user." introductionVersion:"pre5.0"` + TokenManager *TokenManager `yaml:"token_manager"` + Reva *shared.Reva `yaml:"reva"` + StorageSystemEndpoint string `yaml:"storage_system_endpoint" env:"STORAGE_SYSTEM_ENDPOINT" desc:"The STORAGE SYSTEM API endpoint." introductionVersion:"%%NEXT%%"` + + SystemUserID string `yaml:"system_user_id" env:"OCIS_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." introductionVersion:"pre5.0"` + SystemUserAPIKey string `yaml:"system_user_api_key" env:"OCIS_SYSTEM_USER_API_KEY" desc:"API key for the STORAGE-SYSTEM system user." introductionVersion:"pre5.0"` SkipUserGroupsInToken bool `yaml:"skip_user_groups_in_token" env:"STORAGE_SYSTEM_SKIP_USER_GROUPS_IN_TOKEN" desc:"Disables the loading of user's group memberships from the reva access token." introductionVersion:"pre5.0"` diff --git a/services/storage-system/pkg/config/defaults/defaultconfig.go b/services/storage-system/pkg/config/defaults/defaultconfig.go index 40f78410ee7..637966a503b 100644 --- a/services/storage-system/pkg/config/defaults/defaultconfig.go +++ b/services/storage-system/pkg/config/defaults/defaultconfig.go @@ -40,9 +40,10 @@ func DefaultConfig() *config.Config { Service: config.Service{ Name: "storage-system", }, - Reva: shared.DefaultRevaConfig(), - DataServerURL: "http://localhost:9216/data", - Driver: "ocis", + Reva: shared.DefaultRevaConfig(), + StorageSystemEndpoint: "com.owncloud.api.storage-system", + DataServerURL: "http://localhost:9216/data", + Driver: "ocis", Drivers: config.Drivers{ OCIS: config.OCISDriver{ MetadataBackend: "messagepack", diff --git a/services/storage-system/pkg/revaconfig/config.go b/services/storage-system/pkg/revaconfig/config.go index 5557552097e..010ff604ae6 100644 --- a/services/storage-system/pkg/revaconfig/config.go +++ b/services/storage-system/pkg/revaconfig/config.go @@ -25,12 +25,12 @@ func StorageSystemFromStruct(cfg *config.Config) map[string]interface{} { "services": map[string]interface{}{ "gateway": map[string]interface{}{ // registries are located on the gateway - "authregistrysvc": "com.owncloud.api.storage-system", - "storageregistrysvc": "com.owncloud.api.storage-system", + "authregistrysvc": cfg.StorageSystemEndpoint, + "storageregistrysvc": cfg.StorageSystemEndpoint, // user metadata is located on the users services - "userprovidersvc": "com.owncloud.api.storage-system", - "groupprovidersvc": "com.owncloud.api.storage-system", - "permissionssvc": "com.owncloud.api.storage-system", + "userprovidersvc": cfg.StorageSystemEndpoint, + "groupprovidersvc": cfg.StorageSystemEndpoint, + "permissionssvc": cfg.StorageSystemEndpoint, // other "disable_home_creation_on_login": true, // metadata manually creates a space // metadata always uses the simple upload, so no transfer secret or datagateway needed @@ -60,7 +60,7 @@ func StorageSystemFromStruct(cfg *config.Config) map[string]interface{} { "drivers": map[string]interface{}{ "static": map[string]interface{}{ "rules": map[string]interface{}{ - "machine": "com.owncloud.api.storage-system", + "machine": cfg.StorageSystemEndpoint, }, }, }, @@ -70,7 +70,7 @@ func StorageSystemFromStruct(cfg *config.Config) map[string]interface{} { "auth_managers": map[string]interface{}{ "machine": map[string]interface{}{ "api_key": cfg.SystemUserAPIKey, - "gateway_addr": "com.owncloud.api.storage-system", + "gateway_addr": cfg.StorageSystemEndpoint, }, }, }, @@ -86,7 +86,7 @@ func StorageSystemFromStruct(cfg *config.Config) map[string]interface{} { "static": map[string]interface{}{ "rules": map[string]interface{}{ "/": map[string]interface{}{ - "address": "com.owncloud.api.storage-system", + "address": cfg.StorageSystemEndpoint, }, }, }, @@ -152,7 +152,7 @@ func metadataDrivers(cfg *config.Config) map[string]interface{} { "user_layout": "{{.Id.OpaqueId}}", "treetime_accounting": false, "treesize_accounting": false, - "permissionssvc": "com.owncloud.api.storage-system", + "permissionssvc": cfg.StorageSystemEndpoint, "max_acquire_lock_cycles": cfg.Drivers.OCIS.MaxAcquireLockCycles, "lock_cycle_duration_factor": cfg.Drivers.OCIS.LockCycleDurationFactor, "statcache": map[string]interface{}{