Skip to content

Commit 7f19839

Browse files
committed
read edition directly from version, enable name validation config
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
1 parent 1fdd76b commit 7f19839

File tree

4 files changed

+28
-41
lines changed

4 files changed

+28
-41
lines changed

opencloud/pkg/command/services.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ import (
4848
web "github.com/opencloud-eu/opencloud/services/web/pkg/command"
4949
webdav "github.com/opencloud-eu/opencloud/services/webdav/pkg/command"
5050
webfinger "github.com/opencloud-eu/opencloud/services/webfinger/pkg/command"
51-
"github.com/urfave/cli/v2"
5251

5352
"github.com/spf13/cobra"
5453
)
@@ -164,7 +163,7 @@ var serviceCommands = []register.Command{
164163
cfg.Notifications.Commons = cfg.Commons
165164
})
166165
},
167-
func(cfg *config.Config) *cli.Command {
166+
func(cfg *config.Config) *cobra.Command {
168167
return ServiceCommand(cfg, cfg.OCM.Service.Name, ocm.GetCommands(cfg.OCM), func(c *config.Config) {
169168
cfg.OCM.Commons = cfg.Commons
170169
})

services/frontend/pkg/config/config.go

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ type Config struct {
3333
EnableFederatedSharingIncoming bool `yaml:"enable_federated_sharing_incoming" env:"OC_ENABLE_OCM;FRONTEND_ENABLE_FEDERATED_SHARING_INCOMING" desc:"Changing this value is NOT supported. Enables support for incoming federated sharing for clients. The backend behaviour is not changed." introductionVersion:"1.0.0"`
3434
EnableFederatedSharingOutgoing bool `yaml:"enable_federated_sharing_outgoing" env:"OC_ENABLE_OCM;FRONTEND_ENABLE_FEDERATED_SHARING_OUTGOING" desc:"Changing this value is NOT supported. Enables support for outgoing federated sharing for clients. The backend behaviour is not changed." introductionVersion:"1.0.0"`
3535
SearchMinLength int `yaml:"search_min_length" env:"FRONTEND_SEARCH_MIN_LENGTH" desc:"Minimum number of characters to enter before a client should start a search for Share receivers. This setting can be used to customize the user experience if e.g too many results are displayed." introductionVersion:"1.0.0"`
36-
Edition string `desc:"Edition of OpenCloud. Used for branding purposes." introductionVersion:"1.0.0"`
3736
DisableSSE bool `yaml:"disable_sse" env:"OC_DISABLE_SSE;FRONTEND_DISABLE_SSE" desc:"When set to true, clients are informed that the Server-Sent Events endpoint is not accessible." introductionVersion:"1.0.0"`
3837
DisableRadicale bool `yaml:"disable_radicale" env:"FRONTEND_DISABLE_RADICALE" desc:"When set to true, clients are informed that the Radicale (CalDAV/CardDAV) is not accessible." introductionVersion:"4.0.0"`
3938
DefaultLinkPermissions int `yaml:"default_link_permissions" env:"FRONTEND_DEFAULT_LINK_PERMISSIONS" desc:"Defines the default permissions a link is being created with. Possible values are 0 (= internal link, for instance members only) and 1 (= public link with viewer permissions). Defaults to 1." introductionVersion:"1.0.0"`
@@ -173,19 +172,14 @@ type OCDav struct {
173172

174173
MachineAuthAPIKey string `yaml:"machine_auth_api_key" env:"OC_MACHINE_AUTH_API_KEY;OCDAV_MACHINE_AUTH_API_KEY" desc:"Machine auth API key used to validate internal requests necessary for the access to resources from other services." introductionVersion:"1.0.0"`
175174

176-
Status Status `yaml:"-"`
177-
178175
AllowPropfindDepthInfinity bool `yaml:"allow_propfind_depth_infinity" env:"OCDAV_ALLOW_PROPFIND_DEPTH_INFINITY" desc:"Allow the use of depth infinity in PROPFINDS. When enabled, a propfind will traverse through all subfolders. If many subfolders are expected, depth infinity can cause heavy server load and/or delayed response times." introductionVersion:"1.0.0"`
176+
177+
NameValidation NameValidation `yaml:"name_validation"`
179178
}
180179

181-
// Status holds the configurable values for the status.php
182-
type Status struct {
183-
Version string
184-
VersionString string
185-
Product string
186-
ProductName string
187-
ProductVersion string
188-
Edition string `yaml:"edition" env:"OC_EDITION;OCDAV_EDITION" desc:"Edition of OpenCloud. Used for branding purposes." introductionVersion:"1.0.0"`
180+
type NameValidation struct {
181+
InvalidChars []string `yaml:"invalid_chars" env:"OCDAV_NAME_VALIDATION_INVALID_CHARS" desc:"List of characters that are not allowed in file or folder names." introductionVersion:"%%NEXT%%"`
182+
MaxLength int `yaml:"max_length" env:"OCDAV_NAME_VALIDATION_MAX_LENGTH" desc:"Max lenght og file or folder names." introductionVersion:"%%NEXT%%"`
189183
}
190184

191185
type CacheWarmupDrivers struct {

services/frontend/pkg/config/defaults/defaultconfig.go

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55

66
"github.com/opencloud-eu/opencloud/pkg/shared"
77
"github.com/opencloud-eu/opencloud/pkg/structs"
8-
"github.com/opencloud-eu/opencloud/pkg/version"
98
"github.com/opencloud-eu/opencloud/services/frontend/pkg/config"
109
)
1110

@@ -88,7 +87,6 @@ func DefaultConfig() *config.Config {
8887
DefaultUploadProtocol: "tus",
8988
DefaultLinkPermissions: 1,
9089
SearchMinLength: 3,
91-
Edition: version.Edition,
9290
CheckForUpdates: true,
9391
Checksums: config.Checksums{
9492
SupportedTypes: []string{"sha1", "md5", "adler32"},
@@ -124,23 +122,19 @@ func DefaultConfig() *config.Config {
124122
Prefix: "",
125123
SkipUserGroupsInToken: false,
126124

127-
WebdavNamespace: "/users/{{.Id.OpaqueId}}",
128-
FilesNamespace: "/users/{{.Id.OpaqueId}}",
129-
SharesNamespace: "/Shares",
130-
OCMNamespace: "/public",
131-
PublicURL: "https://localhost:9200",
132-
Insecure: false,
133-
EnableHTTPTPC: false,
134-
Timeout: 84300,
135-
Status: config.Status{
136-
Version: version.Legacy,
137-
VersionString: version.LegacyString,
138-
ProductVersion: version.GetString(),
139-
Product: "OpenCloud",
140-
ProductName: "OpenCloud",
141-
Edition: "",
142-
},
125+
WebdavNamespace: "/users/{{.Id.OpaqueId}}",
126+
FilesNamespace: "/users/{{.Id.OpaqueId}}",
127+
SharesNamespace: "/Shares",
128+
OCMNamespace: "/public",
129+
PublicURL: "https://localhost:9200",
130+
Insecure: false,
131+
EnableHTTPTPC: false,
132+
Timeout: 84300,
143133
AllowPropfindDepthInfinity: false,
134+
NameValidation: config.NameValidation{
135+
InvalidChars: []string{"\f", "\r", "\n", "\\"},
136+
MaxLength: 255,
137+
},
144138
},
145139
Middleware: config.Middleware{
146140
Auth: config.Auth{

services/frontend/pkg/revaconfig/config.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ func FrontendConfigFromStruct(cfg *config.Config, logger log.Logger) (map[string
209209
"needsDbUpgrade": false,
210210
"version": version.Legacy,
211211
"versionstring": version.LegacyString,
212-
"edition": cfg.Edition,
212+
"edition": version.Edition,
213213
"productname": "OpenCloud",
214214
"product": "OpenCloud",
215215
"productversion": version.GetString(),
@@ -371,16 +371,16 @@ func FrontendConfigFromStruct(cfg *config.Config, logger log.Logger) (map[string
371371
// still not supported
372372
//"favorite_storage_driver": unused,
373373
//"favorite_storage_drivers": unused,
374-
"version": cfg.OCDav.Status.Version,
375-
"version_string": cfg.OCDav.Status.VersionString,
376-
"edition": cfg.OCDav.Status.Edition,
377-
"product": cfg.OCDav.Status.Product,
378-
"product_name": cfg.OCDav.Status.ProductName,
379-
"product_version": cfg.OCDav.Status.ProductVersion,
374+
"version": version.Legacy,
375+
"version_string": version.LegacyString,
376+
"edition": version.Edition,
377+
"product": "OpenCloud",
378+
"product_name": "OpenCloud",
379+
"product_version": version.GetString(),
380380
"allow_depth_infinity": cfg.OCDav.AllowPropfindDepthInfinity,
381-
"validation": map[string]interface{}{
382-
// "invalid_chars": aka ItemNameInvalidChars option ... unused
383-
// "max_length": aka ItemNameMaxLength option ... unused
381+
"validation": map[string]interface{}{
382+
"invalid_chars": cfg.OCDav.NameValidation.InvalidChars,
383+
"max_length": cfg.OCDav.NameValidation.MaxLength,
384384
},
385385
"url_signing_shared_secret": cfg.Commons.URLSigningSecret,
386386
"machine_auth_apikey": cfg.MachineAuthAPIKey,

0 commit comments

Comments
 (0)