diff --git a/ocis-pkg/config/config.go b/ocis-pkg/config/config.go index cbb79bcb33..a334797fc3 100644 --- a/ocis-pkg/config/config.go +++ b/ocis-pkg/config/config.go @@ -115,7 +115,7 @@ func New() *Config { Store: store.DefaultConfig(), Thumbnails: thumbnails.DefaultConfig(), WebDAV: webdav.DefaultConfig(), - Storage: storage.New(), + Storage: storage.DefaultConfig(), } } @@ -160,7 +160,7 @@ func DefaultConfig() *Config { Store: store.DefaultConfig(), Thumbnails: thumbnails.DefaultConfig(), WebDAV: webdav.DefaultConfig(), - Storage: storage.New(), + Storage: storage.DefaultConfig(), } } diff --git a/storage/cmd/storage/main.go b/storage/cmd/storage/main.go index 2eaed0e963..78ccf99eca 100644 --- a/storage/cmd/storage/main.go +++ b/storage/cmd/storage/main.go @@ -8,7 +8,7 @@ import ( ) func main() { - if err := command.Execute(config.New()); err != nil { + if err := command.Execute(config.DefaultConfig()); err != nil { os.Exit(1) } } diff --git a/storage/pkg/command/appprovider.go b/storage/pkg/command/appprovider.go index 07abdc79be..a4d4b24a22 100644 --- a/storage/pkg/command/appprovider.go +++ b/storage/pkg/command/appprovider.go @@ -12,7 +12,6 @@ import ( ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/sync" "github.com/owncloud/ocis/storage/pkg/config" - "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/thejerf/suture/v4" @@ -24,11 +23,11 @@ func AppProvider(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "app-provider", Usage: "Start appprovider for providing apps", - Flags: flagset.AppProviderWithConfig(cfg), + //Flags: flagset.AppProviderWithConfig(cfg), Before: func(c *cli.Context) error { cfg.Reva.AppProvider.Services = c.StringSlice("service") - return nil + return ParseConfig(c, cfg, "storage-app-provider") }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) diff --git a/storage/pkg/command/authbasic.go b/storage/pkg/command/authbasic.go index 35ec897373..2bb7ff3af5 100644 --- a/storage/pkg/command/authbasic.go +++ b/storage/pkg/command/authbasic.go @@ -13,7 +13,6 @@ import ( ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/sync" "github.com/owncloud/ocis/storage/pkg/config" - "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/thejerf/suture/v4" @@ -25,11 +24,11 @@ func AuthBasic(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "auth-basic", Usage: "Start authprovider for basic auth", - Flags: flagset.AuthBasicWithConfig(cfg), + //Flags: flagset.AuthBasicWithConfig(cfg), Before: func(c *cli.Context) error { cfg.Reva.AuthBasic.Services = c.StringSlice("service") - return nil + return ParseConfig(c, cfg, "storage-auth-basic") }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) diff --git a/storage/pkg/command/authbearer.go b/storage/pkg/command/authbearer.go index beaf9b37b6..95270e0139 100644 --- a/storage/pkg/command/authbearer.go +++ b/storage/pkg/command/authbearer.go @@ -12,7 +12,6 @@ import ( ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/sync" "github.com/owncloud/ocis/storage/pkg/config" - "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/thejerf/suture/v4" @@ -24,11 +23,11 @@ func AuthBearer(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "auth-bearer", Usage: "Start authprovider for bearer auth", - Flags: flagset.AuthBearerWithConfig(cfg), + //Flags: flagset.AuthBearerWithConfig(cfg), Before: func(c *cli.Context) error { cfg.Reva.AuthBearer.Services = c.StringSlice("service") - return nil + return ParseConfig(c, cfg, "storage-auth-bearer") }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) diff --git a/storage/pkg/command/authmachine.go b/storage/pkg/command/authmachine.go index 8b6ea05bb4..50df131765 100644 --- a/storage/pkg/command/authmachine.go +++ b/storage/pkg/command/authmachine.go @@ -12,7 +12,6 @@ import ( ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/sync" "github.com/owncloud/ocis/storage/pkg/config" - "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/thejerf/suture/v4" @@ -24,11 +23,11 @@ func AuthMachine(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "auth-machine", Usage: "Start authprovider for machine auth", - Flags: flagset.AuthMachineWithConfig(cfg), + //Flags: flagset.AuthMachineWithConfig(cfg), Before: func(c *cli.Context) error { cfg.Reva.AuthMachine.Services = c.StringSlice("service") - return nil + return ParseConfig(c, cfg, "storage-auth-machine") }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) diff --git a/storage/pkg/command/frontend.go b/storage/pkg/command/frontend.go index aefd4f5722..208d7dd442 100644 --- a/storage/pkg/command/frontend.go +++ b/storage/pkg/command/frontend.go @@ -16,7 +16,6 @@ import ( "github.com/owncloud/ocis/ocis-pkg/conversions" "github.com/owncloud/ocis/ocis-pkg/sync" "github.com/owncloud/ocis/storage/pkg/config" - "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/thejerf/suture/v4" @@ -28,11 +27,14 @@ func Frontend(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "frontend", Usage: "Start frontend service", - Flags: flagset.FrontendWithConfig(cfg), + //Flags: flagset.FrontendWithConfig(cfg), Before: func(c *cli.Context) error { cfg.Reva.Frontend.Services = c.StringSlice("service") cfg.Reva.ChecksumSupportedTypes = c.StringSlice("checksum-supported-type") - return loadUserAgent(c, cfg) + if err := loadUserAgent(c, cfg); err != nil { + return err + } + return ParseConfig(c, cfg, "storage-frontend") }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) diff --git a/storage/pkg/command/gateway.go b/storage/pkg/command/gateway.go index 9b1ec57176..ede3f43a63 100644 --- a/storage/pkg/command/gateway.go +++ b/storage/pkg/command/gateway.go @@ -9,21 +9,19 @@ import ( "path" "strings" - "github.com/mitchellh/mapstructure" - "github.com/owncloud/ocis/storage/pkg/tracing" - - "github.com/owncloud/ocis/ocis-pkg/sync" - "github.com/owncloud/ocis/ocis-pkg/version" - "github.com/cs3org/reva/cmd/revad/runtime" "github.com/gofrs/uuid" + "github.com/mitchellh/mapstructure" "github.com/oklog/run" ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/log" + "github.com/owncloud/ocis/ocis-pkg/shared" + "github.com/owncloud/ocis/ocis-pkg/sync" + "github.com/owncloud/ocis/ocis-pkg/version" "github.com/owncloud/ocis/storage/pkg/config" - "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" "github.com/owncloud/ocis/storage/pkg/service/external" + "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" ) @@ -33,7 +31,7 @@ func Gateway(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "gateway", Usage: "Start gateway", - Flags: flagset.GatewayWithConfig(cfg), + //Flags: flagset.GatewayWithConfig(cfg), Before: func(c *cli.Context) error { cfg.Reva.Gateway.Services = c.StringSlice("service") cfg.Reva.StorageRegistry.Rules = c.StringSlice("storage-registry-rule") @@ -42,7 +40,7 @@ func Gateway(cfg *config.Config) *cli.Command { cfg.Reva.DataGateway.PublicURL = strings.TrimRight(cfg.Reva.Frontend.PublicURL, "/") + "/data" } - return nil + return ParseConfig(c, cfg, "storage-gatway") }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) @@ -222,11 +220,12 @@ func rules(cfg *config.Config, logger log.Logger) map[string]map[string]interfac // generate rules based on default config return map[string]map[string]interface{}{ - cfg.Reva.StorageHome.MountPath: {"address": cfg.Reva.StorageHome.Endpoint}, - cfg.Reva.StorageHome.MountID: {"address": cfg.Reva.StorageHome.Endpoint}, - cfg.Reva.StorageUsers.MountPath: {"address": cfg.Reva.StorageUsers.Endpoint}, - cfg.Reva.StorageUsers.MountID + ".*": {"address": cfg.Reva.StorageUsers.Endpoint}, - cfg.Reva.StoragePublicLink.MountPath: {"address": cfg.Reva.StoragePublicLink.Endpoint}, + cfg.Reva.StorageHome.MountPath: {"address": cfg.Reva.StorageHome.Endpoint}, + // this is an ugly hack. Why is it here in the first place? + "1284d238-aa92-42ce-bdc4-0b0000009154": {"address": cfg.Reva.StorageHome.Endpoint}, + cfg.Reva.StorageUsers.MountPath: {"address": cfg.Reva.StorageUsers.Endpoint}, + cfg.Reva.StorageUsers.MountID + ".*": {"address": cfg.Reva.StorageUsers.Endpoint}, + cfg.Reva.StoragePublicLink.MountPath: {"address": cfg.Reva.StoragePublicLink.Endpoint}, // public link storage returns the mount id of the actual storage // medatada storage not part of the global namespace } @@ -378,3 +377,29 @@ func (s GatewaySutureService) Serve(ctx context.Context) error { return nil } + +// ParseConfig loads accounts configuration from known paths. +func ParseConfig(c *cli.Context, cfg *config.Config, storageExtension string) error { + conf, err := ociscfg.BindSourcesToStructs(storageExtension, cfg) + if err != nil { + return err + } + + // provide with defaults for shared logging, since we need a valid destination address for BindEnv. + if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { + cfg.Log = &shared.Log{ + Level: cfg.Commons.Log.Level, + Pretty: cfg.Commons.Log.Pretty, + Color: cfg.Commons.Log.Color, + File: cfg.Commons.Log.File, + } + } else if cfg.Log == nil && cfg.Commons == nil { + cfg.Log = &shared.Log{} + } + + // load all env variables relevant to the config in the current context. + conf.LoadOSEnv(config.GetEnv(cfg), false) + + bindings := config.StructMappings(cfg) + return ociscfg.BindEnv(conf, bindings) +} diff --git a/storage/pkg/command/groups.go b/storage/pkg/command/groups.go index 318386082d..0acb622cf3 100644 --- a/storage/pkg/command/groups.go +++ b/storage/pkg/command/groups.go @@ -13,7 +13,6 @@ import ( ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/sync" "github.com/owncloud/ocis/storage/pkg/config" - "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/thejerf/suture/v4" @@ -25,11 +24,11 @@ func Groups(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "groups", Usage: "Start groups service", - Flags: flagset.GroupsWithConfig(cfg), + //Flags: flagset.GroupsWithConfig(cfg), Before: func(c *cli.Context) error { cfg.Reva.Groups.Services = c.StringSlice("service") - return nil + return ParseConfig(c, cfg, "storage-groups") }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) diff --git a/storage/pkg/command/root.go b/storage/pkg/command/root.go index 4c526e06a4..4ac235e8cc 100644 --- a/storage/pkg/command/root.go +++ b/storage/pkg/command/root.go @@ -2,14 +2,10 @@ package command import ( "os" - "strings" - - "github.com/owncloud/ocis/ocis-pkg/shared" "github.com/owncloud/ocis/ocis-pkg/log" "github.com/owncloud/ocis/ocis-pkg/version" "github.com/owncloud/ocis/storage/pkg/config" - "github.com/spf13/viper" "github.com/urfave/cli/v2" ) @@ -28,49 +24,7 @@ func Execute(cfg *config.Config) error { }, }, Before: func(c *cli.Context) error { - if cfg.Log == nil { - cfg.Log = &shared.Log{} - } - - logger := NewLogger(cfg) - - viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) - viper.SetEnvPrefix("STORAGE") - viper.AutomaticEnv() - - if c.IsSet("config-file") { - viper.SetConfigFile(c.String("config-file")) - } else { - viper.SetConfigName("storage") - - viper.AddConfigPath("/etc/ocis") - viper.AddConfigPath("$HOME/.ocis") - viper.AddConfigPath("./config") - } - - if err := viper.ReadInConfig(); err != nil { - switch err.(type) { - case viper.ConfigFileNotFoundError: - logger.Debug(). - Msg("no config found on preconfigured location") - case viper.UnsupportedConfigError: - logger.Fatal(). - Err(err). - Msg("unsupported config type") - default: - logger.Fatal(). - Err(err). - Msg("failed to read config") - } - } - - if err := viper.Unmarshal(&cfg); err != nil { - logger.Fatal(). - Err(err). - Msg("failed to parse config") - } - - return nil + return ParseConfig(c, cfg, "storage") }, Commands: []*cli.Command{ diff --git a/storage/pkg/command/sharing.go b/storage/pkg/command/sharing.go index 6a71e5b22a..692631b58b 100644 --- a/storage/pkg/command/sharing.go +++ b/storage/pkg/command/sharing.go @@ -16,7 +16,6 @@ import ( "github.com/oklog/run" ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/storage/pkg/config" - "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" "github.com/thejerf/suture/v4" "github.com/urfave/cli/v2" @@ -27,11 +26,11 @@ func Sharing(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "sharing", Usage: "Start sharing service", - Flags: flagset.SharingWithConfig(cfg), + //Flags: flagset.SharingWithConfig(cfg), Before: func(c *cli.Context) error { cfg.Reva.Sharing.Services = c.StringSlice("service") - return nil + return ParseConfig(c, cfg, "storage-sharing") }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) diff --git a/storage/pkg/command/storagehome.go b/storage/pkg/command/storagehome.go index 5d4e6d5a4b..72772be555 100644 --- a/storage/pkg/command/storagehome.go +++ b/storage/pkg/command/storagehome.go @@ -14,7 +14,6 @@ import ( ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/storage/pkg/command/storagedrivers" "github.com/owncloud/ocis/storage/pkg/config" - "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/thejerf/suture/v4" @@ -26,11 +25,11 @@ func StorageHome(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "storage-home", Usage: "Start storage-home service", - Flags: flagset.StorageHomeWithConfig(cfg), + //Flags: flagset.StorageHomeWithConfig(cfg), Before: func(c *cli.Context) error { cfg.Reva.StorageHome.Services = c.StringSlice("service") - return nil + return ParseConfig(c, cfg, "storage-home") }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) diff --git a/storage/pkg/command/storagemetadata.go b/storage/pkg/command/storagemetadata.go index a853c68fb6..74864e2c68 100644 --- a/storage/pkg/command/storagemetadata.go +++ b/storage/pkg/command/storagemetadata.go @@ -15,7 +15,6 @@ import ( "github.com/owncloud/ocis/ocis-pkg/version" "github.com/owncloud/ocis/storage/pkg/command/storagedrivers" "github.com/owncloud/ocis/storage/pkg/config" - "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" "github.com/owncloud/ocis/storage/pkg/service/external" "github.com/owncloud/ocis/storage/pkg/tracing" @@ -31,7 +30,10 @@ func StorageMetadata(cfg *config.Config) *cli.Command { Name: "storage-metadata", Usage: "Start storage-metadata service", // TODO(refs) at this point it might make sense delegate log flags to each individual storage command. - Flags: flagset.StorageMetadata(cfg), + //Flags: flagset.StorageMetadata(cfg), + Before: func(c *cli.Context) error { + return ParseConfig(c, cfg, "storage-metadata") + }, Category: "Extensions", Action: func(c *cli.Context) error { logger := NewLogger(cfg) diff --git a/storage/pkg/command/storagepubliclink.go b/storage/pkg/command/storagepubliclink.go index eb3803e504..467749aa03 100644 --- a/storage/pkg/command/storagepubliclink.go +++ b/storage/pkg/command/storagepubliclink.go @@ -12,7 +12,6 @@ import ( ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/sync" "github.com/owncloud/ocis/storage/pkg/config" - "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/thejerf/suture/v4" @@ -22,9 +21,12 @@ import ( // StoragePublicLink is the entrypoint for the reva-storage-public-link command. func StoragePublicLink(cfg *config.Config) *cli.Command { return &cli.Command{ - Name: "storage-public-link", - Usage: "Start storage-public-link service", - Flags: flagset.StoragePublicLink(cfg), + Name: "storage-public-link", + Usage: "Start storage-public-link service", + //Flags: flagset.StoragePublicLink(cfg), + Before: func(c *cli.Context) error { + return ParseConfig(c, cfg, "storage-public-link") + }, Category: "Extensions", Action: func(c *cli.Context) error { logger := NewLogger(cfg) diff --git a/storage/pkg/command/storageusers.go b/storage/pkg/command/storageusers.go index d86d49b53c..996655502b 100644 --- a/storage/pkg/command/storageusers.go +++ b/storage/pkg/command/storageusers.go @@ -13,7 +13,6 @@ import ( "github.com/owncloud/ocis/ocis-pkg/sync" "github.com/owncloud/ocis/storage/pkg/command/storagedrivers" "github.com/owncloud/ocis/storage/pkg/config" - "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/thejerf/suture/v4" @@ -25,11 +24,11 @@ func StorageUsers(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "storage-users", Usage: "Start storage-users service", - Flags: flagset.StorageUsersWithConfig(cfg), + //Flags: flagset.StorageUsersWithConfig(cfg), Before: func(c *cli.Context) error { cfg.Reva.StorageHome.Services = c.StringSlice("service") - return nil + return ParseConfig(c, cfg, "storage-userprovider") }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) diff --git a/storage/pkg/command/users.go b/storage/pkg/command/users.go index 6bc2bdc608..7f2cf88d9a 100644 --- a/storage/pkg/command/users.go +++ b/storage/pkg/command/users.go @@ -13,7 +13,6 @@ import ( ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/sync" "github.com/owncloud/ocis/storage/pkg/config" - "github.com/owncloud/ocis/storage/pkg/flagset" "github.com/owncloud/ocis/storage/pkg/server/debug" "github.com/owncloud/ocis/storage/pkg/tracing" "github.com/thejerf/suture/v4" @@ -25,11 +24,11 @@ func Users(cfg *config.Config) *cli.Command { return &cli.Command{ Name: "users", Usage: "Start users service", - Flags: flagset.UsersWithConfig(cfg), + //Flags: flagset.UsersWithConfig(cfg), Before: func(c *cli.Context) error { cfg.Reva.Users.Services = c.StringSlice("service") - return nil + return ParseConfig(c, cfg, "storage-users") }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) diff --git a/storage/pkg/config/config.go b/storage/pkg/config/config.go index 19c45739b5..fef2ec62fc 100644 --- a/storage/pkg/config/config.go +++ b/storage/pkg/config/config.go @@ -2,238 +2,241 @@ package config import ( "context" + "os" + "path" + + "github.com/owncloud/ocis/ocis-pkg/config/defaults" "github.com/owncloud/ocis/ocis-pkg/shared" ) // Log defines the available logging configuration. type Log struct { - Level string - Pretty bool - Color bool - File string + Level string `mapstructure:"level"` + Pretty bool `mapstructure:"pretty"` + Color bool `mapstructure:"color"` + File string `mapstructure:"file"` } // Debug defines the available debug configuration. type Debug struct { - Addr string - Token string - Pprof bool - Zpages bool + Addr string `mapstructure:"addr"` + Token string `mapstructure:"token"` + Pprof bool `mapstructure:"pprof"` + Zpages bool `mapstructure:"zpages"` } // Gateway defines the available gateway configuration. type Gateway struct { Port - CommitShareToStorageGrant bool - CommitShareToStorageRef bool - DisableHomeCreationOnLogin bool - ShareFolder string - LinkGrants string - HomeMapping string - EtagCacheTTL int + CommitShareToStorageGrant bool `mapstructure:"commit_share_to_storage_grant"` + CommitShareToStorageRef bool `mapstructure:"commit_share_to_storage_ref"` + DisableHomeCreationOnLogin bool `mapstructure:"disable_home_creation_on_login"` + ShareFolder string `mapstructure:"share_folder"` + LinkGrants string `mapstructure:"link_grants"` + HomeMapping string `mapstructure:"home_mapping"` + EtagCacheTTL int `mapstructure:"etag_cache_ttl"` } // StorageRegistry defines the available storage registry configuration type StorageRegistry struct { - Driver string + Driver string `mapstructure:"driver"` // HomeProvider is the path in the global namespace that the static storage registry uses to determine the home storage - HomeProvider string - Rules []string - JSON string + HomeProvider string `mapstructure:"home_provider"` + Rules []string `mapstructure:"rules"` + JSON string `mapstructure:"json"` } // AppRegistry defines the available app registry configuration type AppRegistry struct { - Driver string - MimetypesJSON string + Driver string `mapstructure:"driver"` + MimetypesJSON string `mapstructure:"mime_types_json"` } // AppProvider defines the available app provider configuration type AppProvider struct { Port - ExternalAddr string - Driver string - WopiDriver WopiDriver - AppsURL string - OpenURL string + ExternalAddr string `mapstructure:"external_addr"` + Driver string `mapstructure:"driver"` + WopiDriver WopiDriver `mapstructure:"wopi_driver"` + AppsURL string `mapstructure:"apps_url"` + OpenURL string `mapstructure:"open_url"` } type WopiDriver struct { - AppAPIKey string - AppDesktopOnly bool - AppIconURI string - AppInternalURL string - AppName string - AppURL string - Insecure bool - IopSecret string - JWTSecret string - WopiURL string + AppAPIKey string `mapstructure:"app_api_key"` + AppDesktopOnly bool `mapstructure:"app_desktop_only"` + AppIconURI string `mapstructure:"app_icon_uri"` + AppInternalURL string `mapstructure:"app_internal_url"` + AppName string `mapstructure:"app_name"` + AppURL string `mapstructure:"app_url"` + Insecure bool `mapstructure:"insecure"` + IopSecret string `mapstructure:"ipo_secret"` + JWTSecret string `mapstructure:"jwt_secret"` + WopiURL string `mapstructure:"wopi_url"` } // Sharing defines the available sharing configuration. type Sharing struct { Port - UserDriver string - UserJSONFile string - UserSQLUsername string - UserSQLPassword string - UserSQLHost string - UserSQLPort int - UserSQLName string - PublicDriver string - PublicJSONFile string - PublicPasswordHashCost int - PublicEnableExpiredSharesCleanup bool - PublicJanitorRunInterval int - UserStorageMountID string + UserDriver string `mapstructure:"user_driver"` + UserJSONFile string `mapstructure:"user_json_file"` + UserSQLUsername string `mapstructure:"user_sql_username"` + UserSQLPassword string `mapstructure:"user_sql_password"` + UserSQLHost string `mapstructure:"user_sql_host"` + UserSQLPort int `mapstructure:"user_sql_port"` + UserSQLName string `mapstructure:"user_sql_name"` + PublicDriver string `mapstructure:"public_driver"` + PublicJSONFile string `mapstructure:"public_json_file"` + PublicPasswordHashCost int `mapstructure:"public_password_hash_cost"` + PublicEnableExpiredSharesCleanup bool `mapstructure:"public_enable_expired_shares_cleanup"` + PublicJanitorRunInterval int `mapstructure:"public_janitor_run_interval"` + UserStorageMountID string `mapstructure:"user_storage_mount_id"` } // Port defines the available port configuration. type Port struct { // MaxCPUs can be a number or a percentage - MaxCPUs string - LogLevel string + MaxCPUs string `mapstructure:"max_cpus"` + LogLevel string `mapstructure:"log_level"` // GRPCNetwork can be tcp, udp or unix - GRPCNetwork string + GRPCNetwork string `mapstructure:"grpc_network"` // GRPCAddr to listen on, hostname:port (0.0.0.0:9999 for all interfaces) or socket (/var/run/reva/sock) - GRPCAddr string + GRPCAddr string `mapstructure:"grpc_addr"` // Protocol can be grpc or http // HTTPNetwork can be tcp, udp or unix - HTTPNetwork string + HTTPNetwork string `mapstructure:"http_network"` // HTTPAddr to listen on, hostname:port (0.0.0.0:9100 for all interfaces) or socket (/var/run/reva/sock) - HTTPAddr string + HTTPAddr string `mapstructure:"http_addr"` // Protocol can be grpc or http - Protocol string + Protocol string `mapstructure:"protocol"` // Endpoint is used by the gateway and registries (eg localhost:9100 or cloud.example.com) - Endpoint string + Endpoint string `mapstructure:"endpoint"` // DebugAddr for the debug endpoint to bind to - DebugAddr string + DebugAddr string `mapstructure:"debug_addr"` // Services can be used to give a list of services that should be started on this port - Services []string + Services []string `mapstructure:"services"` // Config can be used to configure the reva instance. // Services and Protocol will be ignored if this is used - Config map[string]interface{} + Config map[string]interface{} `mapstructure:"config"` // Context allows for context cancellation and propagation Context context.Context // Supervised is used when running under an oCIS runtime supervision tree - Supervised bool + Supervised bool // deprecated } // Users defines the available users configuration. type Users struct { Port - Driver string - JSON string - UserGroupsCacheExpiration int + Driver string `mapstucture:"driver"` + JSON string `mapstucture:"json"` + UserGroupsCacheExpiration int `mapstucture:"user_groups_cache_expiration"` } // AuthMachineConfig defines the available configuration for the machine auth driver. type AuthMachineConfig struct { - MachineAuthAPIKey string + MachineAuthAPIKey string `mapstucture:"machine_auth_api_key"` } // Groups defines the available groups configuration. type Groups struct { Port - Driver string - JSON string - GroupMembersCacheExpiration int + Driver string `mapstucture:"driver"` + JSON string `mapstucture:"json"` + GroupMembersCacheExpiration int `mapstucture:"group_members_cache_expiration"` } // FrontendPort defines the available frontend configuration. type FrontendPort struct { Port - AppProviderInsecure bool - AppProviderPrefix string - ArchiverInsecure bool - ArchiverPrefix string - DatagatewayPrefix string - Favorites bool - OCDavInsecure bool - OCDavPrefix string - OCSPrefix string - OCSSharePrefix string - OCSHomeNamespace string - PublicURL string - OCSCacheWarmupDriver string - OCSAdditionalInfoAttribute string - OCSResourceInfoCacheTTL int - Middleware Middleware + AppProviderInsecure bool `mapstucture:"app_provider_insecure"` + AppProviderPrefix string `mapstucture:"app_provider_prefix"` + ArchiverInsecure bool `mapstucture:"archiver_insecure"` + ArchiverPrefix string `mapstucture:"archiver_prefix"` + DatagatewayPrefix string `mapstucture:"data_gateway_prefix"` + Favorites bool `mapstucture:"favorites"` + OCDavInsecure bool `mapstucture:"ocdav_insecure"` + OCDavPrefix string `mapstucture:"ocdav_prefix"` + OCSPrefix string `mapstucture:"ocs_prefix"` + OCSSharePrefix string `mapstucture:"ocs_share_prefix"` + OCSHomeNamespace string `mapstucture:"ocs_home_namespace"` + PublicURL string `mapstucture:"public_url"` + OCSCacheWarmupDriver string `mapstucture:"ocs_cache_warmup_driver"` + OCSAdditionalInfoAttribute string `mapstucture:"ocs_additional_info_attribute"` + OCSResourceInfoCacheTTL int `mapstucture:"ocs_resource_info_cache_ttl"` + Middleware Middleware `mapstucture:"middleware"` } // Middleware configures reva middlewares. type Middleware struct { - Auth Auth + Auth Auth `mapstructure:"auth"` } // Auth configures reva http auth middleware. type Auth struct { - CredentialsByUserAgent map[string]string + CredentialsByUserAgent map[string]string `mapstructure:"credentials_by_user_agenr"` } // DataGatewayPort has a public url type DataGatewayPort struct { Port - PublicURL string + PublicURL string `mapstructure:""` } type DataProvider struct { - Insecure bool + Insecure bool `mapstructure:"insecure"` } // StoragePort defines the available storage configuration. type StoragePort struct { Port - Driver string - MountPath string - MountID string - ExposeDataServer bool + Driver string `mapstructure:"driver"` + MountPath string `mapstructure:"mount_path"` + MountID string `mapstructure:"mount_id"` + ExposeDataServer bool `mapstructure:"expose_data_server"` // url the data gateway will use to route requests - DataServerURL string + DataServerURL string `mapstructure:"data_server_url"` // for HTTP ports with only one http service - HTTPPrefix string - TempFolder string - ReadOnly bool - DataProvider DataProvider + HTTPPrefix string `mapstructure:"http_prefix"` + TempFolder string `mapstructure:"temp_folder"` + ReadOnly bool `mapstructure:"read_only"` + DataProvider DataProvider `mapstructure:"data_provider"` } // PublicStorage configures a public storage provider type PublicStorage struct { StoragePort - PublicShareProviderAddr string - UserProviderAddr string + PublicShareProviderAddr string `mapstructure:"public_share_provider_addr"` + UserProviderAddr string `mapstructure:"user_provider_addr"` } // StorageConfig combines all available storage driver configuration parts. type StorageConfig struct { - EOS DriverEOS - Local DriverCommon - OwnCloud DriverOwnCloud - OwnCloudSQL DriverOwnCloudSQL - S3 DriverS3 - S3NG DriverS3NG - OCIS DriverOCIS - // TODO checksums ... figure out what that is supposed to do + EOS DriverEOS `mapstructure:"eos"` + Local DriverCommon `mapstructure:"local"` + OwnCloud DriverOwnCloud `mapstructure:"owncloud"` + OwnCloudSQL DriverOwnCloudSQL `mapstructure:"owncloud_sql"` + S3 DriverS3 `mapstructure:"s3"` + S3NG DriverS3NG `mapstructure:"s3ng"` + OCIS DriverOCIS `mapstructure:"ocis"` } // DriverCommon defines common driver configuration options. type DriverCommon struct { // Root is the absolute path to the location of the data - Root string + Root string `mapstructure:"root"` //ShareFolder defines the name of the folder jailing all shares - ShareFolder string + ShareFolder string `mapstructure:"share_folder"` // UserLayout contains the template used to construct // the internal path, eg: `{{substr 0 1 .Username}}/{{.Username}}` - UserLayout string + UserLayout string `mapstructure:"user_layout"` // EnableHome enables the creation of home directories. - EnableHome bool + EnableHome bool `mapstructure:"enable_home"` } // DriverEOS defines the available EOS driver configuration. @@ -241,276 +244,754 @@ type DriverEOS struct { DriverCommon // ShadowNamespace for storing shadow data - ShadowNamespace string + ShadowNamespace string `mapstructure:"shadow_namespace"` // UploadsNamespace for storing upload data - UploadsNamespace string + UploadsNamespace string `mapstructure:"uploads_namespace"` // Location of the eos binary. // Default is /usr/bin/eos. - EosBinary string + EosBinary string `mapstructure:"eos_binary"` // Location of the xrdcopy binary. // Default is /usr/bin/xrdcopy. - XrdcopyBinary string + XrdcopyBinary string `mapstructure:"xrd_copy_binary"` // URL of the Master EOS MGM. // Default is root://eos-example.org - MasterURL string + MasterURL string `mapstructure:"master_url"` // URI of the EOS MGM grpc server // Default is empty - GrpcURI string + GrpcURI string `mapstructure:"grpc_uri"` // URL of the Slave EOS MGM. // Default is root://eos-example.org - SlaveURL string + SlaveURL string `mapstructure:"slave_url"` // Location on the local fs where to store reads. // Defaults to os.TempDir() - CacheDirectory string + CacheDirectory string `mapstructure:"cache_directory"` // Enables logging of the commands executed // Defaults to false - EnableLogging bool + EnableLogging bool `mapstructure:"enable_logging"` // ShowHiddenSysFiles shows internal EOS files like // .sys.v# and .sys.a# files. - ShowHiddenSysFiles bool + ShowHiddenSysFiles bool `mapstructure:"shadow_hidden_files"` // ForceSingleUserMode will force connections to EOS to use SingleUsername - ForceSingleUserMode bool + ForceSingleUserMode bool `mapstructure:"force_single_user_mode"` // UseKeyTabAuth changes will authenticate requests by using an EOS keytab. - UseKeytab bool + UseKeytab bool `mapstructure:"user_keytab"` // SecProtocol specifies the xrootd security protocol to use between the server and EOS. - SecProtocol string + SecProtocol string `mapstructure:"sec_protocol"` // Keytab specifies the location of the keytab to use to authenticate to EOS. - Keytab string + Keytab string `mapstructure:"keytab"` // SingleUsername is the username to use when SingleUserMode is enabled - SingleUsername string + SingleUsername string `mapstructure:"single_username"` // gateway service to use for uid lookups - GatewaySVC string + GatewaySVC string `mapstructure:"gateway_svc"` } // DriverOCIS defines the available oCIS storage driver configuration. type DriverOCIS struct { DriverCommon - ServiceUserUUID string + ServiceUserUUID string `mapstructure:"service_user_uuid"` } // DriverOwnCloud defines the available ownCloud storage driver configuration. type DriverOwnCloud struct { DriverCommon - UploadInfoDir string - Redis string - Scan bool + UploadInfoDir string `mapstructure:"upload_info_dir"` + Redis string `mapstructure:"redis"` + Scan bool `mapstructure:"scan"` } // DriverOwnCloudSQL defines the available ownCloudSQL storage driver configuration. type DriverOwnCloudSQL struct { DriverCommon - UploadInfoDir string - DBUsername string - DBPassword string - DBHost string - DBPort int - DBName string + UploadInfoDir string `mapstructure:"upload_info_dir"` + DBUsername string `mapstructure:"db_username"` + DBPassword string `mapstructure:"db_password"` + DBHost string `mapstructure:"db_host"` + DBPort int `mapstructure:"db_port"` + DBName string `mapstructure:"db_name"` } // DriverS3 defines the available S3 storage driver configuration. type DriverS3 struct { DriverCommon - Region string - AccessKey string - SecretKey string - Endpoint string - Bucket string + Region string `mapstructure:"region"` + AccessKey string `mapstructure:"access_key"` + SecretKey string `mapstructure:"secret_key"` + Endpoint string `mapstructure:"endpoint"` + Bucket string `mapstructure:"bucket"` } // DriverS3NG defines the available s3ng storage driver configuration. type DriverS3NG struct { DriverCommon - Region string - AccessKey string - SecretKey string - Endpoint string - Bucket string + Region string `mapstructure:"region"` + AccessKey string `mapstructure:"access_key"` + SecretKey string `mapstructure:"secret_key"` + Endpoint string `mapstructure:"endpoint"` + Bucket string `mapstructure:"bucket"` } // OIDC defines the available OpenID Connect configuration. type OIDC struct { - Issuer string - Insecure bool - IDClaim string - UIDClaim string - GIDClaim string + Issuer string `mapstructure:"issuer"` + Insecure bool `mapstructure:"insecure"` + IDClaim string `mapstructure:"id_claim"` + UIDClaim string `mapstructure:"uid_claim"` + GIDClaim string `mapstructure:"gid_claim"` } // LDAP defines the available ldap configuration. type LDAP struct { - Hostname string - Port int - CACert string - Insecure bool - BaseDN string - LoginFilter string - UserFilter string - UserAttributeFilter string - UserFindFilter string - UserGroupFilter string - GroupFilter string - GroupAttributeFilter string - GroupFindFilter string - GroupMemberFilter string - BindDN string - BindPassword string - IDP string - UserSchema LDAPUserSchema - GroupSchema LDAPGroupSchema + Hostname string `mapstructure:"hostname"` + Port int `mapstructure:"port"` + CACert string `mapstructure:"ca_cert"` + Insecure bool `mapstructure:"insecure"` + BaseDN string `mapstructure:"base_dn"` + LoginFilter string `mapstructure:"login_filter"` + UserFilter string `mapstructure:"user_filter"` + UserAttributeFilter string `mapstructure:"user_attribute_filter"` + UserFindFilter string `mapstructure:"user_find_filter"` + UserGroupFilter string `mapstructure:"user_group_filter"` + GroupFilter string `mapstructure:"group_filter"` + GroupAttributeFilter string `mapstructure:"group_attribute_filter"` + GroupFindFilter string `mapstructure:"group_finder_filter"` + GroupMemberFilter string `mapstructure:"group_member_filter"` + BindDN string `mapstructure:"bind_dn"` + BindPassword string `mapstructure:"bind_password"` + IDP string `mapstructure:"idp"` + UserSchema LDAPUserSchema `mapstructure:"user_schema"` + GroupSchema LDAPGroupSchema `mapstructure:"group_schema"` } // UserGroupRest defines the REST driver specification for user and group resolution. type UserGroupRest struct { - ClientID string - ClientSecret string - RedisAddress string - RedisUsername string - RedisPassword string - IDProvider string - APIBaseURL string - OIDCTokenEndpoint string - TargetAPI string + ClientID string `mapstructure:"client_id"` + ClientSecret string `mapstructure:"client_secret"` + RedisAddress string `mapstructure:"redis_address"` + RedisUsername string `mapstructure:"redis_username"` + RedisPassword string `mapstructure:"redis_password"` + IDProvider string `mapstructure:"idp_provider"` + APIBaseURL string `mapstructure:"api_base_url"` + OIDCTokenEndpoint string `mapstructure:"oidc_token_endpoint"` + TargetAPI string `mapstructure:"target_api"` } // UserOwnCloudSQL defines the available ownCloudSQL user provider configuration. type UserOwnCloudSQL struct { - DBUsername string - DBPassword string - DBHost string - DBPort int - DBName string - Idp string - Nobody int64 - JoinUsername bool - JoinOwnCloudUUID bool - EnableMedialSearch bool + DBUsername string `mapstructure:"db_username"` + DBPassword string `mapstructure:"db_password"` + DBHost string `mapstructure:"db_host"` + DBPort int `mapstructure:"db_port"` + DBName string `mapstructure:"db_name"` + Idp string `mapstructure:"idp"` + Nobody int64 `mapstructure:"nobody"` + JoinUsername bool `mapstructure:"join_username"` + JoinOwnCloudUUID bool `mapstructure:"join_owncloud_uuid"` + EnableMedialSearch bool `mapstructure:"enable_medial_search"` } // LDAPUserSchema defines the available ldap user schema configuration. type LDAPUserSchema struct { - UID string - Mail string - DisplayName string - CN string - UIDNumber string - GIDNumber string + UID string `mapstructure:"uid"` + Mail string `mapstructure:"mail"` + DisplayName string `mapstructure:"display_name"` + CN string `mapstructure:"cn"` + UIDNumber string `mapstructure:"uid_number"` + GIDNumber string `mapstructure:"gid_number"` } // LDAPGroupSchema defines the available ldap group schema configuration. type LDAPGroupSchema struct { - GID string - Mail string - DisplayName string - CN string - GIDNumber string + GID string `mapstructure:"gid"` + Mail string `mapstructure:"mail"` + DisplayName string `mapstructure:"display_name"` + CN string `mapstructure:"cn"` + GIDNumber string `mapstructure:"gid_number"` } // OCDav defines the available ocdav configuration. type OCDav struct { - WebdavNamespace string - DavFilesNamespace string + WebdavNamespace string `mapstructure:"webdav_namespace"` + DavFilesNamespace string `mapstructure:"dav_files_namespace"` } // Archiver defines the available archiver configuration. type Archiver struct { - MaxNumFiles int64 - MaxSize int64 - ArchiverURL string + MaxNumFiles int64 `mapstructure:"max_num_files"` + MaxSize int64 `mapstructure:"max_size"` + ArchiverURL string `mapstructure:"archiver_url"` } // Reva defines the available reva configuration. type Reva struct { // JWTSecret used to sign jwt tokens between services - JWTSecret string - SkipUserGroupsInToken bool - TransferSecret string - TransferExpires int - OIDC OIDC - LDAP LDAP - UserGroupRest UserGroupRest - UserOwnCloudSQL UserOwnCloudSQL - OCDav OCDav - Archiver Archiver - UserStorage StorageConfig - MetadataStorage StorageConfig + JWTSecret string `mapstructure:"jwt_secret"` + SkipUserGroupsInToken bool `mapstructure:"skip_user_grooups_in_token"` + TransferSecret string `mapstructure:"transfer_secret"` + TransferExpires int `mapstructure:"transfer_expires"` + OIDC OIDC `mapstructure:"oidc"` + LDAP LDAP `mapstructure:"ldap"` + UserGroupRest UserGroupRest `mapstructure:"user_group_rest"` + UserOwnCloudSQL UserOwnCloudSQL `mapstructure:"user_owncloud_sql"` + OCDav OCDav `mapstructure:"ocdav"` + Archiver Archiver `mapstructure:"archiver"` + UserStorage StorageConfig `mapstructure:"user_storage"` + MetadataStorage StorageConfig `mapstructure:"metadata_storage"` // Ports are used to configure which services to start on which port - Frontend FrontendPort - DataGateway DataGatewayPort - Gateway Gateway - StorageRegistry StorageRegistry - AppRegistry AppRegistry - Users Users - Groups Groups - AuthProvider Users - AuthBasic Port - AuthBearer Port - AuthMachine Port - AuthMachineConfig AuthMachineConfig - Sharing Sharing - StorageHome StoragePort - StorageUsers StoragePort - StoragePublicLink PublicStorage - StorageMetadata StoragePort - AppProvider AppProvider + Frontend FrontendPort `mapstructure:"frontend"` + DataGateway DataGatewayPort `mapstructure:"data_gateway"` + Gateway Gateway `mapstructure:"gateway"` + StorageRegistry StorageRegistry `mapstructure:"storage_registry"` + AppRegistry AppRegistry `mapstructure:"app_registry"` + Users Users `mapstructure:"users"` + Groups Groups `mapstructure:"groups"` + AuthProvider Users `mapstructure:"auth_provider"` + AuthBasic Port `mapstructure:"auth_basic"` + AuthBearer Port `mapstructure:"auth_bearer"` + AuthMachine Port `mapstructure:"auth_machine"` + AuthMachineConfig AuthMachineConfig `mapstructure:"auth_machine_config"` + Sharing Sharing `mapstructure:"sharing"` + StorageHome StoragePort `mapstructure:"storage_home"` + StorageUsers StoragePort `mapstructure:"storage_users"` + StoragePublicLink PublicStorage `mapstructure:"storage_public_link"` + StorageMetadata StoragePort `mapstructure:"storage_metadata"` + AppProvider AppProvider `mapstructure:"app_provider"` // Configs can be used to configure the reva instance. // Services and Ports will be ignored if this is used - Configs map[string]interface{} + Configs map[string]interface{} `mapstructure:"configs"` // chunking and resumable upload config (TUS) - UploadMaxChunkSize int - UploadHTTPMethodOverride string + UploadMaxChunkSize int `mapstructure:"uppload_max_chunk_size"` + UploadHTTPMethodOverride string `mapstructure:"upload_http_method_override"` // checksumming capabilities - ChecksumSupportedTypes []string - ChecksumPreferredUploadType string - DefaultUploadProtocol string + ChecksumSupportedTypes []string `mapstructure:"checksum_supported_types"` + ChecksumPreferredUploadType string `mapstructure:"checksum_preferred_upload_type"` + DefaultUploadProtocol string `mapstructure:"default_upload_protocol"` } // Tracing defines the available tracing configuration. type Tracing struct { - Enabled bool - Type string - Endpoint string - Collector string - Service string + Enabled bool `mapstructure:"enabled"` + Type string `mapstructure:"type"` + Endpoint string `mapstructure:"endpoint"` + Collector string `mapstructure:"collector"` + Service string `mapstructure:"service"` } // Asset defines the available asset configuration. type Asset struct { - Path string + Path string `mapstructure:"path"` } // Config combines all available configuration parts. type Config struct { *shared.Commons - File string - Log *shared.Log - Debug Debug - Reva Reva - Tracing Tracing - Asset Asset + File string `mapstructure:"file"` + Log *shared.Log `mapstructure:"log"` + Debug Debug `mapstructure:"debug"` + Reva Reva `mapstructure:"reva"` + Tracing Tracing `mapstructure:"tracing"` + Asset Asset `mapstructure:"asset"` } // New initializes a new configuration with or without defaults. func New() *Config { return &Config{} } + +func DefaultConfig() *Config { + return &Config{ + // log is inherited + Debug: Debug{ + Addr: "127.0.0.1:9109", + }, + Reva: Reva{ + JWTSecret: "Pive-Fumkiu4", + SkipUserGroupsInToken: false, + TransferSecret: "replace-me-with-a-transfer-secret", + TransferExpires: 24 * 60 * 60, + OIDC: OIDC{ + Issuer: "https://localhost:9200", + Insecure: false, + IDClaim: "preferred_username", + }, + LDAP: LDAP{ + Hostname: "localhost", + Port: 9126, + CACert: path.Join(defaults.BaseDataPath(), "ldap", "ldap.crt"), + Insecure: false, + BaseDN: "dc=ocis,dc=test", + LoginFilter: "(&(objectclass=posixAccount)(|(cn={{login}})(mail={{login}})))", + UserFilter: "(&(objectclass=posixAccount)(|(ownclouduuid={{.OpaqueId}})(cn={{.OpaqueId}})))", + UserAttributeFilter: "(&(objectclass=posixAccount)({{attr}}={{value}}))", + UserFindFilter: "(&(objectclass=posixAccount)(|(cn={{query}}*)(displayname={{query}}*)(mail={{query}}*)))", + UserGroupFilter: "(&(objectclass=posixGroup)(ownclouduuid={{.OpaqueId}}*))", + GroupFilter: "(&(objectclass=posixGroup)(|(ownclouduuid={{.OpaqueId}})(cn={{.OpaqueId}})))", + GroupAttributeFilter: "(&(objectclass=posixGroup)({{attr}}={{value}}))", + GroupFindFilter: "(&(objectclass=posixGroup)(|(cn={{query}}*)(displayname={{query}}*)(mail={{query}}*)))", + GroupMemberFilter: "(&(objectclass=posixAccount)(ownclouduuid={{.OpaqueId}}*))", + BindDN: "cn=reva,ou=sysusers,dc=ocis,dc=test", + BindPassword: "reva", + IDP: "https://localhost:9200", + UserSchema: LDAPUserSchema{ + UID: "ownclouduuid", + Mail: "mail", + DisplayName: "displayname", + CN: "cn", + UIDNumber: "uidnumber", + GIDNumber: "gidnumber", + }, + GroupSchema: LDAPGroupSchema{ + GID: "cn", + Mail: "mail", + DisplayName: "cn", + CN: "cn", + GIDNumber: "gidnumber", + }, + }, + UserGroupRest: UserGroupRest{ + RedisAddress: "localhost:6379", + }, + UserOwnCloudSQL: UserOwnCloudSQL{ + DBUsername: "owncloud", + DBPassword: "secret", + DBHost: "mysql", + DBPort: 3306, + DBName: "owncloud", + Idp: "https://localhost:9200", + Nobody: 90, + JoinUsername: false, + JoinOwnCloudUUID: false, + EnableMedialSearch: false, + }, + OCDav: OCDav{ + WebdavNamespace: "/home/", + DavFilesNamespace: "/users/", + }, + Archiver: Archiver{ + MaxNumFiles: 10000, + MaxSize: 1073741824, + ArchiverURL: "/archiver", + }, + UserStorage: StorageConfig{ + EOS: DriverEOS{ + DriverCommon: DriverCommon{ + Root: "/eos/dockertest/reva", + ShareFolder: "/Shares", + UserLayout: "{{substr 0 1 .Username}}/{{.Username}}", + }, + ShadowNamespace: "", // Defaults to path.Join(c.Namespace, ".shadow") + UploadsNamespace: "", // Defaults to path.Join(c.Namespace, ".uploads") + EosBinary: "/usr/bin/eos", + XrdcopyBinary: "/usr/bin/xrdcopy", + MasterURL: "root://eos-mgm1.eoscluster.cern.ch:1094", + SlaveURL: "root://eos-mgm1.eoscluster.cern.ch:1094", + CacheDirectory: os.TempDir(), + GatewaySVC: "127.0.0.1:9142", + }, + Local: DriverCommon{ + Root: path.Join(defaults.BaseDataPath(), "storage", "local", "users"), + ShareFolder: "/Shares", + UserLayout: "{{.Username}}", + EnableHome: false, + }, + OwnCloud: DriverOwnCloud{ + DriverCommon: DriverCommon{ + Root: path.Join(defaults.BaseDataPath(), "storage", "owncloud"), + ShareFolder: "/Shares", + UserLayout: "{{.Id.OpaqueId}}", + EnableHome: false, + }, + UploadInfoDir: path.Join(defaults.BaseDataPath(), "storage", "uploadinfo"), + Redis: ":6379", + Scan: true, + }, + OwnCloudSQL: DriverOwnCloudSQL{ + DriverCommon: DriverCommon{ + Root: path.Join(defaults.BaseDataPath(), "storage", "owncloud"), + ShareFolder: "/Shares", + UserLayout: "{{.Username}}", + EnableHome: false, + }, + UploadInfoDir: path.Join(defaults.BaseDataPath(), "storage", "uploadinfo"), + DBUsername: "owncloud", + DBPassword: "owncloud", + DBHost: "", + DBPort: 3306, + DBName: "owncloud", + }, + S3: DriverS3{ + DriverCommon: DriverCommon{}, + Region: "default", + AccessKey: "", + SecretKey: "", + Endpoint: "", + Bucket: "", + }, + S3NG: DriverS3NG{ + DriverCommon: DriverCommon{ + Root: path.Join(defaults.BaseDataPath(), "storage", "users"), + ShareFolder: "/Shares", + UserLayout: "{{.Id.OpaqueId}}", + EnableHome: false, + }, + Region: "default", + AccessKey: "", + SecretKey: "", + Endpoint: "", + Bucket: "", + }, + OCIS: DriverOCIS{ + DriverCommon: DriverCommon{ + Root: path.Join(defaults.BaseDataPath(), "storage", "users"), + ShareFolder: "/Shares", + UserLayout: "{{.Id.OpaqueId}}", + }, + ServiceUserUUID: "95cb8724-03b2-11eb-a0a6-c33ef8ef53ad", + }, + }, + MetadataStorage: StorageConfig{ + EOS: DriverEOS{ + DriverCommon: DriverCommon{ + Root: "/eos/dockertest/reva", + ShareFolder: "/Shares", + UserLayout: "{{substr 0 1 .Username}}/{{.Username}}", + EnableHome: false, + }, + ShadowNamespace: "", + UploadsNamespace: "", + EosBinary: "/usr/bin/eos", + XrdcopyBinary: "/usr/bin/xrdcopy", + MasterURL: "root://eos-mgm1.eoscluster.cern.ch:1094", + GrpcURI: "", + SlaveURL: "root://eos-mgm1.eoscluster.cern.ch:1094", + CacheDirectory: os.TempDir(), + EnableLogging: false, + ShowHiddenSysFiles: false, + ForceSingleUserMode: false, + UseKeytab: false, + SecProtocol: "", + Keytab: "", + SingleUsername: "", + GatewaySVC: "127.0.0.1:9142", + }, + Local: DriverCommon{ + Root: path.Join(defaults.BaseDataPath(), "storage", "local", "metadata"), + }, + OwnCloud: DriverOwnCloud{}, + OwnCloudSQL: DriverOwnCloudSQL{}, + S3: DriverS3{ + DriverCommon: DriverCommon{}, + Region: "default", + }, + S3NG: DriverS3NG{ + DriverCommon: DriverCommon{ + Root: path.Join(defaults.BaseDataPath(), "storage", "metadata"), + ShareFolder: "", + UserLayout: "{{.Id.OpaqueId}}", + EnableHome: false, + }, + Region: "default", + }, + OCIS: DriverOCIS{ + DriverCommon: DriverCommon{ + Root: path.Join(defaults.BaseDataPath(), "storage", "metadata"), + ShareFolder: "", + UserLayout: "{{.Id.OpaqueId}}", + EnableHome: false, + }, + ServiceUserUUID: "95cb8724-03b2-11eb-a0a6-c33ef8ef53ad", + }, + }, + Frontend: FrontendPort{ + Port: Port{ + MaxCPUs: "", + LogLevel: "", + GRPCNetwork: "", + GRPCAddr: "", + HTTPNetwork: "tcp", + HTTPAddr: "127.0.0.1:9140", + Protocol: "", + Endpoint: "", + DebugAddr: "127.0.0.1:9141", + Services: nil, + Config: nil, + Context: nil, + Supervised: false, + }, + AppProviderInsecure: false, + AppProviderPrefix: "", + ArchiverInsecure: false, + ArchiverPrefix: "archiver", + DatagatewayPrefix: "data", + Favorites: false, + OCDavInsecure: false, + OCDavPrefix: "", + OCSPrefix: "ocs", + OCSSharePrefix: "/Shares", + OCSHomeNamespace: "/home", + PublicURL: "https://localhost:9200", + OCSCacheWarmupDriver: "", + OCSAdditionalInfoAttribute: "{{.Mail}}", + OCSResourceInfoCacheTTL: 0, + Middleware: Middleware{}, + }, + DataGateway: DataGatewayPort{ + Port: Port{}, + PublicURL: "", + }, + Gateway: Gateway{ + Port: Port{ + Endpoint: "127.0.0.1:9142", + DebugAddr: "127.0.0.1:9143", + GRPCNetwork: "tcp", + GRPCAddr: "127.0.0.1:9142", + }, + CommitShareToStorageGrant: true, + CommitShareToStorageRef: true, + DisableHomeCreationOnLogin: false, + ShareFolder: "Shares", + LinkGrants: "", + HomeMapping: "", + EtagCacheTTL: 0, + }, + StorageRegistry: StorageRegistry{ + Driver: "static", + HomeProvider: "/home", + JSON: "", + }, + AppRegistry: AppRegistry{ + Driver: "static", + MimetypesJSON: "", + }, + Users: Users{ + Port: Port{ + Endpoint: "localhost:9144", + GRPCNetwork: "tcp", + GRPCAddr: "127.0.0.1:9144", + }, + Driver: "ldap", + UserGroupsCacheExpiration: 5, + }, + Groups: Groups{ + Port: Port{ + Endpoint: "localhost:9160", + DebugAddr: "127.0.0.1:9161", + GRPCNetwork: "tcp", + GRPCAddr: "127.0.0.1:9160", + }, + Driver: "ldap", + GroupMembersCacheExpiration: 5, + }, + AuthProvider: Users{ + Port: Port{}, + Driver: "ldap", + UserGroupsCacheExpiration: 0, + }, + AuthBasic: Port{ + GRPCNetwork: "tcp", + GRPCAddr: "127.0.0.1:9146", + DebugAddr: "127.0.0.1:9147", + }, + AuthBearer: Port{ + GRPCNetwork: "tcp", + GRPCAddr: "127.0.0.1:9148", + DebugAddr: "127.0.0.1:9149", + }, + AuthMachine: Port{ + GRPCNetwork: "tcp", + GRPCAddr: "127.0.0.1:9166", + DebugAddr: "127.0.0.1:9167", + }, + AuthMachineConfig: AuthMachineConfig{ + MachineAuthAPIKey: "change-me-please", + }, + Sharing: Sharing{ + Port: Port{ + Endpoint: "localhost:9150", + DebugAddr: "127.0.0.1:9151", + GRPCNetwork: "tcp", + GRPCAddr: "127.0.0.1:9150", + }, + UserDriver: "json", + UserJSONFile: path.Join(defaults.BaseDataPath(), "storage", "shares.json"), + UserSQLUsername: "", + UserSQLPassword: "", + UserSQLHost: "", + UserSQLPort: 1433, + UserSQLName: "", + PublicDriver: "json", + PublicJSONFile: path.Join(defaults.BaseDataPath(), "storage", "publicshares.json"), + PublicPasswordHashCost: 11, + PublicEnableExpiredSharesCleanup: true, + PublicJanitorRunInterval: 60, + UserStorageMountID: "", + }, + StorageHome: StoragePort{ + Port: Port{ + Endpoint: "localhost:9154", + DebugAddr: "127.0.0.1:9156", + GRPCNetwork: "tcp", + GRPCAddr: "127.0.0.1:9154", + HTTPNetwork: "tcp", + HTTPAddr: "127.0.0.1:9155", + }, + Driver: "ocis", + ReadOnly: false, + MountPath: "/home", + MountID: "1284d238-aa92-42ce-bdc4-0b0000009157", + DataServerURL: "http://localhost:9155/data", + HTTPPrefix: "data", + TempFolder: path.Join(defaults.BaseDataPath(), "tmp", "home"), + }, + StorageUsers: StoragePort{ + Port: Port{ + Endpoint: "localhost:9157", + DebugAddr: "127.0.0.1:9159", + GRPCNetwork: "tcp", + GRPCAddr: "127.0.0.1:9157", + HTTPNetwork: "tcp", + HTTPAddr: "127.0.0.1:9158", + }, + MountPath: "/users", + MountID: "1284d238-aa92-42ce-bdc4-0b0000009157", + Driver: "ocis", + DataServerURL: "http://localhost:9158/data", + HTTPPrefix: "data", + TempFolder: path.Join(defaults.BaseDataPath(), "tmp", "users"), + }, + StoragePublicLink: PublicStorage{ + StoragePort: StoragePort{ + Port: Port{ + Endpoint: "localhost:9178", + DebugAddr: "127.0.0.1:9179", + GRPCNetwork: "tcp", + GRPCAddr: "127.0.0.1:9178", + }, + MountPath: "/public", + }, + PublicShareProviderAddr: "", + UserProviderAddr: "", + }, + StorageMetadata: StoragePort{ + Port: Port{ + GRPCNetwork: "tcp", + GRPCAddr: "127.0.0.1:9215", + HTTPNetwork: "tcp", + HTTPAddr: "127.0.0.1:9216", + DebugAddr: "127.0.0.1:9217", + }, + Driver: "ocis", + ExposeDataServer: false, + DataServerURL: "http://localhost:9216", + TempFolder: path.Join(defaults.BaseDataPath(), "tmp", "metadata"), + DataProvider: DataProvider{}, + }, + AppProvider: AppProvider{ + Port: Port{ + GRPCNetwork: "tcp", + GRPCAddr: "127.0.0.1:9164", + DebugAddr: "127.0.0.1:9165", + Endpoint: "localhost:9164", + }, + ExternalAddr: "127.0.0.1:9164", + WopiDriver: WopiDriver{}, + AppsURL: "/app/list", + OpenURL: "/app/open", + }, + Configs: nil, + UploadMaxChunkSize: 1e+8, + UploadHTTPMethodOverride: "", + ChecksumSupportedTypes: nil, + ChecksumPreferredUploadType: "", + DefaultUploadProtocol: "tus", + }, + Tracing: Tracing{ + Service: "storage", + Type: "jaeger", + }, + Asset: Asset{}, + } +} + +// StructMappings binds a set of environment variables to a destination on cfg. Iterating over this set and editing the +// Destination value of a binding will alter the original value, as it is a pointer to its memory address. This lets +// us propagate changes easier. +func StructMappings(cfg *Config) []shared.EnvBinding { + return structMappings(cfg) +} + +// GetEnv fetches a list of known env variables for this extension. It is to be used by gookit, as it provides a list +// with all the environment variables an extension supports. +func GetEnv(cfg *Config) []string { + var r = make([]string, len(structMappings(cfg))) + for i := range structMappings(cfg) { + r = append(r, structMappings(cfg)[i].EnvVars...) + } + + return r +} + +func structMappings(cfg *Config) []shared.EnvBinding { + return []shared.EnvBinding{ + { + EnvVars: []string{"OCIS_LOG_LEVEL", "STORAGE_FRONTEND_LOG_LEVEL"}, + Destination: &cfg.Log.Level, + }, + { + EnvVars: []string{"OCIS_LOG_PRETTY", "STORAGE_FRONTEND_LOG_PRETTY"}, + Destination: &cfg.Log.Pretty, + }, + { + EnvVars: []string{"OCIS_LOG_COLOR", "STORAGE_FRONTEND_LOG_COLOR"}, + Destination: &cfg.Log.Color, + }, + { + EnvVars: []string{"OCIS_INSECURE", "STORAGE_METADATA_DATAPROVIDER_INSECURE"}, + Destination: &cfg.Reva.StorageMetadata.DataProvider.Insecure, + }, + { + EnvVars: []string{"OCIS_INSECURE", "STORAGE_HOME_DATAPROVIDER_INSECURE"}, + Destination: &cfg.Reva.StorageHome.DataProvider.Insecure, + }, + { + EnvVars: []string{"OCIS_INSECURE", "STORAGE_FRONTEND_APPPROVIDER_INSECURE"}, + Destination: &cfg.Reva.Frontend.AppProviderInsecure, + }, + { + EnvVars: []string{"OCIS_INSECURE", "STORAGE_FRONTEND_ARCHIVER_INSECURE"}, + Destination: &cfg.Reva.Frontend.ArchiverInsecure, + }, + { + EnvVars: []string{"OCIS_INSECURE", "STORAGE_FRONTEND_OCDAV_INSECURE"}, + Destination: &cfg.Reva.Frontend.OCDavInsecure, + }, + { + EnvVars: []string{"OCIS_INSECURE", "STORAGE_OIDC_INSECURE"}, + Destination: &cfg.Reva.OIDC.Insecure, + }, + { + EnvVars: []string{"OCIS_INSECURE", "STORAGE_USERS_DATAPROVIDER_INSECURE"}, + Destination: &cfg.Reva.StorageUsers.DataProvider.Insecure, + }, + } +}