github.com/cs3org/reva/v2@v2.27.7/internal/http/services/owncloud/ocs/config/config.go (about) 1 // Copyright 2018-2021 CERN 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 // 15 // In applying this license, CERN does not waive the privileges and immunities 16 // granted to it by virtue of its status as an Intergovernmental Organization 17 // or submit itself to any jurisdiction. 18 19 package config 20 21 import ( 22 "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/data" 23 "github.com/cs3org/reva/v2/pkg/owncloud/ocs" 24 "github.com/cs3org/reva/v2/pkg/sharedconf" 25 "github.com/cs3org/reva/v2/pkg/storage/cache" 26 ) 27 28 // Config holds the config options that need to be passed down to all ocs handlers 29 type Config struct { 30 Prefix string `mapstructure:"prefix"` 31 Config data.ConfigData `mapstructure:"config"` 32 Capabilities ocs.CapabilitiesData `mapstructure:"capabilities"` 33 GatewaySvc string `mapstructure:"gatewaysvc"` 34 StorageregistrySvc string `mapstructure:"storage_registry_svc"` 35 DefaultUploadProtocol string `mapstructure:"default_upload_protocol"` 36 UserAgentChunkingMap map[string]string `mapstructure:"user_agent_chunking_map"` 37 SharePrefix string `mapstructure:"share_prefix"` 38 HomeNamespace string `mapstructure:"home_namespace"` 39 AdditionalInfoAttribute string `mapstructure:"additional_info_attribute"` 40 CacheWarmupDriver string `mapstructure:"cache_warmup_driver"` 41 CacheWarmupDrivers map[string]map[string]interface{} `mapstructure:"cache_warmup_drivers"` 42 StatCacheConfig cache.Config `mapstructure:"stat_cache_config"` 43 UserIdentifierCacheTTL int `mapstructure:"user_identifier_cache_ttl"` 44 MachineAuthAPIKey string `mapstructure:"machine_auth_apikey"` 45 SkipUpdatingExistingSharesMountpoints bool `mapstructure:"skip_updating_existing_shares_mountpoint"` 46 EnableDenials bool `mapstructure:"enable_denials"` 47 OCMMountPoint string `mapstructure:"ocm_mount_point"` 48 ListOCMShares bool `mapstructure:"list_ocm_shares"` 49 Notifications map[string]interface{} `mapstructure:"notifications"` 50 IncludeOCMSharees bool `mapstructure:"include_ocm_sharees"` 51 ShowEmailInResults bool `mapstructure:"show_email_in_results"` 52 } 53 54 // Init sets sane defaults 55 func (c *Config) Init() { 56 if c.Prefix == "" { 57 c.Prefix = "ocs" 58 } 59 60 if c.SharePrefix == "" { 61 c.SharePrefix = "/Shares" 62 } 63 64 if c.DefaultUploadProtocol == "" { 65 c.DefaultUploadProtocol = "tus" 66 } 67 68 if c.HomeNamespace == "" { 69 c.HomeNamespace = "/users/{{.Id.OpaqueId}}" 70 } 71 72 if c.AdditionalInfoAttribute == "" { 73 c.AdditionalInfoAttribute = "{{.Mail}}" 74 } 75 76 if c.UserIdentifierCacheTTL == 0 { 77 c.UserIdentifierCacheTTL = 60 78 } 79 80 c.GatewaySvc = sharedconf.GetGatewaySVC(c.GatewaySvc) 81 }