diff --git a/accounts/pkg/config/config.go b/accounts/pkg/config/config.go index 5c138ad78..e10f6a932 100644 --- a/accounts/pkg/config/config.go +++ b/accounts/pkg/config/config.go @@ -1,49 +1,31 @@ -// Package config should be moved to internal package config import ( "context" - "path" - - "github.com/owncloud/ocis/ocis-pkg/config/defaults" ) -//TODO: use debug config -// Debug defines the available debug configuration. -type Debug struct { - Addr string `ocisConfig:"addr" env:"ACCOUNTS_DEBUG_ADDR"` - Token string `ocisConfig:"token" env:"ACCOUNTS_DEBUG_TOKEN"` - Pprof bool `ocisConfig:"pprof" env:"ACCOUNTS_DEBUG_PPROF"` - Zpages bool `ocisConfig:"zpages" env:"ACCOUNTS_DEBUG_ZPAGES"` -} +// Config combines all available configuration parts. +type Config struct { + Service Service -// CORS defines the available cors configuration. -type CORS struct { - AllowedOrigins []string `ocisConfig:"allowed_origins"` - AllowedMethods []string `ocisConfig:"allowed_methods"` - AllowedHeaders []string `ocisConfig:"allowed_headers"` - AllowCredentials bool `ocisConfig:"allowed_credentials"` -} + Tracing Tracing `ocisConfig:"tracing"` + Log Log `ocisConfig:"log"` + Debug Debug `ocisConfig:"debug"` -// HTTP defines the available http configuration. -type HTTP struct { - Addr string `ocisConfig:"addr" env:"ACCOUNTS_HTTP_ADDR"` - Namespace string - Root string `ocisConfig:"root" env:"ACCOUNTS_HTTP_ROOT"` - CacheTTL int `ocisConfig:"cache_ttl" env:"ACCOUNTS_CACHE_TTL"` - CORS CORS `ocisConfig:"cors"` -} + HTTP HTTP `ocisConfig:"http"` + GRPC GRPC `ocisConfig:"grpc"` -// GRPC defines the available grpc configuration. -type GRPC struct { - Addr string `ocisConfig:"addr" env:"ACCOUNTS_GRPC_ADDR"` - Namespace string -} + TokenManager TokenManager `ocisConfig:"token_manager"` -// Service defines the available service configuration. -type Service struct { - Name string - Version string + Asset Asset `ocisConfig:"asset"` + Repo Repo `ocisConfig:"repo"` + Index Index `ocisConfig:"index"` + ServiceUser ServiceUser `ocisConfig:"service_user"` + HashDifficulty int `ocisConfig:"hash_difficulty" env:"ACCOUNTS_HASH_DIFFICULTY"` + DemoUsersAndGroups bool `ocisConfig:"demo_users_and_groups" env:"ACCOUNTS_DEMO_USERS_AND_GROUPS"` + + Context context.Context + Supervised bool } // Asset defines the available asset configuration. @@ -99,107 +81,3 @@ type UIDBound struct { Lower int64 `ocisConfig:"lower" env:"ACCOUNTS_UID_INDEX_LOWER_BOUND"` Upper int64 `ocisConfig:"upper" env:"ACCOUNTS_UID_INDEX_UPPER_BOUND"` } - -// Tracing defines the available tracing configuration. -type Tracing struct { - Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;ACCOUNTS_TRACING_ENABLED"` - Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;ACCOUNTS_TRACING_TYPE"` - Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;ACCOUNTS_TRACING_ENDPOINT"` - Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;ACCOUNTS_TRACING_COLLECTOR"` - Service string `ocisConfig:"service" env:"ACCOUNTS_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? -} - -// Log defines the available log configuration. -type Log struct { - Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;ACCOUNTS_LOG_LEVEL"` - Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;ACCOUNTS_LOG_PRETTY"` - Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;ACCOUNTS_LOG_COLOR"` - File string `mapstructure:"file" env:"OCIS_LOG_FILE;ACCOUNTS_LOG_FILE"` -} - -// Config merges all Account config parameters. -type Config struct { - //*shared.Commons - - Service Service `ocisConfig:"service"` - - Tracing Tracing `ocisConfig:"tracing"` - Log Log `ocisConfig:"log"` - Debug Debug `ocisConfig:"debug"` - - HTTP HTTP `ocisConfig:"http"` - GRPC GRPC `ocisConfig:"grpc"` - - TokenManager TokenManager `ocisConfig:"token_manager"` - - Asset Asset `ocisConfig:"asset"` - Repo Repo `ocisConfig:"repo"` - Index Index `ocisConfig:"index"` - ServiceUser ServiceUser `ocisConfig:"service_user"` - HashDifficulty int `ocisConfig:"hash_difficulty" env:"ACCOUNTS_HASH_DIFFICULTY"` - DemoUsersAndGroups bool `ocisConfig:"demo_users_and_groups" env:"ACCOUNTS_DEMO_USERS_AND_GROUPS"` - - Context context.Context - Supervised bool -} - -func DefaultConfig() *Config { - return &Config{ - - HTTP: HTTP{ - Addr: "127.0.0.1:9181", - Namespace: "com.owncloud.web", - Root: "/", - CacheTTL: 604800, // 7 days - CORS: CORS{ - AllowedOrigins: []string{"*"}, - AllowedMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"}, - AllowedHeaders: []string{"Authorization", "Origin", "Content-Type", "Accept", "X-Requested-With"}, - AllowCredentials: true, - }, - }, - GRPC: GRPC{ - Addr: "127.0.0.1:9180", - Namespace: "com.owncloud.api", - }, - Service: Service{ - Name: "accounts", - }, - Asset: Asset{}, - TokenManager: TokenManager{ - JWTSecret: "Pive-Fumkiu4", - }, - HashDifficulty: 11, - DemoUsersAndGroups: true, - Repo: Repo{ - Backend: "CS3", - Disk: Disk{ - Path: path.Join(defaults.BaseDataPath(), "accounts"), - }, - CS3: CS3{ - ProviderAddr: "localhost:9215", - JWTSecret: "Pive-Fumkiu4", - }, - }, - Index: Index{ - UID: UIDBound{ - Lower: 0, - Upper: 1000, - }, - GID: GIDBound{ - Lower: 0, - Upper: 1000, - }, - }, - ServiceUser: ServiceUser{ - UUID: "95cb8724-03b2-11eb-a0a6-c33ef8ef53ad", - Username: "", - UID: 0, - GID: 0, - }, - Tracing: Tracing{ - Type: "jaeger", - Service: "accounts", - }, - } -} diff --git a/accounts/pkg/config/debug.go b/accounts/pkg/config/debug.go new file mode 100644 index 000000000..c95ef3a26 --- /dev/null +++ b/accounts/pkg/config/debug.go @@ -0,0 +1,10 @@ +package config + +//TODO: use debug config +// Debug defines the available debug configuration. +type Debug struct { + Addr string `ocisConfig:"addr" env:"ACCOUNTS_DEBUG_ADDR"` + Token string `ocisConfig:"token" env:"ACCOUNTS_DEBUG_TOKEN"` + Pprof bool `ocisConfig:"pprof" env:"ACCOUNTS_DEBUG_PPROF"` + Zpages bool `ocisConfig:"zpages" env:"ACCOUNTS_DEBUG_ZPAGES"` +} diff --git a/accounts/pkg/config/defaultconfig.go b/accounts/pkg/config/defaultconfig.go new file mode 100644 index 000000000..8e7caa101 --- /dev/null +++ b/accounts/pkg/config/defaultconfig.go @@ -0,0 +1,68 @@ +package config + +import ( + "path" + + "github.com/owncloud/ocis/ocis-pkg/config/defaults" +) + +func DefaultConfig() *Config { + return &Config{ + + HTTP: HTTP{ + Addr: "127.0.0.1:9181", + Namespace: "com.owncloud.web", + Root: "/", + CacheTTL: 604800, // 7 days + CORS: CORS{ + AllowedOrigins: []string{"*"}, + AllowedMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"}, + AllowedHeaders: []string{"Authorization", "Origin", "Content-Type", "Accept", "X-Requested-With"}, + AllowCredentials: true, + }, + }, + GRPC: GRPC{ + Addr: "127.0.0.1:9180", + Namespace: "com.owncloud.api", + }, + Service: Service{ + Name: "accounts", + }, + Asset: Asset{}, + TokenManager: TokenManager{ + JWTSecret: "Pive-Fumkiu4", + }, + HashDifficulty: 11, + DemoUsersAndGroups: true, + Repo: Repo{ + Backend: "CS3", + Disk: Disk{ + Path: path.Join(defaults.BaseDataPath(), "accounts"), + }, + CS3: CS3{ + ProviderAddr: "localhost:9215", + JWTSecret: "Pive-Fumkiu4", + }, + }, + Index: Index{ + UID: UIDBound{ + Lower: 0, + Upper: 1000, + }, + GID: GIDBound{ + Lower: 0, + Upper: 1000, + }, + }, + ServiceUser: ServiceUser{ + UUID: "95cb8724-03b2-11eb-a0a6-c33ef8ef53ad", + Username: "", + UID: 0, + GID: 0, + }, + Tracing: Tracing{ + Type: "jaeger", + Service: "accounts", + }, + } +} diff --git a/accounts/pkg/config/grpc.go b/accounts/pkg/config/grpc.go new file mode 100644 index 000000000..f16de42f2 --- /dev/null +++ b/accounts/pkg/config/grpc.go @@ -0,0 +1,7 @@ +package config + +// GRPC defines the available grpc configuration. +type GRPC struct { + Addr string `ocisConfig:"addr" env:"ACCOUNTS_GRPC_ADDR"` + Namespace string +} diff --git a/accounts/pkg/config/http.go b/accounts/pkg/config/http.go new file mode 100644 index 000000000..c8c7ab628 --- /dev/null +++ b/accounts/pkg/config/http.go @@ -0,0 +1,18 @@ +package config + +// HTTP defines the available http configuration. +type HTTP struct { + Addr string `ocisConfig:"addr" env:"ACCOUNTS_HTTP_ADDR"` + Namespace string + Root string `ocisConfig:"root" env:"ACCOUNTS_HTTP_ROOT"` + CacheTTL int `ocisConfig:"cache_ttl" env:"ACCOUNTS_CACHE_TTL"` + CORS CORS `ocisConfig:"cors"` +} + +// CORS defines the available cors configuration. +type CORS struct { + AllowedOrigins []string `ocisConfig:"allowed_origins"` + AllowedMethods []string `ocisConfig:"allowed_methods"` + AllowedHeaders []string `ocisConfig:"allowed_headers"` + AllowCredentials bool `ocisConfig:"allowed_credentials"` +} diff --git a/accounts/pkg/config/log.go b/accounts/pkg/config/log.go new file mode 100644 index 000000000..6ada8a7dd --- /dev/null +++ b/accounts/pkg/config/log.go @@ -0,0 +1,9 @@ +package config + +// Log defines the available log configuration. +type Log struct { + Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;ACCOUNTS_LOG_LEVEL"` + Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;ACCOUNTS_LOG_PRETTY"` + Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;ACCOUNTS_LOG_COLOR"` + File string `mapstructure:"file" env:"OCIS_LOG_FILE;ACCOUNTS_LOG_FILE"` +} diff --git a/accounts/pkg/config/service.go b/accounts/pkg/config/service.go new file mode 100644 index 000000000..c12faf344 --- /dev/null +++ b/accounts/pkg/config/service.go @@ -0,0 +1,7 @@ +package config + +// Service defines the available service configuration. +type Service struct { + Name string + Version string +} diff --git a/accounts/pkg/config/tracing.go b/accounts/pkg/config/tracing.go new file mode 100644 index 000000000..3547373fb --- /dev/null +++ b/accounts/pkg/config/tracing.go @@ -0,0 +1,10 @@ +package config + +// Tracing defines the available tracing configuration. +type Tracing struct { + Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;ACCOUNTS_TRACING_ENABLED"` + Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;ACCOUNTS_TRACING_TYPE"` + Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;ACCOUNTS_TRACING_ENDPOINT"` + Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;ACCOUNTS_TRACING_COLLECTOR"` + Service string `ocisConfig:"service" env:"ACCOUNTS_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? +} diff --git a/glauth/pkg/config/config.go b/glauth/pkg/config/config.go index 4876413f6..c13d732ea 100644 --- a/glauth/pkg/config/config.go +++ b/glauth/pkg/config/config.go @@ -2,58 +2,26 @@ package config import ( "context" - "path" - - "github.com/owncloud/ocis/ocis-pkg/shared" - - "github.com/owncloud/ocis/ocis-pkg/config/defaults" ) -// Debug defines the available debug configuration. -type Debug struct { - Addr string `ocisConfig:"addr" env:"GLAUTH_DEBUG_ADDR"` - Token string `ocisConfig:"token" env:"GLAUTH_DEBUG_TOKEN"` - Pprof bool `ocisConfig:"pprof" env:"GLAUTH_DEBUG_PPROF"` - Zpages bool `ocisConfig:"zpages" env:"GLAUTH_DEBUG_ZPAGES"` -} +// Config combines all available configuration parts. +type Config struct { + Service Service -// Service defines the available service configuration. -type Service struct { - Name string - Version string -} + Tracing Tracing `ocisConfig:"tracing"` + Log Log `ocisConfig:"log"` + Debug Debug `ocisConfig:"debug"` -// Tracing defines the available tracing configuration. -type Tracing struct { - Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;GLAUTH_TRACING_ENABLED"` - Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;GLAUTH_TRACING_TYPE"` - Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;GLAUTH_TRACING_ENDPOINT"` - Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;GLAUTH_TRACING_COLLECTOR"` - Service string `ocisConfig:"service" env:"GLAUTH_TRACING_SERVICE"` // TODO: -} + Ldap Ldap `ocisConfig:"ldap"` + Ldaps Ldaps `ocisConfig:"ldaps"` -// Log defines the available log configuration. -type Log struct { - Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;GLAUTH_LOG_LEVEL"` - Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;GLAUTH_LOG_PRETTY"` - Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;GLAUTH_LOG_COLOR"` - File string `mapstructure:"file" env:"OCIS_LOG_FILE;GLAUTH_LOG_FILE"` -} + Backend Backend `ocisConfig:"backend"` + Fallback FallbackBackend `ocisConfig:"fallback"` -// Ldap defined the available LDAP configuration. -type Ldap struct { - Enabled bool `ocisConfig:"enabled" env:"GLAUTH_LDAP_ENABLED"` - Addr string `ocisConfig:"addr" env:"GLAUTH_LDAP_ADDR"` - Namespace string -} + RoleBundleUUID string `ocisConfig:"role_bundle_uuid" env:"GLAUTH_ROLE_BUNDLE_ID"` -// Ldaps defined the available LDAPS configuration. -type Ldaps struct { - Enabled bool `ocisConfig:"enabled" env:"GLAUTH_LDAPS_ENABLED"` - Addr string `ocisConfig:"addr" env:"GLAUTH_LDAPS_ADDR"` - Namespace string - Cert string `ocisConfig:"cert" env:"GLAUTH_LDAPS_CERT"` - Key string `ocisConfig:"key" env:"GLAUTH_LDAPS_KEY"` + Context context.Context + Supervised bool } // Backend defined the available backend configuration. @@ -79,73 +47,3 @@ type FallbackBackend struct { SSHKeyAttr string `ocisConfig:"ssh_key_attr" env:"GLAUTH_FALLBACK_SSH_KEY_ATTR"` UseGraphAPI bool `ocisConfig:"use_graph_api" env:"GLAUTH_FALLBACK_USE_GRAPHAPI"` } - -// Config combines all available configuration parts. -type Config struct { - *shared.Commons - - Service Service `ocisConfig:"service"` - - Tracing Tracing `ocisConfig:"tracing"` - Log Log `ocisConfig:"log"` - Debug Debug `ocisConfig:"debug"` - - Ldap Ldap `ocisConfig:"ldap"` - Ldaps Ldaps `ocisConfig:"ldaps"` - - Backend Backend `ocisConfig:"backend"` - Fallback FallbackBackend `ocisConfig:"fallback"` - - RoleBundleUUID string `ocisConfig:"role_bundle_uuid" env:"GLAUTH_ROLE_BUNDLE_ID"` - - Context context.Context - Supervised bool -} - -func DefaultConfig() *Config { - return &Config{ - Debug: Debug{ - Addr: "127.0.0.1:9129", - }, - Tracing: Tracing{ - Type: "jaeger", - Service: "glauth", - }, - Service: Service{ - Name: "glauth", - }, - Ldap: Ldap{ - Enabled: true, - Addr: "127.0.0.1:9125", - Namespace: "com.owncloud.ldap", - }, - Ldaps: Ldaps{ - Enabled: true, - Addr: "127.0.0.1:9126", - Namespace: "com.owncloud.ldaps", - Cert: path.Join(defaults.BaseDataPath(), "ldap", "ldap.crt"), - Key: path.Join(defaults.BaseDataPath(), "ldap", "ldap.key"), - }, - Backend: Backend{ - Datastore: "accounts", - BaseDN: "dc=ocis,dc=test", - Insecure: false, - NameFormat: "cn", - GroupFormat: "ou", - Servers: nil, - SSHKeyAttr: "sshPublicKey", - UseGraphAPI: true, - }, - Fallback: FallbackBackend{ - Datastore: "", - BaseDN: "dc=ocis,dc=test", - Insecure: false, - NameFormat: "cn", - GroupFormat: "ou", - Servers: nil, - SSHKeyAttr: "sshPublicKey", - UseGraphAPI: true, - }, - RoleBundleUUID: "71881883-1768-46bd-a24d-a356a2afdf7f", // BundleUUIDRoleAdmin - } -} diff --git a/glauth/pkg/config/debug.go b/glauth/pkg/config/debug.go new file mode 100644 index 000000000..1d612c88d --- /dev/null +++ b/glauth/pkg/config/debug.go @@ -0,0 +1,9 @@ +package config + +// Debug defines the available debug configuration. +type Debug struct { + Addr string `ocisConfig:"addr" env:"GLAUTH_DEBUG_ADDR"` + Token string `ocisConfig:"token" env:"GLAUTH_DEBUG_TOKEN"` + Pprof bool `ocisConfig:"pprof" env:"GLAUTH_DEBUG_PPROF"` + Zpages bool `ocisConfig:"zpages" env:"GLAUTH_DEBUG_ZPAGES"` +} diff --git a/glauth/pkg/config/defaultconfig.go b/glauth/pkg/config/defaultconfig.go new file mode 100644 index 000000000..23c12f844 --- /dev/null +++ b/glauth/pkg/config/defaultconfig.go @@ -0,0 +1,55 @@ +package config + +import ( + "path" + + "github.com/owncloud/ocis/ocis-pkg/config/defaults" +) + +func DefaultConfig() *Config { + return &Config{ + Debug: Debug{ + Addr: "127.0.0.1:9129", + }, + Tracing: Tracing{ + Type: "jaeger", + Service: "glauth", + }, + Service: Service{ + Name: "glauth", + }, + Ldap: Ldap{ + Enabled: true, + Addr: "127.0.0.1:9125", + Namespace: "com.owncloud.ldap", + }, + Ldaps: Ldaps{ + Enabled: true, + Addr: "127.0.0.1:9126", + Namespace: "com.owncloud.ldaps", + Cert: path.Join(defaults.BaseDataPath(), "ldap", "ldap.crt"), + Key: path.Join(defaults.BaseDataPath(), "ldap", "ldap.key"), + }, + Backend: Backend{ + Datastore: "accounts", + BaseDN: "dc=ocis,dc=test", + Insecure: false, + NameFormat: "cn", + GroupFormat: "ou", + Servers: nil, + SSHKeyAttr: "sshPublicKey", + UseGraphAPI: true, + }, + Fallback: FallbackBackend{ + Datastore: "", + BaseDN: "dc=ocis,dc=test", + Insecure: false, + NameFormat: "cn", + GroupFormat: "ou", + Servers: nil, + SSHKeyAttr: "sshPublicKey", + UseGraphAPI: true, + }, + RoleBundleUUID: "71881883-1768-46bd-a24d-a356a2afdf7f", // BundleUUIDRoleAdmin + } +} diff --git a/glauth/pkg/config/ldap.go b/glauth/pkg/config/ldap.go new file mode 100644 index 000000000..b0780084a --- /dev/null +++ b/glauth/pkg/config/ldap.go @@ -0,0 +1,8 @@ +package config + +// Ldap defines the available LDAP configuration. +type Ldap struct { + Enabled bool `ocisConfig:"enabled" env:"GLAUTH_LDAP_ENABLED"` + Addr string `ocisConfig:"addr" env:"GLAUTH_LDAP_ADDR"` + Namespace string +} diff --git a/glauth/pkg/config/ldaps.go b/glauth/pkg/config/ldaps.go new file mode 100644 index 000000000..2c09f2530 --- /dev/null +++ b/glauth/pkg/config/ldaps.go @@ -0,0 +1,10 @@ +package config + +// Ldaps defined the available LDAPS configuration. +type Ldaps struct { + Enabled bool `ocisConfig:"enabled" env:"GLAUTH_LDAPS_ENABLED"` + Addr string `ocisConfig:"addr" env:"GLAUTH_LDAPS_ADDR"` + Namespace string + Cert string `ocisConfig:"cert" env:"GLAUTH_LDAPS_CERT"` + Key string `ocisConfig:"key" env:"GLAUTH_LDAPS_KEY"` +} diff --git a/glauth/pkg/config/log.go b/glauth/pkg/config/log.go new file mode 100644 index 000000000..2ce88369b --- /dev/null +++ b/glauth/pkg/config/log.go @@ -0,0 +1,9 @@ +package config + +// Log defines the available log configuration. +type Log struct { + Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;GLAUTH_LOG_LEVEL"` + Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;GLAUTH_LOG_PRETTY"` + Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;GLAUTH_LOG_COLOR"` + File string `mapstructure:"file" env:"OCIS_LOG_FILE;GLAUTH_LOG_FILE"` +} diff --git a/glauth/pkg/config/service.go b/glauth/pkg/config/service.go new file mode 100644 index 000000000..c12faf344 --- /dev/null +++ b/glauth/pkg/config/service.go @@ -0,0 +1,7 @@ +package config + +// Service defines the available service configuration. +type Service struct { + Name string + Version string +} diff --git a/glauth/pkg/config/tracing.go b/glauth/pkg/config/tracing.go new file mode 100644 index 000000000..3caca2705 --- /dev/null +++ b/glauth/pkg/config/tracing.go @@ -0,0 +1,10 @@ +package config + +// Tracing defines the available tracing configuration. +type Tracing struct { + Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;GLAUTH_TRACING_ENABLED"` + Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;GLAUTH_TRACING_TYPE"` + Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;GLAUTH_TRACING_ENDPOINT"` + Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;GLAUTH_TRACING_COLLECTOR"` + Service string `ocisConfig:"service" env:"GLAUTH_TRACING_SERVICE"` // TODO: +} diff --git a/graph-explorer/pkg/config/config.go b/graph-explorer/pkg/config/config.go index 9a76da101..9e11dd8e7 100644 --- a/graph-explorer/pkg/config/config.go +++ b/graph-explorer/pkg/config/config.go @@ -4,55 +4,9 @@ import ( "context" ) -// Debug defines the available debug configuration. -type Debug struct { - Addr string `ocisConfig:"addr" env:"GRAPH_EXPLORER_DEBUG_ADDR"` - Token string `ocisConfig:"token" env:"GRAPH_EXPLORER_DEBUG_TOKEN"` - Pprof bool `ocisConfig:"pprof" env:"GRAPH_EXPLORER_DEBUG_PPROF"` - Zpages bool `ocisConfig:"zpages" env:"GRAPH_EXPLORER_DEBUG_ZPAGES"` -} - -// HTTP defines the available http configuration. -type HTTP struct { - Addr string `ocisConfig:"addr" env:"GRAPH_EXPLORER_HTTP_ADDR"` - Root string `ocisConfig:"root" env:"GRAPH_EXPLORER_HTTP_ROOT"` - Namespace string -} - -// Service defines the available service configuration. -type Service struct { - Name string - Version string -} - -// Tracing defines the available tracing configuration. -type Tracing struct { - Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;GRAPH_EXPLORER_TRACING_ENABLED"` - Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;GRAPH_EXPLORER_TRACING_TYPE"` - Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;GRAPH_EXPLORER_TRACING_ENDPOINT"` - Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;GRAPH_EXPLORER_TRACING_COLLECTOR"` - Service string `ocisConfig:"service" env:"GRAPH_EXPLORER_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? -} - -// Log defines the available log configuration. -type Log struct { - Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;GRAPH_EXPLORER_LOG_LEVEL"` - Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;GRAPH_EXPLORER_LOG_PRETTY"` - Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;GRAPH_EXPLORER_LOG_COLOR"` - File string `mapstructure:"file" env:"OCIS_LOG_FILE;GRAPH_EXPLORER_LOG_FILE"` -} - -// GraphExplorer defines the available graph-explorer configuration. -type GraphExplorer struct { - ClientID string `ocisConfig:"client_id" env:"GRAPH_EXPLORER_CLIENT_ID"` - Issuer string `ocisConfig:"issuer" env:"OCIS_URL;GRAPH_EXPLORER_ISSUER"` - GraphURLBase string `ocisConfig:"graph_url_base" env:"OCIS_URL;GRAPH_EXPLORER_GRAPH_URL_BASE"` - GraphURLPath string `ocisConfig:"graph_url_path" env:"GRAPH_EXPLORER_GRAPH_URL_PATH"` -} - // Config combines all available configuration parts. type Config struct { - Service Service `ocisConfig:"service"` + Service Service Tracing Tracing `ocisConfig:"tracing"` Log Log `ocisConfig:"log"` @@ -66,34 +20,10 @@ type Config struct { Supervised bool } -// DefaultConfig provides with a working version of a config. -func DefaultConfig() *Config { - return &Config{ - Debug: Debug{ - Addr: "127.0.0.1:9136", - Token: "", - Pprof: false, - Zpages: false, - }, - HTTP: HTTP{ - Addr: "127.0.0.1:9135", - Root: "/graph-explorer", - Namespace: "com.owncloud.web", - }, - Service: Service{ - Name: "graph-explorer", - }, - Tracing: Tracing{ - Type: "jaeger", - Endpoint: "", - Collector: "", - Service: "graph-explorer", - }, - GraphExplorer: GraphExplorer{ - ClientID: "ocis-explorer.js", - Issuer: "https://localhost:9200", - GraphURLBase: "https://localhost:9200", - GraphURLPath: "/graph", - }, - } +// GraphExplorer defines the available graph-explorer configuration. +type GraphExplorer struct { + ClientID string `ocisConfig:"client_id" env:"GRAPH_EXPLORER_CLIENT_ID"` + Issuer string `ocisConfig:"issuer" env:"OCIS_URL;GRAPH_EXPLORER_ISSUER"` + GraphURLBase string `ocisConfig:"graph_url_base" env:"OCIS_URL;GRAPH_EXPLORER_GRAPH_URL_BASE"` + GraphURLPath string `ocisConfig:"graph_url_path" env:"GRAPH_EXPLORER_GRAPH_URL_PATH"` } diff --git a/graph-explorer/pkg/config/debug.go b/graph-explorer/pkg/config/debug.go new file mode 100644 index 000000000..3dfc27f7b --- /dev/null +++ b/graph-explorer/pkg/config/debug.go @@ -0,0 +1,9 @@ +package config + +// Debug defines the available debug configuration. +type Debug struct { + Addr string `ocisConfig:"addr" env:"GRAPH_EXPLORER_DEBUG_ADDR"` + Token string `ocisConfig:"token" env:"GRAPH_EXPLORER_DEBUG_TOKEN"` + Pprof bool `ocisConfig:"pprof" env:"GRAPH_EXPLORER_DEBUG_PPROF"` + Zpages bool `ocisConfig:"zpages" env:"GRAPH_EXPLORER_DEBUG_ZPAGES"` +} diff --git a/graph-explorer/pkg/config/defaultconfig.go b/graph-explorer/pkg/config/defaultconfig.go new file mode 100644 index 000000000..b44927243 --- /dev/null +++ b/graph-explorer/pkg/config/defaultconfig.go @@ -0,0 +1,32 @@ +package config + +func DefaultConfig() *Config { + return &Config{ + Debug: Debug{ + Addr: "127.0.0.1:9136", + Token: "", + Pprof: false, + Zpages: false, + }, + HTTP: HTTP{ + Addr: "127.0.0.1:9135", + Root: "/graph-explorer", + Namespace: "com.owncloud.web", + }, + Service: Service{ + Name: "graph-explorer", + }, + Tracing: Tracing{ + Type: "jaeger", + Endpoint: "", + Collector: "", + Service: "graph-explorer", + }, + GraphExplorer: GraphExplorer{ + ClientID: "ocis-explorer.js", + Issuer: "https://localhost:9200", + GraphURLBase: "https://localhost:9200", + GraphURLPath: "/graph", + }, + } +} diff --git a/graph-explorer/pkg/config/http.go b/graph-explorer/pkg/config/http.go new file mode 100644 index 000000000..8990a455e --- /dev/null +++ b/graph-explorer/pkg/config/http.go @@ -0,0 +1,16 @@ +package config + +// HTTP defines the available http configuration. +type HTTP struct { + Addr string `ocisConfig:"addr" env:"GRAPH_EXPLORER_HTTP_ADDR"` + Root string `ocisConfig:"root" env:"GRAPH_EXPLORER_HTTP_ROOT"` + Namespace string +} + +// CORS defines the available cors configuration. +type CORS struct { + AllowedOrigins []string `ocisConfig:"allowed_origins"` + AllowedMethods []string `ocisConfig:"allowed_methods"` + AllowedHeaders []string `ocisConfig:"allowed_headers"` + AllowCredentials bool `ocisConfig:"allowed_credentials"` +} diff --git a/graph-explorer/pkg/config/log.go b/graph-explorer/pkg/config/log.go new file mode 100644 index 000000000..7c9c0f538 --- /dev/null +++ b/graph-explorer/pkg/config/log.go @@ -0,0 +1,9 @@ +package config + +// Log defines the available log configuration. +type Log struct { + Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;GRAPH_EXPLORER_LOG_LEVEL"` + Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;GRAPH_EXPLORER_LOG_PRETTY"` + Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;GRAPH_EXPLORER_LOG_COLOR"` + File string `mapstructure:"file" env:"OCIS_LOG_FILE;GRAPH_EXPLORER_LOG_FILE"` +} diff --git a/graph-explorer/pkg/config/service.go b/graph-explorer/pkg/config/service.go new file mode 100644 index 000000000..c12faf344 --- /dev/null +++ b/graph-explorer/pkg/config/service.go @@ -0,0 +1,7 @@ +package config + +// Service defines the available service configuration. +type Service struct { + Name string + Version string +} diff --git a/graph-explorer/pkg/config/tracing.go b/graph-explorer/pkg/config/tracing.go new file mode 100644 index 000000000..cf4214eb4 --- /dev/null +++ b/graph-explorer/pkg/config/tracing.go @@ -0,0 +1,10 @@ +package config + +// Tracing defines the available tracing configuration. +type Tracing struct { + Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;GRAPH_EXPLORER_TRACING_ENABLED"` + Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;GRAPH_EXPLORER_TRACING_TYPE"` + Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;GRAPH_EXPLORER_TRACING_ENDPOINT"` + Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;GRAPH_EXPLORER_TRACING_COLLECTOR"` + Service string `ocisConfig:"service" env:"GRAPH_EXPLORER_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? +} diff --git a/graph/pkg/config/config.go b/graph/pkg/config/config.go index c3d22789a..e2cc81c47 100644 --- a/graph/pkg/config/config.go +++ b/graph/pkg/config/config.go @@ -2,56 +2,26 @@ package config import ( "context" - - "github.com/owncloud/ocis/ocis-pkg/shared" ) -// Debug defines the available debug configuration. -type Debug struct { - Addr string `ocisConfig:"addr" env:"GRAPH_DEBUG_ADDR"` - Token string `ocisConfig:"token" env:"GRAPH_DEBUG_TOKEN"` - Pprof bool `ocisConfig:"pprof" env:"GRAPH_DEBUG_PPROF"` - Zpages bool `ocisConfig:"zpages" env:"GRAPH_DEBUG_ZPAGES"` -} +// Config combines all available configuration parts. +type Config struct { + Service Service -// HTTP defines the available http configuration. -type HTTP struct { - Addr string `ocisConfig:"addr" env:"GRAPH_HTTP_ADDR"` - Namespace string - Root string `ocisConfig:"root" env:"GRAPH_HTTP_ROOT"` -} + Tracing Tracing `ocisConfig:"tracing"` + Log Log `ocisConfig:"log"` + Debug Debug `ocisConfig:"debug"` -// Service defines the available service configuration. -type Service struct { - Name string - Version string -} + HTTP HTTP `ocisConfig:"http"` -// Tracing defines the available tracing configuration. -type Tracing struct { - Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;GRAPH_TRACING_ENABLED"` - Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;GRAPH_TRACING_TYPE"` - Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;GRAPH_TRACING_ENDPOINT"` - Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;GRAPH_TRACING_COLLECTOR"` - Service string `ocisConfig:"service" env:"GRAPH_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? -} + Reva Reva `ocisConfig:"reva"` + TokenManager TokenManager `ocisConfig:"token_manager"` -// Log defines the available log configuration. -type Log struct { - Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;GRAPH_LOG_LEVEL"` - Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;GRAPH_LOG_PRETTY"` - Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;GRAPH_LOG_COLOR"` - File string `mapstructure:"file" env:"OCIS_LOG_FILE;GRAPH_LOG_FILE"` -} + Spaces Spaces `ocisConfig:"spaces"` + Identity Identity `ocisConfig:"identity"` -// Reva defines all available REVA configuration. -type Reva struct { - Address string `ocisConfig:"address" env:"REVA_GATEWAY"` -} - -// TokenManager is the config for using the reva token manager -type TokenManager struct { - JWTSecret string `ocisConfig:"jwt_secret" env:"OCIS_JWT_SECRET;GRAPH_JWT_SECRET"` + Context context.Context + Supervised bool } type Spaces struct { @@ -85,80 +55,3 @@ type Identity struct { Backend string `ocisConfig:"backend" env:"GRAPH_IDENTITY_BACKEND"` LDAP LDAP `ocisConfig:"ldap"` } - -// Config combines all available configuration parts. -type Config struct { - *shared.Commons - - Service Service `ocisConfig:"service"` - - Tracing Tracing `ocisConfig:"tracing"` - Log Log `ocisConfig:"log"` - Debug Debug `ocisConfig:"debug"` - - HTTP HTTP `ocisConfig:"http"` - - Reva Reva `ocisConfig:"reva"` - TokenManager TokenManager `ocisConfig:"token_manager"` - - Spaces Spaces `ocisConfig:"spaces"` - Identity Identity `ocisConfig:"identity"` - - Context context.Context - Supervised bool -} - -func DefaultConfig() *Config { - return &Config{ - Debug: Debug{ - Addr: "127.0.0.1:9124", - Token: "", - }, - HTTP: HTTP{ - Addr: "127.0.0.1:9120", - Namespace: "com.owncloud.graph", - Root: "/graph", - }, - Service: Service{ - Name: "graph", - }, - Tracing: Tracing{ - Enabled: false, - Type: "jaeger", - Service: "graph", - }, - Reva: Reva{ - Address: "127.0.0.1:9142", - }, - TokenManager: TokenManager{ - JWTSecret: "Pive-Fumkiu4", - }, - Spaces: Spaces{ - WebDavBase: "https://localhost:9200", - WebDavPath: "/dav/spaces/", - DefaultQuota: "1000000000", - }, - Identity: Identity{ - Backend: "cs3", - LDAP: LDAP{ - URI: "ldap://localhost:9125", - BindDN: "", - BindPassword: "", - UserBaseDN: "ou=users,dc=ocis,dc=test", - UserSearchScope: "sub", - UserFilter: "(objectClass=posixaccount)", - UserEmailAttribute: "mail", - UserDisplayNameAttribute: "displayName", - UserNameAttribute: "uid", - // FIXME: switch this to some more widely available attribute by default - // ideally this needs to be constant for the lifetime of a users - UserIDAttribute: "ownclouduuid", - GroupBaseDN: "ou=groups,dc=ocis,dc=test", - GroupSearchScope: "sub", - GroupFilter: "(objectclass=groupOfNames)", - GroupNameAttribute: "cn", - GroupIDAttribute: "cn", - }, - }, - } -} diff --git a/graph/pkg/config/debug.go b/graph/pkg/config/debug.go new file mode 100644 index 000000000..c1284be91 --- /dev/null +++ b/graph/pkg/config/debug.go @@ -0,0 +1,9 @@ +package config + +// Debug defines the available debug configuration. +type Debug struct { + Addr string `ocisConfig:"addr" env:"GRAPH_DEBUG_ADDR"` + Token string `ocisConfig:"token" env:"GRAPH_DEBUG_TOKEN"` + Pprof bool `ocisConfig:"pprof" env:"GRAPH_DEBUG_PPROF"` + Zpages bool `ocisConfig:"zpages" env:"GRAPH_DEBUG_ZPAGES"` +} diff --git a/graph/pkg/config/defaultconfig.go b/graph/pkg/config/defaultconfig.go new file mode 100644 index 000000000..b5d09a9d2 --- /dev/null +++ b/graph/pkg/config/defaultconfig.go @@ -0,0 +1,56 @@ +package config + +func DefaultConfig() *Config { + return &Config{ + Debug: Debug{ + Addr: "127.0.0.1:9124", + Token: "", + }, + HTTP: HTTP{ + Addr: "127.0.0.1:9120", + Namespace: "com.owncloud.graph", + Root: "/graph", + }, + Service: Service{ + Name: "graph", + }, + Tracing: Tracing{ + Enabled: false, + Type: "jaeger", + Service: "graph", + }, + Reva: Reva{ + Address: "127.0.0.1:9142", + }, + TokenManager: TokenManager{ + JWTSecret: "Pive-Fumkiu4", + }, + Spaces: Spaces{ + WebDavBase: "https://localhost:9200", + WebDavPath: "/dav/spaces/", + DefaultQuota: "1000000000", + }, + Identity: Identity{ + Backend: "cs3", + LDAP: LDAP{ + URI: "ldap://localhost:9125", + BindDN: "", + BindPassword: "", + UserBaseDN: "ou=users,dc=ocis,dc=test", + UserSearchScope: "sub", + UserFilter: "(objectClass=posixaccount)", + UserEmailAttribute: "mail", + UserDisplayNameAttribute: "displayName", + UserNameAttribute: "uid", + // FIXME: switch this to some more widely available attribute by default + // ideally this needs to be constant for the lifetime of a users + UserIDAttribute: "ownclouduuid", + GroupBaseDN: "ou=groups,dc=ocis,dc=test", + GroupSearchScope: "sub", + GroupFilter: "(objectclass=groupOfNames)", + GroupNameAttribute: "cn", + GroupIDAttribute: "cn", + }, + }, + } +} diff --git a/graph/pkg/config/http.go b/graph/pkg/config/http.go new file mode 100644 index 000000000..64351105b --- /dev/null +++ b/graph/pkg/config/http.go @@ -0,0 +1,8 @@ +package config + +// HTTP defines the available http configuration. +type HTTP struct { + Addr string `ocisConfig:"addr" env:"GRAPH_HTTP_ADDR"` + Namespace string + Root string `ocisConfig:"root" env:"GRAPH_HTTP_ROOT"` +} diff --git a/graph/pkg/config/log.go b/graph/pkg/config/log.go new file mode 100644 index 000000000..3f1f84603 --- /dev/null +++ b/graph/pkg/config/log.go @@ -0,0 +1,9 @@ +package config + +// Log defines the available log configuration. +type Log struct { + Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;GRAPH_LOG_LEVEL"` + Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;GRAPH_LOG_PRETTY"` + Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;GRAPH_LOG_COLOR"` + File string `mapstructure:"file" env:"OCIS_LOG_FILE;GRAPH_LOG_FILE"` +} diff --git a/graph/pkg/config/reva.go b/graph/pkg/config/reva.go new file mode 100644 index 000000000..31f48fbb6 --- /dev/null +++ b/graph/pkg/config/reva.go @@ -0,0 +1,11 @@ +package config + +// Reva defines all available REVA configuration. +type Reva struct { + Address string `ocisConfig:"address" env:"REVA_GATEWAY"` +} + +// TokenManager is the config for using the reva token manager +type TokenManager struct { + JWTSecret string `ocisConfig:"jwt_secret" env:"OCIS_JWT_SECRET;OCS_JWT_SECRET"` +} diff --git a/graph/pkg/config/service.go b/graph/pkg/config/service.go new file mode 100644 index 000000000..c12faf344 --- /dev/null +++ b/graph/pkg/config/service.go @@ -0,0 +1,7 @@ +package config + +// Service defines the available service configuration. +type Service struct { + Name string + Version string +} diff --git a/graph/pkg/config/tracing.go b/graph/pkg/config/tracing.go new file mode 100644 index 000000000..457edb0fd --- /dev/null +++ b/graph/pkg/config/tracing.go @@ -0,0 +1,10 @@ +package config + +// Tracing defines the available tracing configuration. +type Tracing struct { + Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;GRAPH_TRACING_ENABLED"` + Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;GRAPH_TRACING_TYPE"` + Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;GRAPH_TRACING_ENDPOINT"` + Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;GRAPH_TRACING_COLLECTOR"` + Service string `ocisConfig:"service" env:"GRAPH_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? +} diff --git a/idp/pkg/config/config.go b/idp/pkg/config/config.go index 6793294e6..cc1e3b538 100644 --- a/idp/pkg/config/config.go +++ b/idp/pkg/config/config.go @@ -2,35 +2,24 @@ package config import ( "context" - "path" - - "github.com/owncloud/ocis/ocis-pkg/shared" - - "github.com/owncloud/ocis/ocis-pkg/config/defaults" ) -// Debug defines the available debug configuration. -type Debug struct { - Addr string `ocisConfig:"addr" env:"IDP_DEBUG_ADDR"` - Token string `ocisConfig:"token" env:"IDP_DEBUG_TOKEN"` - Pprof bool `ocisConfig:"pprof" env:"IDP_DEBUG_PPROF"` - Zpages bool `ocisConfig:"zpages" env:"IDP_DEBUG_ZPAGES"` -} +// Config combines all available configuration parts. +type Config struct { + Service Service -// HTTP defines the available http configuration. -type HTTP struct { - Addr string `ocisConfig:"addr" env:"IDP_HTTP_ADDR"` - Root string `ocisConfig:"root" env:"IDP_HTTP_ROOT"` - Namespace string - TLSCert string `ocisConfig:"tls_cert" env:"IDP_TRANSPORT_TLS_CERT"` - TLSKey string `ocisConfig:"tls_key" env:"IDP_TRANSPORT_TLS_KEY"` - TLS bool `ocisConfig:"tls" env:"IDP_TLS"` -} + Tracing Tracing `ocisConfig:"tracing"` + Log Log `ocisConfig:"log"` + Debug Debug `ocisConfig:"debug"` -// Service defines the available service configuration. -type Service struct { - Name string - Version string + HTTP HTTP `ocisConfig:"http"` + + Asset Asset `ocisConfig:"asset"` + IDP Settings `ocisConfig:"idp"` + Ldap Ldap `ocisConfig:"ldap"` + + Context context.Context + Supervised bool } // Ldap defines the available LDAP configuration. @@ -52,23 +41,6 @@ type Ldap struct { Filter string `ocisConfig:"filter" env:"IDP_LDAP_FILTER"` } -// Tracing defines the available tracing configuration. -type Tracing struct { - Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;IDP_TRACING_ENABLED"` - Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;IDP_TRACING_TYPE"` - Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;IDP_TRACING_ENDPOINT"` - Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;IDP_TRACING_COLLECTOR"` - Service string `ocisConfig:"service" env:"IDP_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? -} - -// Log defines the available log configuration. -type Log struct { - Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;IDP_LOG_LEVEL"` - Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;IDP_LOG_PRETTY"` - Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;IDP_LOG_COLOR"` - File string `mapstructure:"file" env:"OCIS_LOG_FILE;IDP_LOG_FILE"` -} - // Asset defines the available asset configuration. type Asset struct { Path string `ocisConfig:"asset" env:"IDP_ASSET_PATH"` @@ -123,95 +95,3 @@ type Settings struct { RefreshTokenDurationSeconds uint64 `ocisConfig:"refresh_token_duration_seconds" env:"IDP_REFRESH_TOKEN_EXPIRATION"` DyamicClientSecretDurationSeconds uint64 `ocisConfig:"dynamic_client_secret_duration_seconds" env:""` } - -// Config combines all available configuration parts. -type Config struct { - *shared.Commons - - Service Service `ocisConfig:"service"` - - Tracing Tracing `ocisConfig:"tracing"` - Log Log `ocisConfig:"log"` - Debug Debug `ocisConfig:"debug"` - - HTTP HTTP `ocisConfig:"http"` - - Asset Asset `ocisConfig:"asset"` - IDP Settings `ocisConfig:"idp"` - Ldap Ldap `ocisConfig:"ldap"` - - Context context.Context - Supervised bool -} - -func DefaultConfig() *Config { - return &Config{ - Debug: Debug{ - Addr: "127.0.0.1:9134", - }, - HTTP: HTTP{ - Addr: "127.0.0.1:9130", - Root: "/", - Namespace: "com.owncloud.web", - TLSCert: path.Join(defaults.BaseDataPath(), "idp", "server.crt"), - TLSKey: path.Join(defaults.BaseDataPath(), "idp", "server.key"), - TLS: false, - }, - Service: Service{ - Name: "idp", - }, - Tracing: Tracing{ - Type: "jaeger", - Endpoint: "", - Collector: "", - Service: "idp", - }, - Asset: Asset{}, - IDP: Settings{ - Iss: "https://localhost:9200", - IdentityManager: "ldap", - URIBasePath: "", - SignInURI: "", - SignedOutURI: "", - AuthorizationEndpointURI: "", - EndsessionEndpointURI: "", - Insecure: false, - TrustedProxy: nil, - AllowScope: nil, - AllowClientGuests: false, - AllowDynamicClientRegistration: false, - EncryptionSecretFile: "", - Listen: "", - IdentifierClientDisabled: true, - IdentifierClientPath: path.Join(defaults.BaseDataPath(), "idp"), - IdentifierRegistrationConf: path.Join(defaults.BaseDataPath(), "idp", "identifier-registration.yaml"), - IdentifierScopesConf: "", - IdentifierDefaultBannerLogo: "", - IdentifierDefaultSignInPageText: "", - IdentifierDefaultUsernameHintText: "", - SigningKid: "", - SigningMethod: "PS256", - SigningPrivateKeyFiles: nil, - ValidationKeysPath: "", - CookieBackendURI: "", - CookieNames: nil, - AccessTokenDurationSeconds: 60 * 10, // 10 minutes - IDTokenDurationSeconds: 60 * 60, // 1 hour - RefreshTokenDurationSeconds: 60 * 60 * 24 * 365 * 3, // 1 year - DyamicClientSecretDurationSeconds: 0, - }, - Ldap: Ldap{ - URI: "ldap://localhost:9125", - BindDN: "cn=idp,ou=sysusers,dc=ocis,dc=test", - BindPassword: "idp", - BaseDN: "ou=users,dc=ocis,dc=test", - Scope: "sub", - LoginAttribute: "cn", - EmailAttribute: "mail", - NameAttribute: "sn", - UUIDAttribute: "uid", - UUIDAttributeType: "text", - Filter: "(objectClass=posixaccount)", - }, - } -} diff --git a/idp/pkg/config/debug.go b/idp/pkg/config/debug.go new file mode 100644 index 000000000..f713bc341 --- /dev/null +++ b/idp/pkg/config/debug.go @@ -0,0 +1,9 @@ +package config + +// Debug defines the available debug configuration. +type Debug struct { + Addr string `ocisConfig:"addr" env:"IDP_DEBUG_ADDR"` + Token string `ocisConfig:"token" env:"IDP_DEBUG_TOKEN"` + Pprof bool `ocisConfig:"pprof" env:"IDP_DEBUG_PPROF"` + Zpages bool `ocisConfig:"zpages" env:"IDP_DEBUG_ZPAGES"` +} diff --git a/idp/pkg/config/defaultconfig.go b/idp/pkg/config/defaultconfig.go new file mode 100644 index 000000000..dbaa3ba57 --- /dev/null +++ b/idp/pkg/config/defaultconfig.go @@ -0,0 +1,79 @@ +package config + +import ( + "path" + + "github.com/owncloud/ocis/ocis-pkg/config/defaults" +) + +func DefaultConfig() *Config { + return &Config{ + Debug: Debug{ + Addr: "127.0.0.1:9134", + }, + HTTP: HTTP{ + Addr: "127.0.0.1:9130", + Root: "/", + Namespace: "com.owncloud.web", + TLSCert: path.Join(defaults.BaseDataPath(), "idp", "server.crt"), + TLSKey: path.Join(defaults.BaseDataPath(), "idp", "server.key"), + TLS: false, + }, + Service: Service{ + Name: "idp", + }, + Tracing: Tracing{ + Type: "jaeger", + Endpoint: "", + Collector: "", + Service: "idp", + }, + Asset: Asset{}, + IDP: Settings{ + Iss: "https://localhost:9200", + IdentityManager: "ldap", + URIBasePath: "", + SignInURI: "", + SignedOutURI: "", + AuthorizationEndpointURI: "", + EndsessionEndpointURI: "", + Insecure: false, + TrustedProxy: nil, + AllowScope: nil, + AllowClientGuests: false, + AllowDynamicClientRegistration: false, + EncryptionSecretFile: "", + Listen: "", + IdentifierClientDisabled: true, + IdentifierClientPath: path.Join(defaults.BaseDataPath(), "idp"), + IdentifierRegistrationConf: path.Join(defaults.BaseDataPath(), "idp", "identifier-registration.yaml"), + IdentifierScopesConf: "", + IdentifierDefaultBannerLogo: "", + IdentifierDefaultSignInPageText: "", + IdentifierDefaultUsernameHintText: "", + SigningKid: "", + SigningMethod: "PS256", + SigningPrivateKeyFiles: nil, + ValidationKeysPath: "", + CookieBackendURI: "", + CookieNames: nil, + AccessTokenDurationSeconds: 60 * 10, // 10 minutes + IDTokenDurationSeconds: 60 * 60, // 1 hour + RefreshTokenDurationSeconds: 60 * 60 * 24 * 365 * 3, // 1 year + DyamicClientSecretDurationSeconds: 0, + }, + Ldap: Ldap{ + URI: "ldap://localhost:9125", + BindDN: "cn=idp,ou=sysusers,dc=ocis,dc=test", + BindPassword: "idp", + BaseDN: "ou=users,dc=ocis,dc=test", + Scope: "sub", + LoginAttribute: "cn", + EmailAttribute: "mail", + NameAttribute: "sn", + UUIDAttribute: "uid", + UUIDAttributeType: "text", + Filter: "(objectClass=posixaccount)", + }, + } +} diff --git a/idp/pkg/config/http.go b/idp/pkg/config/http.go new file mode 100644 index 000000000..4d528e027 --- /dev/null +++ b/idp/pkg/config/http.go @@ -0,0 +1,11 @@ +package config + +// HTTP defines the available http configuration. +type HTTP struct { + Addr string `ocisConfig:"addr" env:"IDP_HTTP_ADDR"` + Root string `ocisConfig:"root" env:"IDP_HTTP_ROOT"` + Namespace string + TLSCert string `ocisConfig:"tls_cert" env:"IDP_TRANSPORT_TLS_CERT"` + TLSKey string `ocisConfig:"tls_key" env:"IDP_TRANSPORT_TLS_KEY"` + TLS bool `ocisConfig:"tls" env:"IDP_TLS"` +} diff --git a/idp/pkg/config/log.go b/idp/pkg/config/log.go new file mode 100644 index 000000000..39ba2d9e5 --- /dev/null +++ b/idp/pkg/config/log.go @@ -0,0 +1,9 @@ +package config + +// Log defines the available log configuration. +type Log struct { + Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;IDP_LOG_LEVEL"` + Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;IDP_LOG_PRETTY"` + Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;IDP_LOG_COLOR"` + File string `mapstructure:"file" env:"OCIS_LOG_FILE;IDP_LOG_FILE"` +} diff --git a/idp/pkg/config/service.go b/idp/pkg/config/service.go new file mode 100644 index 000000000..c12faf344 --- /dev/null +++ b/idp/pkg/config/service.go @@ -0,0 +1,7 @@ +package config + +// Service defines the available service configuration. +type Service struct { + Name string + Version string +} diff --git a/idp/pkg/config/tracing.go b/idp/pkg/config/tracing.go new file mode 100644 index 000000000..8cb1d9db6 --- /dev/null +++ b/idp/pkg/config/tracing.go @@ -0,0 +1,10 @@ +package config + +// Tracing defines the available tracing configuration. +type Tracing struct { + Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;IDP_TRACING_ENABLED"` + Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;IDP_TRACING_TYPE"` + Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;IDP_TRACING_ENDPOINT"` + Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;IDP_TRACING_COLLECTOR"` + Service string `ocisConfig:"service" env:"IDP_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? +} diff --git a/ocis-pkg/indexer/index/cs3/config.go b/ocis-pkg/indexer/index/cs3/config.go index 430927d4c..9326de762 100644 --- a/ocis-pkg/indexer/index/cs3/config.go +++ b/ocis-pkg/indexer/index/cs3/config.go @@ -4,6 +4,7 @@ import ( acccfg "github.com/owncloud/ocis/accounts/pkg/config" ) +//TODO: remove? // Config represents cs3conf. Should be deprecated in favor of config.Config. type Config struct { ProviderAddr string diff --git a/ocis/pkg/command/glauth.go b/ocis/pkg/command/glauth.go index c6baacfde..d6adfa74a 100644 --- a/ocis/pkg/command/glauth.go +++ b/ocis/pkg/command/glauth.go @@ -18,9 +18,9 @@ func GLAuthCommand(cfg *config.Config) *cli.Command { return err } - if cfg.Commons != nil { - cfg.GLAuth.Commons = cfg.Commons - } + //if cfg.Commons != nil { + // cfg.GLAuth.Commons = cfg.Commons + //} return nil }, diff --git a/ocis/pkg/command/graph.go b/ocis/pkg/command/graph.go index ecc94826c..162416d24 100644 --- a/ocis/pkg/command/graph.go +++ b/ocis/pkg/command/graph.go @@ -18,9 +18,9 @@ func GraphCommand(cfg *config.Config) *cli.Command { return err } - if cfg.Commons != nil { - cfg.Graph.Commons = cfg.Commons - } + //if cfg.Commons != nil { + // cfg.Graph.Commons = cfg.Commons + //} return nil }, diff --git a/ocis/pkg/command/graphexplorer.go b/ocis/pkg/command/graphexplorer.go index 7833206b9..ede47b9c8 100644 --- a/ocis/pkg/command/graphexplorer.go +++ b/ocis/pkg/command/graphexplorer.go @@ -18,9 +18,9 @@ func GraphExplorerCommand(cfg *config.Config) *cli.Command { return err } - if cfg.Commons != nil { - cfg.Graph.Commons = cfg.Commons - } + //if cfg.Commons != nil { + // cfg.Graph.Commons = cfg.Commons + //} return nil }, diff --git a/ocis/pkg/command/idp.go b/ocis/pkg/command/idp.go index 7b35c15ba..399b9339a 100644 --- a/ocis/pkg/command/idp.go +++ b/ocis/pkg/command/idp.go @@ -21,9 +21,9 @@ func IDPCommand(cfg *config.Config) *cli.Command { return err } - if cfg.Commons != nil { - cfg.IDP.Commons = cfg.Commons - } + //if cfg.Commons != nil { + // cfg.IDP.Commons = cfg.Commons + //} return nil }, diff --git a/ocis/pkg/command/ocs.go b/ocis/pkg/command/ocs.go index 243c27696..40c79fd32 100644 --- a/ocis/pkg/command/ocs.go +++ b/ocis/pkg/command/ocs.go @@ -18,9 +18,9 @@ func OCSCommand(cfg *config.Config) *cli.Command { return err } - if cfg.Commons != nil { - cfg.OCS.Commons = cfg.Commons - } + //if cfg.Commons != nil { + // cfg.OCS.Commons = cfg.Commons + //} return nil }, diff --git a/ocis/pkg/command/proxy.go b/ocis/pkg/command/proxy.go index 7458a80d6..6b3dc5b95 100644 --- a/ocis/pkg/command/proxy.go +++ b/ocis/pkg/command/proxy.go @@ -21,9 +21,9 @@ func ProxyCommand(cfg *config.Config) *cli.Command { return err } - if cfg.Commons != nil { - cfg.Proxy.Commons = cfg.Commons - } + //if cfg.Commons != nil { + // cfg.Proxy.Commons = cfg.Commons + //} return nil }, diff --git a/ocis/pkg/command/settings.go b/ocis/pkg/command/settings.go index 90bdafc30..7980f9d0b 100644 --- a/ocis/pkg/command/settings.go +++ b/ocis/pkg/command/settings.go @@ -21,9 +21,9 @@ func SettingsCommand(cfg *config.Config) *cli.Command { return err } - if cfg.Commons != nil { - cfg.Settings.Commons = cfg.Commons - } + //if cfg.Commons != nil { + // cfg.Settings.Commons = cfg.Commons + //} return nil }, diff --git a/ocis/pkg/command/webdav.go b/ocis/pkg/command/webdav.go index 31cb2c528..ad95e8498 100644 --- a/ocis/pkg/command/webdav.go +++ b/ocis/pkg/command/webdav.go @@ -22,9 +22,9 @@ func WebDAVCommand(cfg *config.Config) *cli.Command { return err } - if cfg.Commons != nil { - cfg.WebDAV.Commons = cfg.Commons - } + //if cfg.Commons != nil { + // cfg.WebDAV.Commons = cfg.Commons + //} return nil }, diff --git a/ocs/pkg/config/config.go b/ocs/pkg/config/config.go index c1d7145ad..b8554f887 100644 --- a/ocs/pkg/config/config.go +++ b/ocs/pkg/config/config.go @@ -2,79 +2,11 @@ package config import ( "context" - - "github.com/owncloud/ocis/ocis-pkg/shared" ) -// Debug defines the available debug configuration. -type Debug struct { - Addr string `ocisConfig:"addr" env:"OCS_DEBUG_ADDR"` - Token string `ocisConfig:"token" env:"OCS_DEBUG_TOKEN"` - Pprof bool `ocisConfig:"pprof" env:"OCS_DEBUG_PPROF"` - Zpages bool `ocisConfig:"zpages" env:"OCS_DEBUG_ZPAGES"` -} - -// CORS defines the available cors configuration. -type CORS struct { - AllowedOrigins []string `ocisConfig:"allowed_origins"` - AllowedMethods []string `ocisConfig:"allowed_methods"` - AllowedHeaders []string `ocisConfig:"allowed_headers"` - AllowCredentials bool `ocisConfig:"allow_credentials"` -} - -// HTTP defines the available http configuration. -type HTTP struct { - Addr string `ocisConfig:"addr" env:"OCS_HTTP_ADDR"` - Root string `ocisConfig:"root" env:"OCS_HTTP_ROOT"` - Namespace string - CORS CORS `ocisConfig:"cors"` -} - -// Service defines the available service configuration. -type Service struct { - Name string - Version string -} - -// Tracing defines the available tracing configuration. -type Tracing struct { - Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;OCS_TRACING_ENABLED"` - Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;OCS_TRACING_TYPE"` - Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;OCS_TRACING_ENDPOINT"` - Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;OCS_TRACING_COLLECTOR"` - Service string `ocisConfig:"service" env:"OCS_TRACING_SERVICE"` -} - -// Log defines the available log configuration. -type Log struct { - Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;OCS_LOG_LEVEL"` - Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;OCS_LOG_PRETTY"` - Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;OCS_LOG_COLOR"` - File string `mapstructure:"file" env:"OCIS_LOG_FILE;OCS_LOG_FILE"` -} - -// Reva defines all available REVA configuration. -type Reva struct { - Address string `ocisConfig:"address" env:"REVA_GATEWAY"` -} - -// TokenManager is the config for using the reva token manager -type TokenManager struct { - JWTSecret string `ocisConfig:"jwt_secret" env:"OCIS_JWT_SECRET;OCS_JWT_SECRET"` -} - -// IdentityManagement keeps track of the OIDC address. This is because Reva requisite of uniqueness for users -// is based in the combination of IDP hostname + UserID. For more information see: -// https://github.com/cs3org/reva/blob/4fd0229f13fae5bc9684556a82dbbd0eced65ef9/pkg/storage/utils/decomposedfs/node/node.go#L856-L865 -type IdentityManagement struct { - Address string `ocisConfig:"address" env:"OCIS_URL;OCS_IDM_ADDRESS"` -} - // Config combines all available configuration parts. type Config struct { - *shared.Commons - - Service Service `ocisConfig:"service"` + Service Service Tracing Tracing `ocisConfig:"tracing"` Log Log `ocisConfig:"log"` @@ -95,45 +27,9 @@ type Config struct { Supervised bool } -// DefaultConfig provides default values for a config struct. -func DefaultConfig() *Config { - return &Config{ - Debug: Debug{ - Addr: "127.0.0.1:9114", - Token: "", - Pprof: false, - Zpages: false, - }, - HTTP: HTTP{ - Addr: "127.0.0.1:9110", - Root: "/ocs", - Namespace: "com.owncloud.web", - CORS: CORS{ - AllowedOrigins: []string{"*"}, - AllowedMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"}, - AllowedHeaders: []string{"Authorization", "Origin", "Content-Type", "Accept", "X-Requested-With"}, - AllowCredentials: true, - }, - }, - Service: Service{ - Name: "ocs", - }, - Tracing: Tracing{ - Enabled: false, - Type: "jaeger", - Endpoint: "", - Collector: "", - Service: "ocs", - }, - TokenManager: TokenManager{ - JWTSecret: "Pive-Fumkiu4", - }, - AccountBackend: "accounts", - Reva: Reva{Address: "127.0.0.1:9142"}, - StorageUsersDriver: "ocis", - MachineAuthAPIKey: "change-me-please", - IdentityManagement: IdentityManagement{ - Address: "https://localhost:9200", - }, - } +// IdentityManagement keeps track of the OIDC address. This is because Reva requisite of uniqueness for users +// is based in the combination of IDP hostname + UserID. For more information see: +// https://github.com/cs3org/reva/blob/4fd0229f13fae5bc9684556a82dbbd0eced65ef9/pkg/storage/utils/decomposedfs/node/node.go#L856-L865 +type IdentityManagement struct { + Address string `ocisConfig:"address" env:"OCIS_URL;OCS_IDM_ADDRESS"` } diff --git a/ocs/pkg/config/debug.go b/ocs/pkg/config/debug.go new file mode 100644 index 000000000..baef37488 --- /dev/null +++ b/ocs/pkg/config/debug.go @@ -0,0 +1,9 @@ +package config + +// Debug defines the available debug configuration. +type Debug struct { + Addr string `ocisConfig:"addr" env:"OCS_DEBUG_ADDR"` + Token string `ocisConfig:"token" env:"OCS_DEBUG_TOKEN"` + Pprof bool `ocisConfig:"pprof" env:"OCS_DEBUG_PPROF"` + Zpages bool `ocisConfig:"zpages" env:"OCS_DEBUG_ZPAGES"` +} diff --git a/ocs/pkg/config/defaultconfig.go b/ocs/pkg/config/defaultconfig.go new file mode 100644 index 000000000..428b254a4 --- /dev/null +++ b/ocs/pkg/config/defaultconfig.go @@ -0,0 +1,43 @@ +package config + +func DefaultConfig() *Config { + return &Config{ + Debug: Debug{ + Addr: "127.0.0.1:9114", + Token: "", + Pprof: false, + Zpages: false, + }, + HTTP: HTTP{ + Addr: "127.0.0.1:9110", + Root: "/ocs", + Namespace: "com.owncloud.web", + CORS: CORS{ + AllowedOrigins: []string{"*"}, + AllowedMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"}, + AllowedHeaders: []string{"Authorization", "Origin", "Content-Type", "Accept", "X-Requested-With"}, + AllowCredentials: true, + }, + }, + Service: Service{ + Name: "ocs", + }, + Tracing: Tracing{ + Enabled: false, + Type: "jaeger", + Endpoint: "", + Collector: "", + Service: "ocs", + }, + TokenManager: TokenManager{ + JWTSecret: "Pive-Fumkiu4", + }, + AccountBackend: "accounts", + Reva: Reva{Address: "127.0.0.1:9142"}, + StorageUsersDriver: "ocis", + MachineAuthAPIKey: "change-me-please", + IdentityManagement: IdentityManagement{ + Address: "https://localhost:9200", + }, + } +} diff --git a/ocs/pkg/config/http.go b/ocs/pkg/config/http.go new file mode 100644 index 000000000..b965e78b3 --- /dev/null +++ b/ocs/pkg/config/http.go @@ -0,0 +1,17 @@ +package config + +// HTTP defines the available http configuration. +type HTTP struct { + Addr string `ocisConfig:"addr" env:"OCS_HTTP_ADDR"` + Root string `ocisConfig:"root" env:"OCS_HTTP_ROOT"` + Namespace string + CORS CORS `ocisConfig:"cors"` +} + +// CORS defines the available cors configuration. +type CORS struct { + AllowedOrigins []string `ocisConfig:"allowed_origins"` + AllowedMethods []string `ocisConfig:"allowed_methods"` + AllowedHeaders []string `ocisConfig:"allowed_headers"` + AllowCredentials bool `ocisConfig:"allowed_credentials"` +} diff --git a/ocs/pkg/config/log.go b/ocs/pkg/config/log.go new file mode 100644 index 000000000..4f235f1ca --- /dev/null +++ b/ocs/pkg/config/log.go @@ -0,0 +1,9 @@ +package config + +// Log defines the available log configuration. +type Log struct { + Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;OCS_LOG_LEVEL"` + Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;OCS_LOG_PRETTY"` + Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;OCS_LOG_COLOR"` + File string `mapstructure:"file" env:"OCIS_LOG_FILE;OCS_LOG_FILE"` +} diff --git a/ocs/pkg/config/reva.go b/ocs/pkg/config/reva.go new file mode 100644 index 000000000..31f48fbb6 --- /dev/null +++ b/ocs/pkg/config/reva.go @@ -0,0 +1,11 @@ +package config + +// Reva defines all available REVA configuration. +type Reva struct { + Address string `ocisConfig:"address" env:"REVA_GATEWAY"` +} + +// TokenManager is the config for using the reva token manager +type TokenManager struct { + JWTSecret string `ocisConfig:"jwt_secret" env:"OCIS_JWT_SECRET;OCS_JWT_SECRET"` +} diff --git a/ocs/pkg/config/service.go b/ocs/pkg/config/service.go new file mode 100644 index 000000000..c12faf344 --- /dev/null +++ b/ocs/pkg/config/service.go @@ -0,0 +1,7 @@ +package config + +// Service defines the available service configuration. +type Service struct { + Name string + Version string +} diff --git a/ocs/pkg/config/tracing.go b/ocs/pkg/config/tracing.go new file mode 100644 index 000000000..f627ec382 --- /dev/null +++ b/ocs/pkg/config/tracing.go @@ -0,0 +1,10 @@ +package config + +// Tracing defines the available tracing configuration. +type Tracing struct { + Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;OCS_TRACING_ENABLED"` + Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;OCS_TRACING_TYPE"` + Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;OCS_TRACING_ENDPOINT"` + Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;OCS_TRACING_COLLECTOR"` + Service string `ocisConfig:"service" env:"OCS_TRACING_SERVICE"` +} diff --git a/proxy/pkg/config/config.go b/proxy/pkg/config/config.go index 9afd1cc72..4408550b7 100644 --- a/proxy/pkg/config/config.go +++ b/proxy/pkg/config/config.go @@ -1,52 +1,33 @@ package config -import ( - "context" - "path" +import "context" - "github.com/owncloud/ocis/ocis-pkg/config/defaults" - "github.com/owncloud/ocis/ocis-pkg/shared" -) +// Config combines all available configuration parts. +type Config struct { + Service Service -// Log defines the available log configuration. -type Log struct { - Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;PROXY_LOG_LEVEL"` - Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;PROXY_LOG_PRETTY"` - Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;PROXY_LOG_COLOR"` - File string `mapstructure:"file" env:"OCIS_LOG_FILE;PROXY_LOG_FILE"` -} + Tracing Tracing `ocisConfig:"tracing"` + Log Log `ocisConfig:"log"` + Debug Debug `ocisConfig:"debug"` -// Debug defines the available debug configuration. -type Debug struct { - Addr string `ocisConfig:"addr" env:"PROXY_DEBUG_ADDR"` - Token string `ocisConfig:"token" env:"PROXY_DEBUG_TOKEN"` - Pprof bool `ocisConfig:"pprof" env:"PROXY_DEBUG_PPROF"` - Zpages bool `ocisConfig:"zpages" env:"PROXY_DEBUG_ZPAGES"` -} + HTTP HTTP `ocisConfig:"http"` -// HTTP defines the available http configuration. -type HTTP struct { - Addr string `ocisConfig:"addr" env:"PROXY_HTTP_ADDR"` - Root string `ocisConfig:"root" env:"PROXY_HTTP_ROOT"` - Namespace string - TLSCert string `ocisConfig:"tls_cert" env:"PROXY_TRANSPORT_TLS_CERT"` - TLSKey string `ocisConfig:"tls_key" env:"PROXY_TRANSPORT_TLS_KEY"` - TLS bool `ocisConfig:"tls" env:"PROXY_TLS"` -} + Policies []Policy `ocisConfig:"policies"` + OIDC OIDC `ocisConfig:"oidc"` + TokenManager TokenManager `ocisConfig:"token_manager"` + PolicySelector *PolicySelector `ocisConfig:"policy_selector"` + Reva Reva `ocisConfig:"reva"` + PreSignedURL PreSignedURL `ocisConfig:"pre_signed_url"` + AccountBackend string `ocisConfig:"account_backend" env:"PROXY_ACCOUNT_BACKEND_TYPE"` + UserOIDCClaim string `ocisConfig:"user_oidc_claim" env:"PROXY_USER_OIDC_CLAIM"` + UserCS3Claim string `ocisConfig:"user_cs3_claim" env:"PROXY_USER_CS3_CLAIM"` + MachineAuthAPIKey string `ocisConfig:"machine_auth_api_key" env:"OCIS_MACHINE_AUTH_API_KEY;PROXY_MACHINE_AUTH_API_KEY"` + AutoprovisionAccounts bool `ocisConfig:"auto_provision_accounts" env:"PROXY_AUTOPROVISION_ACCOUNTS"` + EnableBasicAuth bool `ocisConfig:"enable_basic_auth" env:"PROXY_ENABLE_BASIC_AUTH"` + InsecureBackends bool `ocisConfig:"insecure_backends" env:"PROXY_INSECURE_BACKENDS"` -// Service defines the available service configuration. -type Service struct { - Name string - Version string -} - -// Tracing defines the available tracing configuration. -type Tracing struct { - Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;PROXY_TRACING_ENABLED"` - Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;PROXY_TRACING_TYPE"` - Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;PROXY_TRACING_ENDPOINT"` - Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;PROXY_TRACING_COLLECTOR"` - Service string `ocisConfig:"service" env:"PROXY_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? + Context context.Context + Supervised bool } // Policy enables us to use multiple directors. @@ -82,6 +63,7 @@ var ( RouteTypes = []RouteType{QueryRoute, RegexRoute, PrefixRoute} ) +// TODO: use reva config here // Reva defines all available REVA configuration. type Reva struct { Address string `ocisConfig:"address" env:"REVA_GATEWAY"` @@ -98,36 +80,6 @@ type Auth struct { CredentialsByUserAgent map[string]string `ocisConfig:""` } -// Config combines all available configuration parts. -type Config struct { - *shared.Commons - - Service Service `ocisConfig:"service"` - - Tracing Tracing `ocisConfig:"tracing"` - Log Log `ocisConfig:"log"` - Debug Debug `ocisConfig:"debug"` - - HTTP HTTP `ocisConfig:"http"` - - Policies []Policy `ocisConfig:"policies"` - OIDC OIDC `ocisConfig:"oidc"` - TokenManager TokenManager `ocisConfig:"token_manager"` - PolicySelector *PolicySelector `ocisConfig:"policy_selector"` - Reva Reva `ocisConfig:"reva"` - PreSignedURL PreSignedURL `ocisConfig:"pre_signed_url"` - AccountBackend string `ocisConfig:"account_backend" env:"PROXY_ACCOUNT_BACKEND_TYPE"` - UserOIDCClaim string `ocisConfig:"user_oidc_claim" env:"PROXY_USER_OIDC_CLAIM"` - UserCS3Claim string `ocisConfig:"user_cs3_claim" env:"PROXY_USER_CS3_CLAIM"` - MachineAuthAPIKey string `ocisConfig:"machine_auth_api_key" env:"OCIS_MACHINE_AUTH_API_KEY;PROXY_MACHINE_AUTH_API_KEY"` - AutoprovisionAccounts bool `ocisConfig:"auto_provision_accounts" env:"PROXY_AUTOPROVISION_ACCOUNTS"` - EnableBasicAuth bool `ocisConfig:"enable_basic_auth" env:"PROXY_ENABLE_BASIC_AUTH"` - InsecureBackends bool `ocisConfig:"insecure_backends" env:"PROXY_INSECURE_BACKENDS"` - - Context context.Context - Supervised bool -} - // OIDC is the config for the OpenID-Connect middleware. If set the proxy will try to authenticate every request // with the configured oidc-provider type OIDC struct { @@ -194,217 +146,3 @@ type RegexRuleConf struct { Match string `ocisConfig:"match"` Policy string `ocisConfig:"policy"` } - -// DefaultConfig provides with a working local configuration for a proxy service. -func DefaultConfig() *Config { - return &Config{ - Debug: Debug{ - Addr: "0.0.0.0:9205", - Token: "", - }, - HTTP: HTTP{ - Addr: "0.0.0.0:9200", - Root: "/", - Namespace: "com.owncloud.web", - TLSCert: path.Join(defaults.BaseDataPath(), "proxy", "server.crt"), - TLSKey: path.Join(defaults.BaseDataPath(), "proxy", "server.key"), - TLS: true, - }, - Service: Service{ - Name: "proxy", - }, - Tracing: Tracing{ - Type: "jaeger", - Endpoint: "", - Collector: "", - Service: "proxy", - }, - OIDC: OIDC{ - Issuer: "https://localhost:9200", - Insecure: true, - //Insecure: true, - UserinfoCache: UserinfoCache{ - Size: 1024, - TTL: 10, - }, - }, - TokenManager: TokenManager{ - JWTSecret: "Pive-Fumkiu4", - }, - PolicySelector: nil, - Reva: Reva{ - Address: "127.0.0.1:9142", - }, - PreSignedURL: PreSignedURL{ - AllowedHTTPMethods: []string{"GET"}, - Enabled: true, - }, - AccountBackend: "accounts", - UserOIDCClaim: "email", - UserCS3Claim: "mail", - MachineAuthAPIKey: "change-me-please", - AutoprovisionAccounts: false, - EnableBasicAuth: false, - InsecureBackends: false, - // TODO: enable - //Policies: defaultPolicies(), - } -} - -func DefaultPolicies() []Policy { - return []Policy{ - { - Name: "ocis", - Routes: []Route{ - { - Endpoint: "/", - Backend: "http://localhost:9100", - }, - { - Endpoint: "/.well-known/", - Backend: "http://localhost:9130", - }, - { - Endpoint: "/konnect/", - Backend: "http://localhost:9130", - }, - { - Endpoint: "/signin/", - Backend: "http://localhost:9130", - }, - { - Endpoint: "/archiver", - Backend: "http://localhost:9140", - }, - { - Type: RegexRoute, - Endpoint: "/ocs/v[12].php/cloud/(users?|groups)", // we have `user`, `users` and `groups` in ocis-ocs - Backend: "http://localhost:9110", - }, - { - Endpoint: "/ocs/", - Backend: "http://localhost:9140", - }, - { - Type: QueryRoute, - Endpoint: "/remote.php/?preview=1", - Backend: "http://localhost:9115", - }, - { - Endpoint: "/remote.php/", - Backend: "http://localhost:9140", - }, - { - Endpoint: "/dav/", - Backend: "http://localhost:9140", - }, - { - Endpoint: "/webdav/", - Backend: "http://localhost:9140", - }, - { - Endpoint: "/status.php", - Backend: "http://localhost:9140", - }, - { - Endpoint: "/index.php/", - Backend: "http://localhost:9140", - }, - { - Endpoint: "/data", - Backend: "http://localhost:9140", - }, - { - Endpoint: "/app/", - Backend: "http://localhost:9140", - }, - { - Endpoint: "/graph/", - Backend: "http://localhost:9120", - }, - { - Endpoint: "/graph-explorer", - Backend: "http://localhost:9135", - }, - // if we were using the go micro api gateway we could look up the endpoint in the registry dynamically - { - Endpoint: "/api/v0/accounts", - Backend: "http://localhost:9181", - }, - // TODO the lookup needs a better mechanism - { - Endpoint: "/accounts.js", - Backend: "http://localhost:9181", - }, - { - Endpoint: "/api/v0/settings", - Backend: "http://localhost:9190", - }, - { - Endpoint: "/settings.js", - Backend: "http://localhost:9190", - }, - }, - }, - { - Name: "oc10", - Routes: []Route{ - { - Endpoint: "/", - Backend: "http://localhost:9100", - }, - { - Endpoint: "/.well-known/", - Backend: "http://localhost:9130", - }, - { - Endpoint: "/konnect/", - Backend: "http://localhost:9130", - }, - { - Endpoint: "/signin/", - Backend: "http://localhost:9130", - }, - { - Endpoint: "/archiver", - Backend: "http://localhost:9140", - }, - { - Endpoint: "/ocs/", - Backend: "https://demo.owncloud.com", - ApacheVHost: true, - }, - { - Endpoint: "/remote.php/", - Backend: "https://demo.owncloud.com", - ApacheVHost: true, - }, - { - Endpoint: "/dav/", - Backend: "https://demo.owncloud.com", - ApacheVHost: true, - }, - { - Endpoint: "/webdav/", - Backend: "https://demo.owncloud.com", - ApacheVHost: true, - }, - { - Endpoint: "/status.php", - Backend: "https://demo.owncloud.com", - ApacheVHost: true, - }, - { - Endpoint: "/index.php/", - Backend: "https://demo.owncloud.com", - ApacheVHost: true, - }, - { - Endpoint: "/data", - Backend: "https://demo.owncloud.com", - ApacheVHost: true, - }, - }, - }, - } -} diff --git a/proxy/pkg/config/debug.go b/proxy/pkg/config/debug.go new file mode 100644 index 000000000..1c450cc4d --- /dev/null +++ b/proxy/pkg/config/debug.go @@ -0,0 +1,9 @@ +package config + +// Debug defines the available debug configuration. +type Debug struct { + Addr string `ocisConfig:"addr" env:"PROXY_DEBUG_ADDR"` + Token string `ocisConfig:"token" env:"PROXY_DEBUG_TOKEN"` + Pprof bool `ocisConfig:"pprof" env:"PROXY_DEBUG_PPROF"` + Zpages bool `ocisConfig:"zpages" env:"PROXY_DEBUG_ZPAGES"` +} diff --git a/proxy/pkg/config/defaultconfig.go b/proxy/pkg/config/defaultconfig.go new file mode 100644 index 000000000..ea1940a57 --- /dev/null +++ b/proxy/pkg/config/defaultconfig.go @@ -0,0 +1,220 @@ +package config + +import ( + "path" + + "github.com/owncloud/ocis/ocis-pkg/config/defaults" +) + +func DefaultConfig() *Config { + return &Config{ + Debug: Debug{ + Addr: "0.0.0.0:9205", + Token: "", + }, + HTTP: HTTP{ + Addr: "0.0.0.0:9200", + Root: "/", + Namespace: "com.owncloud.web", + TLSCert: path.Join(defaults.BaseDataPath(), "proxy", "server.crt"), + TLSKey: path.Join(defaults.BaseDataPath(), "proxy", "server.key"), + TLS: true, + }, + Service: Service{ + Name: "proxy", + }, + Tracing: Tracing{ + Type: "jaeger", + Endpoint: "", + Collector: "", + Service: "proxy", + }, + OIDC: OIDC{ + Issuer: "https://localhost:9200", + Insecure: true, + //Insecure: true, + UserinfoCache: UserinfoCache{ + Size: 1024, + TTL: 10, + }, + }, + TokenManager: TokenManager{ + JWTSecret: "Pive-Fumkiu4", + }, + PolicySelector: nil, + Reva: Reva{ + Address: "127.0.0.1:9142", + }, + PreSignedURL: PreSignedURL{ + AllowedHTTPMethods: []string{"GET"}, + Enabled: true, + }, + AccountBackend: "accounts", + UserOIDCClaim: "email", + UserCS3Claim: "mail", + MachineAuthAPIKey: "change-me-please", + AutoprovisionAccounts: false, + EnableBasicAuth: false, + InsecureBackends: false, + // TODO: enable + //Policies: defaultPolicies(), + } +} + +func DefaultPolicies() []Policy { + return []Policy{ + { + Name: "ocis", + Routes: []Route{ + { + Endpoint: "/", + Backend: "http://localhost:9100", + }, + { + Endpoint: "/.well-known/", + Backend: "http://localhost:9130", + }, + { + Endpoint: "/konnect/", + Backend: "http://localhost:9130", + }, + { + Endpoint: "/signin/", + Backend: "http://localhost:9130", + }, + { + Endpoint: "/archiver", + Backend: "http://localhost:9140", + }, + { + Type: RegexRoute, + Endpoint: "/ocs/v[12].php/cloud/(users?|groups)", // we have `user`, `users` and `groups` in ocis-ocs + Backend: "http://localhost:9110", + }, + { + Endpoint: "/ocs/", + Backend: "http://localhost:9140", + }, + { + Type: QueryRoute, + Endpoint: "/remote.php/?preview=1", + Backend: "http://localhost:9115", + }, + { + Endpoint: "/remote.php/", + Backend: "http://localhost:9140", + }, + { + Endpoint: "/dav/", + Backend: "http://localhost:9140", + }, + { + Endpoint: "/webdav/", + Backend: "http://localhost:9140", + }, + { + Endpoint: "/status.php", + Backend: "http://localhost:9140", + }, + { + Endpoint: "/index.php/", + Backend: "http://localhost:9140", + }, + { + Endpoint: "/data", + Backend: "http://localhost:9140", + }, + { + Endpoint: "/app/", + Backend: "http://localhost:9140", + }, + { + Endpoint: "/graph/", + Backend: "http://localhost:9120", + }, + { + Endpoint: "/graph-explorer", + Backend: "http://localhost:9135", + }, + // if we were using the go micro api gateway we could look up the endpoint in the registry dynamically + { + Endpoint: "/api/v0/accounts", + Backend: "http://localhost:9181", + }, + // TODO the lookup needs a better mechanism + { + Endpoint: "/accounts.js", + Backend: "http://localhost:9181", + }, + { + Endpoint: "/api/v0/settings", + Backend: "http://localhost:9190", + }, + { + Endpoint: "/settings.js", + Backend: "http://localhost:9190", + }, + }, + }, + { + Name: "oc10", + Routes: []Route{ + { + Endpoint: "/", + Backend: "http://localhost:9100", + }, + { + Endpoint: "/.well-known/", + Backend: "http://localhost:9130", + }, + { + Endpoint: "/konnect/", + Backend: "http://localhost:9130", + }, + { + Endpoint: "/signin/", + Backend: "http://localhost:9130", + }, + { + Endpoint: "/archiver", + Backend: "http://localhost:9140", + }, + { + Endpoint: "/ocs/", + Backend: "https://demo.owncloud.com", + ApacheVHost: true, + }, + { + Endpoint: "/remote.php/", + Backend: "https://demo.owncloud.com", + ApacheVHost: true, + }, + { + Endpoint: "/dav/", + Backend: "https://demo.owncloud.com", + ApacheVHost: true, + }, + { + Endpoint: "/webdav/", + Backend: "https://demo.owncloud.com", + ApacheVHost: true, + }, + { + Endpoint: "/status.php", + Backend: "https://demo.owncloud.com", + ApacheVHost: true, + }, + { + Endpoint: "/index.php/", + Backend: "https://demo.owncloud.com", + ApacheVHost: true, + }, + { + Endpoint: "/data", + Backend: "https://demo.owncloud.com", + ApacheVHost: true, + }, + }, + }, + } +} diff --git a/proxy/pkg/config/http.go b/proxy/pkg/config/http.go new file mode 100644 index 000000000..8ab553063 --- /dev/null +++ b/proxy/pkg/config/http.go @@ -0,0 +1,11 @@ +package config + +// HTTP defines the available http configuration. +type HTTP struct { + Addr string `ocisConfig:"addr" env:"PROXY_HTTP_ADDR"` + Root string `ocisConfig:"root" env:"PROXY_HTTP_ROOT"` + Namespace string + TLSCert string `ocisConfig:"tls_cert" env:"PROXY_TRANSPORT_TLS_CERT"` + TLSKey string `ocisConfig:"tls_key" env:"PROXY_TRANSPORT_TLS_KEY"` + TLS bool `ocisConfig:"tls" env:"PROXY_TLS"` +} diff --git a/proxy/pkg/config/log.go b/proxy/pkg/config/log.go new file mode 100644 index 000000000..54612fc20 --- /dev/null +++ b/proxy/pkg/config/log.go @@ -0,0 +1,9 @@ +package config + +// Log defines the available log configuration. +type Log struct { + Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;PROXY_LOG_LEVEL"` + Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;PROXY_LOG_PRETTY"` + Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;PROXY_LOG_COLOR"` + File string `mapstructure:"file" env:"OCIS_LOG_FILE;PROXY_LOG_FILE"` +} diff --git a/proxy/pkg/config/service.go b/proxy/pkg/config/service.go new file mode 100644 index 000000000..c12faf344 --- /dev/null +++ b/proxy/pkg/config/service.go @@ -0,0 +1,7 @@ +package config + +// Service defines the available service configuration. +type Service struct { + Name string + Version string +} diff --git a/proxy/pkg/config/tracing.go b/proxy/pkg/config/tracing.go new file mode 100644 index 000000000..914726759 --- /dev/null +++ b/proxy/pkg/config/tracing.go @@ -0,0 +1,10 @@ +package config + +// Tracing defines the available tracing configuration. +type Tracing struct { + Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;PROXY_TRACING_ENABLED"` + Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;PROXY_TRACING_TYPE"` + Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;PROXY_TRACING_ENDPOINT"` + Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;PROXY_TRACING_COLLECTOR"` + Service string `ocisConfig:"service" env:"PROXY_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? +} diff --git a/settings/pkg/config/config.go b/settings/pkg/config/config.go index fadd6722c..18284a56c 100644 --- a/settings/pkg/config/config.go +++ b/settings/pkg/config/config.go @@ -2,82 +2,11 @@ package config import ( "context" - "path" - - "github.com/owncloud/ocis/ocis-pkg/shared" - - "github.com/owncloud/ocis/ocis-pkg/config/defaults" ) -// Debug defines the available debug configuration. -type Debug struct { - Addr string `ocisConfig:"addr" env:"SETTINGS_DEBUG_ADDR"` - Token string `ocisConfig:"token" env:"SETTINGS_DEBUG_TOKEN"` - Pprof bool `ocisConfig:"pprof" env:"SETTINGS_DEBUG_PPROF"` - Zpages bool `ocisConfig:"zpages" env:"SETTINGS_DEBUG_ZPAGES"` -} - -// CORS defines the available cors configuration. -type CORS struct { - AllowedOrigins []string `ocisConfig:"allowed_origins"` - AllowedMethods []string `ocisConfig:"allowed_methods"` - AllowedHeaders []string `ocisConfig:"allowed_headers"` - AllowCredentials bool `ocisConfig:"allow_credentials"` -} - -// HTTP defines the available http configuration. -type HTTP struct { - Addr string `ocisConfig:"addr" env:"SETTINGS_HTTP_ADDR"` - Namespace string - Root string `ocisConfig:"root" env:"SETTINGS_HTTP_ROOT"` - CacheTTL int `ocisConfig:"cache_ttl" env:"SETTINGS_CACHE_TTL"` - CORS CORS `ocisConfig:"cors"` -} - -// GRPC defines the available grpc configuration. -type GRPC struct { - Addr string `ocisConfig:"addr" env:"SETTINGS_GRPC_ADDR"` - Namespace string -} - -// Service defines the available service configuration. -type Service struct { - Name string - Version string -} - -// Tracing defines the available tracing configuration. -type Tracing struct { - Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;SETTINGS_TRACING_ENABLED"` - Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;SETTINGS_TRACING_TYPE"` - Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;SETTINGS_TRACING_ENDPOINT"` - Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;SETTINGS_TRACING_COLLECTOR"` - Service string `ocisConfig:"service" env:"SETTINGS_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? -} - -// Log defines the available log configuration. -type Log struct { - Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;SETTINGS_LOG_LEVEL"` - Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;SETTINGS_LOG_PRETTY"` - Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;SETTINGS_LOG_COLOR"` - File string `mapstructure:"file" env:"OCIS_LOG_FILE;SETTINGS_LOG_FILE"` -} - -// Asset defines the available asset configuration. -type Asset struct { - Path string `ocisConfig:"path" env:"SETTINGS_ASSET_PATH"` -} - -// TokenManager is the config for using the reva token manager -type TokenManager struct { - JWTSecret string `ocisConfig:"jwt_secret" env:"OCIS_JWT_SECRET;SETTINGS_JWT_SECRET"` -} - // Config combines all available configuration parts. type Config struct { - *shared.Commons - - Service Service `ocisConfig:"service"` + Service Service Tracing Tracing `ocisConfig:"tracing"` Log Log `ocisConfig:"log"` @@ -94,47 +23,8 @@ type Config struct { Supervised bool } -// DefaultConfig provides sane bootstrapping defaults. -func DefaultConfig() *Config { - return &Config{ - Service: Service{ - Name: "settings", - }, - Debug: Debug{ - Addr: "127.0.0.1:9194", - Token: "", - Pprof: false, - Zpages: false, - }, - HTTP: HTTP{ - Addr: "127.0.0.1:9190", - Namespace: "com.owncloud.web", - Root: "/", - CacheTTL: 604800, // 7 days - CORS: CORS{ - AllowedOrigins: []string{"*"}, - AllowedMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"}, - AllowedHeaders: []string{"Authorization", "Origin", "Content-Type", "Accept", "X-Requested-With"}, - AllowCredentials: true, - }, - }, - GRPC: GRPC{ - Addr: "127.0.0.1:9191", - Namespace: "com.owncloud.api", - }, - Tracing: Tracing{ - Enabled: false, - Type: "jaeger", - Endpoint: "", - Collector: "", - Service: "settings", - }, - DataPath: path.Join(defaults.BaseDataPath(), "settings"), - Asset: Asset{ - Path: "", - }, - TokenManager: TokenManager{ - JWTSecret: "Pive-Fumkiu4", - }, - } +// Asset defines the available asset configuration. +type Asset struct { + Path string `ocisConfig:"path" env:"SETTINGS_ASSET_PATH"` } + diff --git a/settings/pkg/config/debug.go b/settings/pkg/config/debug.go new file mode 100644 index 000000000..5cec3b97b --- /dev/null +++ b/settings/pkg/config/debug.go @@ -0,0 +1,9 @@ +package config + +// Debug defines the available debug configuration. +type Debug struct { + Addr string `ocisConfig:"addr" env:"SETTINGS_DEBUG_ADDR"` + Token string `ocisConfig:"token" env:"SETTINGS_DEBUG_TOKEN"` + Pprof bool `ocisConfig:"pprof" env:"SETTINGS_DEBUG_PPROF"` + Zpages bool `ocisConfig:"zpages" env:"SETTINGS_DEBUG_ZPAGES"` +} diff --git a/settings/pkg/config/defaultconfig.go b/settings/pkg/config/defaultconfig.go new file mode 100644 index 000000000..100c1e80f --- /dev/null +++ b/settings/pkg/config/defaultconfig.go @@ -0,0 +1,51 @@ +package config + +import ( + "path" + + "github.com/owncloud/ocis/ocis-pkg/config/defaults" +) + +func DefaultConfig() *Config { + return &Config{ + Service: Service{ + Name: "settings", + }, + Debug: Debug{ + Addr: "127.0.0.1:9194", + Token: "", + Pprof: false, + Zpages: false, + }, + HTTP: HTTP{ + Addr: "127.0.0.1:9190", + Namespace: "com.owncloud.web", + Root: "/", + CacheTTL: 604800, // 7 days + CORS: CORS{ + AllowedOrigins: []string{"*"}, + AllowedMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"}, + AllowedHeaders: []string{"Authorization", "Origin", "Content-Type", "Accept", "X-Requested-With"}, + AllowCredentials: true, + }, + }, + GRPC: GRPC{ + Addr: "127.0.0.1:9191", + Namespace: "com.owncloud.api", + }, + Tracing: Tracing{ + Enabled: false, + Type: "jaeger", + Endpoint: "", + Collector: "", + Service: "settings", + }, + DataPath: path.Join(defaults.BaseDataPath(), "settings"), + Asset: Asset{ + Path: "", + }, + TokenManager: TokenManager{ + JWTSecret: "Pive-Fumkiu4", + }, + } +} diff --git a/settings/pkg/config/grpc.go b/settings/pkg/config/grpc.go new file mode 100644 index 000000000..016b61fa9 --- /dev/null +++ b/settings/pkg/config/grpc.go @@ -0,0 +1,7 @@ +package config + +// GRPC defines the available grpc configuration. +type GRPC struct { + Addr string `ocisConfig:"addr" env:"SETTINGS_GRPC_ADDR"` + Namespace string +} diff --git a/settings/pkg/config/http.go b/settings/pkg/config/http.go new file mode 100644 index 000000000..f2099febf --- /dev/null +++ b/settings/pkg/config/http.go @@ -0,0 +1,18 @@ +package config + +// HTTP defines the available http configuration. +type HTTP struct { + Addr string `ocisConfig:"addr" env:"SETTINGS_HTTP_ADDR"` + Namespace string + Root string `ocisConfig:"root" env:"SETTINGS_HTTP_ROOT"` + CacheTTL int `ocisConfig:"cache_ttl" env:"SETTINGS_CACHE_TTL"` + CORS CORS `ocisConfig:"cors"` +} + +// CORS defines the available cors configuration. +type CORS struct { + AllowedOrigins []string `ocisConfig:"allowed_origins"` + AllowedMethods []string `ocisConfig:"allowed_methods"` + AllowedHeaders []string `ocisConfig:"allowed_headers"` + AllowCredentials bool `ocisConfig:"allowed_credentials"` +} diff --git a/settings/pkg/config/log.go b/settings/pkg/config/log.go new file mode 100644 index 000000000..48247bd17 --- /dev/null +++ b/settings/pkg/config/log.go @@ -0,0 +1,9 @@ +package config + +// Log defines the available log configuration. +type Log struct { + Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;SETTINGS_LOG_LEVEL"` + Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;SETTINGS_LOG_PRETTY"` + Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;SETTINGS_LOG_COLOR"` + File string `mapstructure:"file" env:"OCIS_LOG_FILE;SETTINGS_LOG_FILE"` +} diff --git a/settings/pkg/config/reva.go b/settings/pkg/config/reva.go new file mode 100644 index 000000000..5427747df --- /dev/null +++ b/settings/pkg/config/reva.go @@ -0,0 +1,6 @@ +package config + +// TokenManager is the config for using the reva token manager +type TokenManager struct { + JWTSecret string `ocisConfig:"jwt_secret" env:"OCIS_JWT_SECRET;SETTINGS_JWT_SECRET"` +} diff --git a/settings/pkg/config/service.go b/settings/pkg/config/service.go new file mode 100644 index 000000000..c12faf344 --- /dev/null +++ b/settings/pkg/config/service.go @@ -0,0 +1,7 @@ +package config + +// Service defines the available service configuration. +type Service struct { + Name string + Version string +} diff --git a/settings/pkg/config/tracing.go b/settings/pkg/config/tracing.go new file mode 100644 index 000000000..543298663 --- /dev/null +++ b/settings/pkg/config/tracing.go @@ -0,0 +1,10 @@ +package config + +// Tracing defines the available tracing configuration. +type Tracing struct { + Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;SETTINGS_TRACING_ENABLED"` + Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;SETTINGS_TRACING_TYPE"` + Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;SETTINGS_TRACING_ENDPOINT"` + Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;SETTINGS_TRACING_COLLECTOR"` + Service string `ocisConfig:"service" env:"SETTINGS_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? +} diff --git a/storage/pkg/command/appprovider.go b/storage/pkg/command/appprovider.go index 3ac4f71d4..86ccac4f0 100644 --- a/storage/pkg/command/appprovider.go +++ b/storage/pkg/command/appprovider.go @@ -129,7 +129,7 @@ type AppProviderSutureService struct { // NewAppProvider creates a new store.AppProviderSutureService func NewAppProvider(cfg *ociscfg.Config) suture.Service { - cfg.Storage.Commons = cfg.Commons + ////cfg.Storage.Commons = cfg.Commons return AppProviderSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/authbasic.go b/storage/pkg/command/authbasic.go index 40bd71ed1..1d57341f1 100644 --- a/storage/pkg/command/authbasic.go +++ b/storage/pkg/command/authbasic.go @@ -148,7 +148,7 @@ type AuthBasicSutureService struct { // NewAuthBasicSutureService creates a new store.AuthBasicSutureService func NewAuthBasic(cfg *ociscfg.Config) suture.Service { - cfg.Storage.Commons = cfg.Commons + //cfg.Storage.Commons = cfg.Commons return AuthBasicSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/authbearer.go b/storage/pkg/command/authbearer.go index 4424a6ef2..7c2e23a84 100644 --- a/storage/pkg/command/authbearer.go +++ b/storage/pkg/command/authbearer.go @@ -124,7 +124,7 @@ type AuthBearerSutureService struct { // NewAuthBearerSutureService creates a new gateway.AuthBearerSutureService func NewAuthBearer(cfg *ociscfg.Config) suture.Service { - cfg.Storage.Commons = cfg.Commons + //cfg.Storage.Commons = cfg.Commons return AuthBearerSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/authmachine.go b/storage/pkg/command/authmachine.go index 80c70f832..9bce040bf 100644 --- a/storage/pkg/command/authmachine.go +++ b/storage/pkg/command/authmachine.go @@ -120,7 +120,7 @@ type AuthMachineSutureService struct { // NewAuthMachineSutureService creates a new gateway.AuthMachineSutureService func NewAuthMachine(cfg *ociscfg.Config) suture.Service { - cfg.Storage.Commons = cfg.Commons + //cfg.Storage.Commons = cfg.Commons return AuthMachineSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/frontend.go b/storage/pkg/command/frontend.go index db0135387..c3394f84b 100644 --- a/storage/pkg/command/frontend.go +++ b/storage/pkg/command/frontend.go @@ -339,7 +339,7 @@ type FrontendSutureService struct { // NewFrontend creates a new frontend.FrontendSutureService func NewFrontend(cfg *ociscfg.Config) suture.Service { - cfg.Storage.Commons = cfg.Commons + //cfg.Storage.Commons = cfg.Commons return FrontendSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/gateway.go b/storage/pkg/command/gateway.go index 687e52ebb..a2128c77b 100644 --- a/storage/pkg/command/gateway.go +++ b/storage/pkg/command/gateway.go @@ -352,7 +352,7 @@ type GatewaySutureService struct { // NewGatewaySutureService creates a new gateway.GatewaySutureService func NewGateway(cfg *ociscfg.Config) suture.Service { - cfg.Storage.Commons = cfg.Commons + //cfg.Storage.Commons = cfg.Commons return GatewaySutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/groups.go b/storage/pkg/command/groups.go index 625a23177..0d37c4149 100644 --- a/storage/pkg/command/groups.go +++ b/storage/pkg/command/groups.go @@ -162,7 +162,7 @@ type GroupSutureService struct { // NewGroupProviderSutureService creates a new storage.GroupProvider func NewGroupProvider(cfg *ociscfg.Config) suture.Service { - cfg.Storage.Commons = cfg.Commons + //cfg.Storage.Commons = cfg.Commons return GroupSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/sharing.go b/storage/pkg/command/sharing.go index 1d8c032c8..7229b7f28 100644 --- a/storage/pkg/command/sharing.go +++ b/storage/pkg/command/sharing.go @@ -188,7 +188,7 @@ type SharingSutureService struct { // NewSharingSutureService creates a new store.SharingSutureService func NewSharing(cfg *ociscfg.Config) suture.Service { - cfg.Storage.Commons = cfg.Commons + //cfg.Storage.Commons = cfg.Commons return SharingSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/storagehome.go b/storage/pkg/command/storagehome.go index 516eda4ac..c3a2a312a 100644 --- a/storage/pkg/command/storagehome.go +++ b/storage/pkg/command/storagehome.go @@ -147,7 +147,7 @@ type StorageHomeSutureService struct { // NewStorageHomeSutureService creates a new storage.StorageHomeSutureService func NewStorageHome(cfg *ociscfg.Config) suture.Service { - cfg.Storage.Commons = cfg.Commons + //cfg.Storage.Commons = cfg.Commons return StorageHomeSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/storagemetadata.go b/storage/pkg/command/storagemetadata.go index 8ba574a27..6ff7a2819 100644 --- a/storage/pkg/command/storagemetadata.go +++ b/storage/pkg/command/storagemetadata.go @@ -167,7 +167,7 @@ type MetadataSutureService struct { // NewSutureService creates a new storagemetadata.SutureService func NewStorageMetadata(cfg *ociscfg.Config) suture.Service { - cfg.Storage.Commons = cfg.Commons + //cfg.Storage.Commons = cfg.Commons return MetadataSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/storagepubliclink.go b/storage/pkg/command/storagepubliclink.go index 9bd908799..f61b32a78 100644 --- a/storage/pkg/command/storagepubliclink.go +++ b/storage/pkg/command/storagepubliclink.go @@ -127,7 +127,7 @@ type StoragePublicLinkSutureService struct { // NewStoragePublicLinkSutureService creates a new storage.StoragePublicLinkSutureService func NewStoragePublicLink(cfg *ociscfg.Config) suture.Service { - cfg.Storage.Commons = cfg.Commons + //cfg.Storage.Commons = cfg.Commons return StoragePublicLinkSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/storageusers.go b/storage/pkg/command/storageusers.go index 266eb2dfb..0d61415d1 100644 --- a/storage/pkg/command/storageusers.go +++ b/storage/pkg/command/storageusers.go @@ -147,7 +147,7 @@ type StorageUsersSutureService struct { // NewStorageUsersSutureService creates a new storage.StorageUsersSutureService func NewStorageUsers(cfg *ociscfg.Config) suture.Service { - cfg.Storage.Commons = cfg.Commons + //cfg.Storage.Commons = cfg.Commons return StorageUsersSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/users.go b/storage/pkg/command/users.go index b7205a542..908865ae7 100644 --- a/storage/pkg/command/users.go +++ b/storage/pkg/command/users.go @@ -183,7 +183,7 @@ type UserProviderSutureService struct { // NewUserProviderSutureService creates a new storage.UserProvider func NewUserProvider(cfg *ociscfg.Config) suture.Service { - cfg.Storage.Commons = cfg.Commons + //cfg.Storage.Commons = cfg.Commons return UserProviderSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/config/config.go b/storage/pkg/config/config.go index 23e8f4794..35d544a98 100644 --- a/storage/pkg/config/config.go +++ b/storage/pkg/config/config.go @@ -2,34 +2,21 @@ package config import ( "context" - "os" - "path" - - "github.com/owncloud/ocis/ocis-pkg/config/defaults" "github.com/owncloud/ocis/ocis-pkg/shared" ) -// Service defines the available service configuration. -type Service struct { - Name string - Version string -} +// Config combines all available configuration parts. +type Config struct { + Service Service -// Log defines the available logging configuration. -type Log struct { - Level string `ocisConfig:"level"` - Pretty bool `ocisConfig:"pretty"` - Color bool `ocisConfig:"color"` - File string `ocisConfig:"file"` -} + Tracing Tracing `ocisConfig:"tracing"` + Log Log `ocisConfig:"log"` + Debug Debug `ocisConfig:"debug"` -// Debug defines the available debug configuration. -type Debug struct { - Addr string `ocisConfig:"addr"` - Token string `ocisConfig:"token"` - Pprof bool `ocisConfig:"pprof"` - Zpages bool `ocisConfig:"zpages"` + Reva Reva `ocisConfig:"reva"` + + Asset Asset `ocisConfig:"asset"` } // Gateway defines the available gateway configuration. @@ -496,470 +483,11 @@ type Reva struct { DefaultUploadProtocol string `ocisConfig:"default_upload_protocol"` } -// Tracing defines the available tracing configuration. -type Tracing struct { - Enabled bool `ocisConfig:"enabled"` - Type string `ocisConfig:"type"` - Endpoint string `ocisConfig:"endpoint"` - Collector string `ocisConfig:"collector"` - Service string `ocisConfig:"service"` -} - // Asset defines the available asset configuration. type Asset struct { Path string `ocisConfig:"path"` } -// Config combines all available configuration parts. -type Config struct { - *shared.Commons - - Service Service `ocisConfig:"service"` - - Tracing Tracing `ocisConfig:"tracing"` - Log Log `ocisConfig:"log"` - Debug Debug `ocisConfig:"debug"` - - Reva Reva `ocisConfig:"reva"` - - Asset Asset `ocisConfig:"asset"` -} - -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, - }, - ServiceUserUUID: "95cb8724-03b2-11eb-a0a6-c33ef8ef53ad", - 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, - }, - ServiceUserUUID: "95cb8724-03b2-11eb-a0a6-c33ef8ef53ad", - Region: "default", - AccessKey: "", - SecretKey: "", - Endpoint: "", - Bucket: "", - }, - 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: []string{"datagateway", "ocdav", "ocs", "appprovider"}, - 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", - DebugAddr: "127.0.0.1:9145", - GRPCNetwork: "tcp", - GRPCAddr: "127.0.0.1:9144", - Services: []string{"userprovider"}, - }, - 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", - Services: []string{"groupprovider"}, - }, - 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", - Services: []string{"authprovider"}, - Endpoint: "localhost:9146", - }, - AuthBearer: Port{ - GRPCNetwork: "tcp", - GRPCAddr: "127.0.0.1:9148", - DebugAddr: "127.0.0.1:9149", - Services: []string{"authprovider"}, - Endpoint: "localhost:9148", - }, - AuthMachine: Port{ - GRPCNetwork: "tcp", - GRPCAddr: "127.0.0.1:9166", - DebugAddr: "127.0.0.1:9167", - Services: []string{"authprovider"}, - Endpoint: "localhost:9166", - }, - 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", - Services: []string{"usershareprovider", "publicshareprovider"}, - }, - 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", - AlternativeID: "1284d238-aa92-42ce-bdc4-0b0000009154", - 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", - MountID: "e1a73ede-549b-4226-abdf-40e69ca8230d", - }, - 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/data", - 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", - Services: []string{"appprovider"}, - }, - ExternalAddr: "127.0.0.1:9164", - WopiDriver: WopiDriver{}, - AppsURL: "/app/list", - OpenURL: "/app/open", - NewURL: "/app/new", - }, - Configs: nil, - UploadMaxChunkSize: 1e+8, - UploadHTTPMethodOverride: "", - ChecksumSupportedTypes: []string{"sha1", "md5", "adler32"}, - 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. diff --git a/storage/pkg/config/debug.go b/storage/pkg/config/debug.go new file mode 100644 index 000000000..f9283a9b2 --- /dev/null +++ b/storage/pkg/config/debug.go @@ -0,0 +1,9 @@ +package config + +// Debug defines the available debug configuration. +type Debug struct { + Addr string `ocisConfig:"addr" env:"STORAGE_DEBUG_ADDR"` + Token string `ocisConfig:"token" env:"STORAGE_DEBUG_TOKEN"` + Pprof bool `ocisConfig:"pprof" env:"STORAGE_DEBUG_PPROF"` + Zpages bool `ocisConfig:"zpages" env:"STORAGE_DEBUG_ZPAGES"` +} diff --git a/storage/pkg/config/defaultconfig.go b/storage/pkg/config/defaultconfig.go new file mode 100644 index 000000000..95cc57c1a --- /dev/null +++ b/storage/pkg/config/defaultconfig.go @@ -0,0 +1,443 @@ +package config + +import ( + "os" + "path" + + "github.com/owncloud/ocis/ocis-pkg/config/defaults" +) + +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, + }, + ServiceUserUUID: "95cb8724-03b2-11eb-a0a6-c33ef8ef53ad", + 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, + }, + ServiceUserUUID: "95cb8724-03b2-11eb-a0a6-c33ef8ef53ad", + Region: "default", + AccessKey: "", + SecretKey: "", + Endpoint: "", + Bucket: "", + }, + 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: []string{"datagateway", "ocdav", "ocs", "appprovider"}, + 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", + DebugAddr: "127.0.0.1:9145", + GRPCNetwork: "tcp", + GRPCAddr: "127.0.0.1:9144", + Services: []string{"userprovider"}, + }, + 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", + Services: []string{"groupprovider"}, + }, + 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", + Services: []string{"authprovider"}, + Endpoint: "localhost:9146", + }, + AuthBearer: Port{ + GRPCNetwork: "tcp", + GRPCAddr: "127.0.0.1:9148", + DebugAddr: "127.0.0.1:9149", + Services: []string{"authprovider"}, + Endpoint: "localhost:9148", + }, + AuthMachine: Port{ + GRPCNetwork: "tcp", + GRPCAddr: "127.0.0.1:9166", + DebugAddr: "127.0.0.1:9167", + Services: []string{"authprovider"}, + Endpoint: "localhost:9166", + }, + 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", + Services: []string{"usershareprovider", "publicshareprovider"}, + }, + 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", + AlternativeID: "1284d238-aa92-42ce-bdc4-0b0000009154", + 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", + MountID: "e1a73ede-549b-4226-abdf-40e69ca8230d", + }, + 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/data", + 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", + Services: []string{"appprovider"}, + }, + ExternalAddr: "127.0.0.1:9164", + WopiDriver: WopiDriver{}, + AppsURL: "/app/list", + OpenURL: "/app/open", + NewURL: "/app/new", + }, + Configs: nil, + UploadMaxChunkSize: 1e+8, + UploadHTTPMethodOverride: "", + ChecksumSupportedTypes: []string{"sha1", "md5", "adler32"}, + ChecksumPreferredUploadType: "", + DefaultUploadProtocol: "tus", + }, + Tracing: Tracing{ + Service: "storage", + Type: "jaeger", + }, + Asset: Asset{}, + } +} diff --git a/storage/pkg/config/grpc.go b/storage/pkg/config/grpc.go new file mode 100644 index 000000000..016b61fa9 --- /dev/null +++ b/storage/pkg/config/grpc.go @@ -0,0 +1,7 @@ +package config + +// GRPC defines the available grpc configuration. +type GRPC struct { + Addr string `ocisConfig:"addr" env:"SETTINGS_GRPC_ADDR"` + Namespace string +} diff --git a/storage/pkg/config/http.go b/storage/pkg/config/http.go new file mode 100644 index 000000000..f2099febf --- /dev/null +++ b/storage/pkg/config/http.go @@ -0,0 +1,18 @@ +package config + +// HTTP defines the available http configuration. +type HTTP struct { + Addr string `ocisConfig:"addr" env:"SETTINGS_HTTP_ADDR"` + Namespace string + Root string `ocisConfig:"root" env:"SETTINGS_HTTP_ROOT"` + CacheTTL int `ocisConfig:"cache_ttl" env:"SETTINGS_CACHE_TTL"` + CORS CORS `ocisConfig:"cors"` +} + +// CORS defines the available cors configuration. +type CORS struct { + AllowedOrigins []string `ocisConfig:"allowed_origins"` + AllowedMethods []string `ocisConfig:"allowed_methods"` + AllowedHeaders []string `ocisConfig:"allowed_headers"` + AllowCredentials bool `ocisConfig:"allowed_credentials"` +} diff --git a/storage/pkg/config/log.go b/storage/pkg/config/log.go new file mode 100644 index 000000000..eb14a82e8 --- /dev/null +++ b/storage/pkg/config/log.go @@ -0,0 +1,9 @@ +package config + +// Log defines the available log configuration. +type Log struct { + Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;STORAGE_LOG_LEVEL"` + Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;STORAGE_LOG_PRETTY"` + Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;STORAGE_LOG_COLOR"` + File string `mapstructure:"file" env:"OCIS_LOG_FILE;STORAGE_LOG_FILE"` +} diff --git a/storage/pkg/config/reva.go b/storage/pkg/config/reva.go new file mode 100644 index 000000000..5427747df --- /dev/null +++ b/storage/pkg/config/reva.go @@ -0,0 +1,6 @@ +package config + +// TokenManager is the config for using the reva token manager +type TokenManager struct { + JWTSecret string `ocisConfig:"jwt_secret" env:"OCIS_JWT_SECRET;SETTINGS_JWT_SECRET"` +} diff --git a/storage/pkg/config/service.go b/storage/pkg/config/service.go new file mode 100644 index 000000000..c12faf344 --- /dev/null +++ b/storage/pkg/config/service.go @@ -0,0 +1,7 @@ +package config + +// Service defines the available service configuration. +type Service struct { + Name string + Version string +} diff --git a/storage/pkg/config/tracing.go b/storage/pkg/config/tracing.go new file mode 100644 index 000000000..b5c955444 --- /dev/null +++ b/storage/pkg/config/tracing.go @@ -0,0 +1,10 @@ +package config + +// Tracing defines the available tracing configuration. +type Tracing struct { + Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;STORAGE_TRACING_ENABLED"` + Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;STORAGE_TRACING_TYPE"` + Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;STORAGE_TRACING_ENDPOINT"` + Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;STORAGE_TRACING_COLLECTOR"` + Service string `ocisConfig:"service" env:"STORAGE_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? +} diff --git a/store/pkg/config/config.go b/store/pkg/config/config.go index c96271fbd..bb79327e8 100644 --- a/store/pkg/config/config.go +++ b/store/pkg/config/config.go @@ -2,51 +2,11 @@ package config import ( "context" - "path" - - "github.com/owncloud/ocis/ocis-pkg/config/defaults" ) -// Debug defines the available debug configuration. -type Debug struct { - Addr string `ocisConfig:"addr" env:"STORE_DEBUG_ADDR"` - Token string `ocisConfig:"token" env:"STORE_DEBUG_TOKEN"` - Pprof bool `ocisConfig:"pprof" env:"STORE_DEBUG_PPROF"` - Zpages bool `ocisConfig:"zpages" env:"STORE_DEBUG_ZPAGES"` -} - -// GRPC defines the available grpc configuration. -type GRPC struct { - Addr string `ocisConfig:"addr" env:"STORE_GRPC_ADDR"` - Namespace string -} - -// Service defines the available service configuration. -type Service struct { - Name string - Version string -} - -// Tracing defines the available tracing configuration. -type Tracing struct { - Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;STORE_TRACING_ENABLED"` - Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;STORE_TRACING_TYPE"` - Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;STORE_TRACING_ENDPOINT"` - Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;STORE_TRACING_COLLECTOR"` - Service string `ocisConfig:"service" env:"STORE_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? -} - -// Log defines the available log configuration. -type Log struct { - Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;STORE_LOG_LEVEL"` - Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;STORE_LOG_PRETTY"` - Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;STORE_LOG_COLOR"` - File string `mapstructure:"file" env:"OCIS_LOG_FILE;STORE_LOG_FILE"` -} - // Config combines all available configuration parts. type Config struct { - Service Service `ocisConfig:"service"` + Service Service Tracing Tracing `ocisConfig:"tracing"` Log Log `ocisConfig:"log"` @@ -59,29 +19,3 @@ type Config struct { Context context.Context Supervised bool } - -func DefaultConfig() *Config { - return &Config{ - Debug: Debug{ - Addr: "127.0.0.1:9464", - Token: "", - Pprof: false, - Zpages: false, - }, - GRPC: GRPC{ - Addr: "127.0.0.1:9460", - Namespace: "com.owncloud.api", - }, - Service: Service{ - Name: "store", - }, - Tracing: Tracing{ - Enabled: false, - Type: "jaeger", - Endpoint: "", - Collector: "", - Service: "store", - }, - Datapath: path.Join(defaults.BaseDataPath(), "store"), - } -} diff --git a/store/pkg/config/debug.go b/store/pkg/config/debug.go new file mode 100644 index 000000000..a168ce846 --- /dev/null +++ b/store/pkg/config/debug.go @@ -0,0 +1,9 @@ +package config + +// Debug defines the available debug configuration. +type Debug struct { + Addr string `ocisConfig:"addr" env:"STORE_DEBUG_ADDR"` + Token string `ocisConfig:"token" env:"STORE_DEBUG_TOKEN"` + Pprof bool `ocisConfig:"pprof" env:"STORE_DEBUG_PPROF"` + Zpages bool `ocisConfig:"zpages" env:"STORE_DEBUG_ZPAGES"` +} diff --git a/store/pkg/config/defaultconfig.go b/store/pkg/config/defaultconfig.go new file mode 100644 index 000000000..4ba99550c --- /dev/null +++ b/store/pkg/config/defaultconfig.go @@ -0,0 +1,33 @@ +package config + +import ( + "path" + + "github.com/owncloud/ocis/ocis-pkg/config/defaults" +) + +func DefaultConfig() *Config { + return &Config{ + Debug: Debug{ + Addr: "127.0.0.1:9464", + Token: "", + Pprof: false, + Zpages: false, + }, + GRPC: GRPC{ + Addr: "127.0.0.1:9460", + Namespace: "com.owncloud.api", + }, + Service: Service{ + Name: "store", + }, + Tracing: Tracing{ + Enabled: false, + Type: "jaeger", + Endpoint: "", + Collector: "", + Service: "store", + }, + Datapath: path.Join(defaults.BaseDataPath(), "store"), + } +} diff --git a/store/pkg/config/grpc.go b/store/pkg/config/grpc.go new file mode 100644 index 000000000..ed87112dd --- /dev/null +++ b/store/pkg/config/grpc.go @@ -0,0 +1,7 @@ +package config + +// GRPC defines the available grpc configuration. +type GRPC struct { + Addr string `ocisConfig:"addr" env:"STORE_GRPC_ADDR"` + Namespace string +} diff --git a/store/pkg/config/log.go b/store/pkg/config/log.go new file mode 100644 index 000000000..a00934bb2 --- /dev/null +++ b/store/pkg/config/log.go @@ -0,0 +1,9 @@ +package config + +// Log defines the available log configuration. +type Log struct { + Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;STORE_LOG_LEVEL"` + Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;STORE_LOG_PRETTY"` + Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;STORE_LOG_COLOR"` + File string `mapstructure:"file" env:"OCIS_LOG_FILE;STORE_LOG_FILE"` +} diff --git a/store/pkg/config/service.go b/store/pkg/config/service.go new file mode 100644 index 000000000..c12faf344 --- /dev/null +++ b/store/pkg/config/service.go @@ -0,0 +1,7 @@ +package config + +// Service defines the available service configuration. +type Service struct { + Name string + Version string +} diff --git a/store/pkg/config/tracing.go b/store/pkg/config/tracing.go new file mode 100644 index 000000000..a54001c94 --- /dev/null +++ b/store/pkg/config/tracing.go @@ -0,0 +1,10 @@ +package config + +// Tracing defines the available tracing configuration. +type Tracing struct { + Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;STORE_TRACING_ENABLED"` + Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;STORE_TRACING_TYPE"` + Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;STORE_TRACING_ENDPOINT"` + Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;STORE_TRACING_COLLECTOR"` + Service string `ocisConfig:"service" env:"STORE_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? +} diff --git a/thumbnails/pkg/config/config.go b/thumbnails/pkg/config/config.go index 1e3d5608b..30c225fac 100644 --- a/thumbnails/pkg/config/config.go +++ b/thumbnails/pkg/config/config.go @@ -2,51 +2,11 @@ package config import ( "context" - "path" - - "github.com/owncloud/ocis/ocis-pkg/config/defaults" ) -// Debug defines the available debug configuration. -type Debug struct { - Addr string `ocisConfig:"addr" env:"THUMBNAILS_DEBUG_ADDR"` - Token string `ocisConfig:"token" env:"THUMBNAILS_DEBUG_TOKEN"` - Pprof bool `ocisConfig:"pprof" env:"THUMBNAILS_DEBUG_PPROF"` - Zpages bool `ocisConfig:"zpages" env:"THUMBNAILS_DEBUG_ZPAGES"` -} - -// GRPC defines the available grpc configuration. -type GRPC struct { - Addr string `ocisConfig:"addr" env:"THUMBNAILS_GRPC_ADDR"` - Namespace string -} - -// Service defines the available service configuration. -type Service struct { - Name string - Version string -} - -// Tracing defines the available tracing configuration. -type Tracing struct { - Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;THUMBNAILS_TRACING_ENABLED"` - Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;THUMBNAILS_TRACING_TYPE"` - Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;THUMBNAILS_TRACING_ENDPOINT"` - Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;THUMBNAILS_TRACING_COLLECTOR"` - Service string `ocisConfig:"service" env:"THUMBNAILS_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? -} - -// Log defines the available log configuration. -type Log struct { - Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;THUMBNAILS_LOG_LEVEL"` - Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;THUMBNAILS_LOG_PRETTY"` - Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;THUMBNAILS_LOG_COLOR"` - File string `mapstructure:"file" env:"OCIS_LOG_FILE;THUMBNAILS_LOG_FILE"` -} - // Config combines all available configuration parts. type Config struct { - Service Service `ocisConfig:"service"` + Service Service Tracing Tracing `ocisConfig:"tracing"` Log Log `ocisConfig:"log"` @@ -76,42 +36,7 @@ type Thumbnail struct { FileSystemStorage FileSystemStorage `ocisConfig:"filesystem_storage"` WebdavAllowInsecure bool `ocisConfig:"webdav_allow_insecure" env:"OCIS_INSECURE;THUMBNAILS_WEBDAVSOURCE_INSECURE"` CS3AllowInsecure bool `ocisConfig:"cs3_allow_insecure" env:"OCIS_INSECURE;THUMBNAILS_CS3SOURCE_INSECURE"` - RevaGateway string `ocisConfig:"reva_gateway" env:"REVA_GATEWAY"` + RevaGateway string `ocisConfig:"reva_gateway" env:"REVA_GATEWAY"` //TODO: use REVA config WebdavNamespace string `ocisConfig:"webdav_namespace" env:"STORAGE_WEBDAV_NAMESPACE"` FontMapFile string `ocisConfig:"font_map_file" env:"THUMBNAILS_TXT_FONTMAP_FILE"` } - -func DefaultConfig() *Config { - return &Config{ - Debug: Debug{ - Addr: "127.0.0.1:9189", - Token: "", - Pprof: false, - Zpages: false, - }, - GRPC: GRPC{ - Addr: "127.0.0.1:9185", - Namespace: "com.owncloud.api", - }, - Service: Service{ - Name: "thumbnails", - }, - Tracing: Tracing{ - Enabled: false, - Type: "jaeger", - Endpoint: "", - Collector: "", - Service: "thumbnails", - }, - Thumbnail: Thumbnail{ - Resolutions: []string{"16x16", "32x32", "64x64", "128x128", "1920x1080", "3840x2160", "7680x4320"}, - FileSystemStorage: FileSystemStorage{ - RootDirectory: path.Join(defaults.BaseDataPath(), "thumbnails"), - }, - WebdavAllowInsecure: true, - RevaGateway: "127.0.0.1:9142", - WebdavNamespace: "/home", - CS3AllowInsecure: false, - }, - } -} diff --git a/thumbnails/pkg/config/debug.go b/thumbnails/pkg/config/debug.go new file mode 100644 index 000000000..f1f3a01e1 --- /dev/null +++ b/thumbnails/pkg/config/debug.go @@ -0,0 +1,9 @@ +package config + +// Debug defines the available debug configuration. +type Debug struct { + Addr string `ocisConfig:"addr" env:"THUMBNAILS_DEBUG_ADDR"` + Token string `ocisConfig:"token" env:"THUMBNAILS_DEBUG_TOKEN"` + Pprof bool `ocisConfig:"pprof" env:"THUMBNAILS_DEBUG_PPROF"` + Zpages bool `ocisConfig:"zpages" env:"THUMBNAILS_DEBUG_ZPAGES"` +} diff --git a/thumbnails/pkg/config/defaultconfig.go b/thumbnails/pkg/config/defaultconfig.go new file mode 100644 index 000000000..bc7bd36fa --- /dev/null +++ b/thumbnails/pkg/config/defaultconfig.go @@ -0,0 +1,42 @@ +package config + +import ( + "path" + + "github.com/owncloud/ocis/ocis-pkg/config/defaults" +) + +func DefaultConfig() *Config { + return &Config{ + Debug: Debug{ + Addr: "127.0.0.1:9189", + Token: "", + Pprof: false, + Zpages: false, + }, + GRPC: GRPC{ + Addr: "127.0.0.1:9185", + Namespace: "com.owncloud.api", + }, + Service: Service{ + Name: "thumbnails", + }, + Tracing: Tracing{ + Enabled: false, + Type: "jaeger", + Endpoint: "", + Collector: "", + Service: "thumbnails", + }, + Thumbnail: Thumbnail{ + Resolutions: []string{"16x16", "32x32", "64x64", "128x128", "1920x1080", "3840x2160", "7680x4320"}, + FileSystemStorage: FileSystemStorage{ + RootDirectory: path.Join(defaults.BaseDataPath(), "thumbnails"), + }, + WebdavAllowInsecure: true, + RevaGateway: "127.0.0.1:9142", + WebdavNamespace: "/home", + CS3AllowInsecure: false, + }, + } +} diff --git a/thumbnails/pkg/config/grpc.go b/thumbnails/pkg/config/grpc.go new file mode 100644 index 000000000..9682ed12c --- /dev/null +++ b/thumbnails/pkg/config/grpc.go @@ -0,0 +1,7 @@ +package config + +// GRPC defines the available grpc configuration. +type GRPC struct { + Addr string `ocisConfig:"addr" env:"THUMBNAILS_GRPC_ADDR"` + Namespace string +} diff --git a/thumbnails/pkg/config/log.go b/thumbnails/pkg/config/log.go new file mode 100644 index 000000000..a9b19f070 --- /dev/null +++ b/thumbnails/pkg/config/log.go @@ -0,0 +1,9 @@ +package config + +// Log defines the available log configuration. +type Log struct { + Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;THUMBNAILS_LOG_LEVEL"` + Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;THUMBNAILS_LOG_PRETTY"` + Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;THUMBNAILS_LOG_COLOR"` + File string `mapstructure:"file" env:"OCIS_LOG_FILE;THUMBNAILS_LOG_FILE"` +} diff --git a/thumbnails/pkg/config/service.go b/thumbnails/pkg/config/service.go new file mode 100644 index 000000000..c12faf344 --- /dev/null +++ b/thumbnails/pkg/config/service.go @@ -0,0 +1,7 @@ +package config + +// Service defines the available service configuration. +type Service struct { + Name string + Version string +} diff --git a/thumbnails/pkg/config/tracing.go b/thumbnails/pkg/config/tracing.go new file mode 100644 index 000000000..e118e1530 --- /dev/null +++ b/thumbnails/pkg/config/tracing.go @@ -0,0 +1,10 @@ +package config + +// Tracing defines the available tracing configuration. +type Tracing struct { + Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;THUMBNAILS_TRACING_ENABLED"` + Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;THUMBNAILS_TRACING_TYPE"` + Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;THUMBNAILS_TRACING_ENDPOINT"` + Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;THUMBNAILS_TRACING_COLLECTOR"` + Service string `ocisConfig:"service" env:"THUMBNAILS_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? +} diff --git a/web/pkg/config/config.go b/web/pkg/config/config.go index 345ae8aec..6a1ef7eab 100644 --- a/web/pkg/config/config.go +++ b/web/pkg/config/config.go @@ -1,46 +1,23 @@ package config -import ( - "context" -) +import "context" -// Debug defines the available debug configuration. -type Debug struct { - Addr string `ocisConfig:"addr" env:"WEB_DEBUG_ADDR"` - Token string `ocisConfig:"token" env:"WEB_DEBUG_TOKEN"` - Pprof bool `ocisConfig:"pprof" env:"WEB_DEBUG_PPROF"` - Zpages bool `ocisConfig:"zpages" env:"WEB_DEBUG_ZPAGES"` -} +// Config combines all available configuration parts. +type Config struct { + Service Service -// HTTP defines the available http configuration. -type HTTP struct { - Addr string `ocisConfig:"addr" env:"WEB_HTTP_ADDR"` - Namespace string - Root string `ocisConfig:"root" env:"WEB_HTTP_ROOT"` - CacheTTL int `ocisConfig:"cache_ttl" env:"WEB_CACHE_TTL"` -} + Tracing Tracing `ocisConfig:"tracing"` + Log Log `ocisConfig:"log"` + Debug Debug `ocisConfig:"debug"` -// Service defines the available service configuration. -type Service struct { - Name string - Version string -} + HTTP HTTP `ocisConfig:"http"` -// Tracing defines the available tracing configuration. -type Tracing struct { - Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;WEB_TRACING_ENABLED"` - Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;WEB_TRACING_TYPE"` - Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;WEB_TRACING_ENDPOINT"` - Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;WEB_TRACING_COLLECTOR"` - Service string `ocisConfig:"service" env:"WEB_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? -} + Asset Asset `ocisConfig:"asset"` + File string `ocisConfig:"file" env:"WEB_UI_CONFIG"` // TODO: rename this to a more self explaining string + Web Web `ocisConfig:"web"` -// Log defines the available log configuration. -type Log struct { - Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;WEB_LOG_LEVEL"` - Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;WEB_LOG_PRETTY"` - Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;WEB_LOG_COLOR"` - File string `mapstructure:"file" env:"OCIS_LOG_FILE;WEB_LOG_FILE"` + Context context.Context + Supervised bool } // Asset defines the available asset configuration. @@ -95,69 +72,3 @@ type Web struct { ThemePath string `ocisConfig:"theme_path" env:"WEB_UI_THEME_PATH"` // used to build Theme in WebConfig Config WebConfig `ocisConfig:"config"` } - -// Config combines all available configuration parts. -type Config struct { - Service Service `ocisConfig:"service"` - - Tracing Tracing `ocisConfig:"tracing"` - Log Log `ocisConfig:"log"` - Debug Debug `ocisConfig:"debug"` - - HTTP HTTP `ocisConfig:"http"` - - Asset Asset `ocisConfig:"asset"` - File string `ocisConfig:"file" env:"WEB_UI_CONFIG"` // TODO: rename this to a more self explaining string - Web Web `ocisConfig:"web"` - - Context context.Context - Supervised bool -} - -func DefaultConfig() *Config { - return &Config{ - Debug: Debug{ - Addr: "127.0.0.1:9104", - Token: "", - Pprof: false, - Zpages: false, - }, - HTTP: HTTP{ - Addr: "127.0.0.1:9100", - Root: "/", - Namespace: "com.owncloud.web", - CacheTTL: 604800, // 7 days - }, - Service: Service{ - Name: "web", - }, - Tracing: Tracing{ - Enabled: false, - Type: "jaeger", - Endpoint: "", - Collector: "", - Service: "web", - }, - Asset: Asset{ - Path: "", - }, - Web: Web{ - Path: "", - ThemeServer: "https://localhost:9200", - ThemePath: "/themes/owncloud/theme.json", - Config: WebConfig{ - Server: "https://localhost:9200", - Theme: "", - Version: "0.1.0", - OpenIDConnect: OIDC{ - MetadataURL: "", - Authority: "https://localhost:9200", - ClientID: "web", - ResponseType: "code", - Scope: "openid profile email", - }, - Apps: []string{"files", "search", "media-viewer", "external"}, - }, - }, - } -} diff --git a/web/pkg/config/debug.go b/web/pkg/config/debug.go new file mode 100644 index 000000000..d4dda707d --- /dev/null +++ b/web/pkg/config/debug.go @@ -0,0 +1,9 @@ +package config + +// Debug defines the available debug configuration. +type Debug struct { + Addr string `ocisConfig:"addr" env:"WEB_DEBUG_ADDR"` + Token string `ocisConfig:"token" env:"WEB_DEBUG_TOKEN"` + Pprof bool `ocisConfig:"pprof" env:"WEB_DEBUG_PPROF"` + Zpages bool `ocisConfig:"zpages" env:"WEB_DEBUG_ZPAGES"` +} diff --git a/web/pkg/config/defaultconfig.go b/web/pkg/config/defaultconfig.go new file mode 100644 index 000000000..a41d1af4d --- /dev/null +++ b/web/pkg/config/defaultconfig.go @@ -0,0 +1,49 @@ +package config + +func DefaultConfig() *Config { + return &Config{ + Debug: Debug{ + Addr: "127.0.0.1:9104", + Token: "", + Pprof: false, + Zpages: false, + }, + HTTP: HTTP{ + Addr: "127.0.0.1:9100", + Root: "/", + Namespace: "com.owncloud.web", + CacheTTL: 604800, // 7 days + }, + Service: Service{ + Name: "web", + }, + Tracing: Tracing{ + Enabled: false, + Type: "jaeger", + Endpoint: "", + Collector: "", + Service: "web", + }, + Asset: Asset{ + Path: "", + }, + Web: Web{ + Path: "", + ThemeServer: "https://localhost:9200", + ThemePath: "/themes/owncloud/theme.json", + Config: WebConfig{ + Server: "https://localhost:9200", + Theme: "", + Version: "0.1.0", + OpenIDConnect: OIDC{ + MetadataURL: "", + Authority: "https://localhost:9200", + ClientID: "web", + ResponseType: "code", + Scope: "openid profile email", + }, + Apps: []string{"files", "search", "media-viewer", "external"}, + }, + }, + } +} diff --git a/web/pkg/config/http.go b/web/pkg/config/http.go new file mode 100644 index 000000000..317b93497 --- /dev/null +++ b/web/pkg/config/http.go @@ -0,0 +1,9 @@ +package config + +// HTTP defines the available http configuration. +type HTTP struct { + Addr string `ocisConfig:"addr" env:"WEB_HTTP_ADDR"` + Namespace string + Root string `ocisConfig:"root" env:"WEB_HTTP_ROOT"` + CacheTTL int `ocisConfig:"cache_ttl" env:"WEB_CACHE_TTL"` +} diff --git a/web/pkg/config/log.go b/web/pkg/config/log.go new file mode 100644 index 000000000..1a3310728 --- /dev/null +++ b/web/pkg/config/log.go @@ -0,0 +1,9 @@ +package config + +// Log defines the available log configuration. +type Log struct { + Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;WEB_LOG_LEVEL"` + Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;WEB_LOG_PRETTY"` + Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;WEB_LOG_COLOR"` + File string `mapstructure:"file" env:"OCIS_LOG_FILE;WEB_LOG_FILE"` +} diff --git a/web/pkg/config/service.go b/web/pkg/config/service.go new file mode 100644 index 000000000..c12faf344 --- /dev/null +++ b/web/pkg/config/service.go @@ -0,0 +1,7 @@ +package config + +// Service defines the available service configuration. +type Service struct { + Name string + Version string +} diff --git a/web/pkg/config/tracing.go b/web/pkg/config/tracing.go new file mode 100644 index 000000000..c6bb6569a --- /dev/null +++ b/web/pkg/config/tracing.go @@ -0,0 +1,10 @@ +package config + +// Tracing defines the available tracing configuration. +type Tracing struct { + Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;WEB_TRACING_ENABLED"` + Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;WEB_TRACING_TYPE"` + Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;WEB_TRACING_ENDPOINT"` + Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;WEB_TRACING_COLLECTOR"` + Service string `ocisConfig:"service" env:"WEB_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? +} diff --git a/webdav/pkg/config/config.go b/webdav/pkg/config/config.go index 2fcfd9a78..9003f946e 100644 --- a/webdav/pkg/config/config.go +++ b/webdav/pkg/config/config.go @@ -2,62 +2,11 @@ package config import ( "context" - - "github.com/owncloud/ocis/ocis-pkg/shared" ) -// Debug defines the available debug configuration. -type Debug struct { - Addr string `ocisConfig:"addr" env:"WEBDAV_DEBUG_ADDR"` - Token string `ocisConfig:"token" env:"WEBDAV_DEBUG_TOKEN"` - Pprof bool `ocisConfig:"pprof" env:"WEBDAV_DEBUG_PPROF"` - Zpages bool `ocisConfig:"zpages" env:"WEBDAV_DEBUG_ZPAGES"` -} - -// CORS defines the available cors configuration. -type CORS struct { - AllowedOrigins []string `ocisConfig:"allowed_origins"` - AllowedMethods []string `ocisConfig:"allowed_methods"` - AllowedHeaders []string `ocisConfig:"allowed_headers"` - AllowCredentials bool `ocisConfig:"allow_credentials"` -} - -// HTTP defines the available http configuration. -type HTTP struct { - Addr string `ocisConfig:"addr" env:"WEBDAV_HTTP_ADDR"` - Namespace string - Root string `ocisConfig:"root" env:"WEBDAV_HTTP_ROOT"` - CORS CORS `ocisConfig:"cors"` -} - -// Service defines the available service configuration. -type Service struct { - Name string - Version string -} - -// Tracing defines the available tracing configuration. -type Tracing struct { - Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;WEBDAV_TRACING_ENABLED"` - Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;WEBDAV_TRACING_TYPE"` - Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;WEBDAV_TRACING_ENDPOINT"` - Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;WEBDAV_TRACING_COLLECTOR"` - Service string `ocisConfig:"service" env:"WEBDAV_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? -} - -// Log defines the available log configuration. -type Log struct { - Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;WEBDAV_LOG_LEVEL"` - Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;WEBDAV_LOG_PRETTY"` - Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;WEBDAV_LOG_COLOR"` - File string `mapstructure:"file" env:"OCIS_LOG_FILE;WEBDAV_LOG_FILE"` -} - // Config combines all available configuration parts. type Config struct { - *shared.Commons - - Service Service `ocisConfig:"service"` + Service Service Tracing Tracing `ocisConfig:"tracing"` Log Log `ocisConfig:"log"` @@ -71,37 +20,3 @@ type Config struct { Context context.Context Supervised bool } - -func DefaultConfig() *Config { - return &Config{ - Debug: Debug{ - Addr: "127.0.0.1:9119", - Token: "", - Pprof: false, - Zpages: false, - }, - HTTP: HTTP{ - Addr: "127.0.0.1:9115", - Root: "/", - Namespace: "com.owncloud.web", - CORS: CORS{ - AllowedOrigins: []string{"*"}, - AllowedMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"}, - AllowedHeaders: []string{"Authorization", "Origin", "Content-Type", "Accept", "X-Requested-With"}, - AllowCredentials: true, - }, - }, - Service: Service{ - Name: "webdav", - }, - Tracing: Tracing{ - Enabled: false, - Type: "jaeger", - Endpoint: "", - Collector: "", - Service: "webdav", - }, - OcisPublicURL: "https://127.0.0.1:9200", - WebdavNamespace: "/home", - } -} diff --git a/webdav/pkg/config/debug.go b/webdav/pkg/config/debug.go new file mode 100644 index 000000000..2551ce17a --- /dev/null +++ b/webdav/pkg/config/debug.go @@ -0,0 +1,9 @@ +package config + +// Debug defines the available debug configuration. +type Debug struct { + Addr string `ocisConfig:"addr" env:"WEBDAV_DEBUG_ADDR"` + Token string `ocisConfig:"token" env:"WEBDAV_DEBUG_TOKEN"` + Pprof bool `ocisConfig:"pprof" env:"WEBDAV_DEBUG_PPROF"` + Zpages bool `ocisConfig:"zpages" env:"WEBDAV_DEBUG_ZPAGES"` +} diff --git a/webdav/pkg/config/defaultconfig.go b/webdav/pkg/config/defaultconfig.go new file mode 100644 index 000000000..6d0e82310 --- /dev/null +++ b/webdav/pkg/config/defaultconfig.go @@ -0,0 +1,35 @@ +package config + +func DefaultConfig() *Config { + return &Config{ + Debug: Debug{ + Addr: "127.0.0.1:9119", + Token: "", + Pprof: false, + Zpages: false, + }, + HTTP: HTTP{ + Addr: "127.0.0.1:9115", + Root: "/", + Namespace: "com.owncloud.web", + CORS: CORS{ + AllowedOrigins: []string{"*"}, + AllowedMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"}, + AllowedHeaders: []string{"Authorization", "Origin", "Content-Type", "Accept", "X-Requested-With"}, + AllowCredentials: true, + }, + }, + Service: Service{ + Name: "webdav", + }, + Tracing: Tracing{ + Enabled: false, + Type: "jaeger", + Endpoint: "", + Collector: "", + Service: "webdav", + }, + OcisPublicURL: "https://127.0.0.1:9200", + WebdavNamespace: "/home", + } +} diff --git a/webdav/pkg/config/http.go b/webdav/pkg/config/http.go new file mode 100644 index 000000000..4ce2f2dcd --- /dev/null +++ b/webdav/pkg/config/http.go @@ -0,0 +1,17 @@ +package config + +// CORS defines the available cors configuration. +type CORS struct { + AllowedOrigins []string `ocisConfig:"allowed_origins"` + AllowedMethods []string `ocisConfig:"allowed_methods"` + AllowedHeaders []string `ocisConfig:"allowed_headers"` + AllowCredentials bool `ocisConfig:"allow_credentials"` +} + +// HTTP defines the available http configuration. +type HTTP struct { + Addr string `ocisConfig:"addr" env:"WEBDAV_HTTP_ADDR"` + Namespace string + Root string `ocisConfig:"root" env:"WEBDAV_HTTP_ROOT"` + CORS CORS `ocisConfig:"cors"` +} diff --git a/webdav/pkg/config/log.go b/webdav/pkg/config/log.go new file mode 100644 index 000000000..211aad1a4 --- /dev/null +++ b/webdav/pkg/config/log.go @@ -0,0 +1,9 @@ +package config + +// Log defines the available log configuration. +type Log struct { + Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;WEBDAV_LOG_LEVEL"` + Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;WEBDAV_LOG_PRETTY"` + Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;WEBDAV_LOG_COLOR"` + File string `mapstructure:"file" env:"OCIS_LOG_FILE;WEBDAV_LOG_FILE"` +} diff --git a/webdav/pkg/config/service.go b/webdav/pkg/config/service.go new file mode 100644 index 000000000..c12faf344 --- /dev/null +++ b/webdav/pkg/config/service.go @@ -0,0 +1,7 @@ +package config + +// Service defines the available service configuration. +type Service struct { + Name string + Version string +} diff --git a/webdav/pkg/config/tracing.go b/webdav/pkg/config/tracing.go new file mode 100644 index 000000000..f63b2480d --- /dev/null +++ b/webdav/pkg/config/tracing.go @@ -0,0 +1,10 @@ +package config + +// Tracing defines the available tracing configuration. +type Tracing struct { + Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED;WEBDAV_TRACING_ENABLED"` + Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE;WEBDAV_TRACING_TYPE"` + Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT;WEBDAV_TRACING_ENDPOINT"` + Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR;WEBDAV_TRACING_COLLECTOR"` + Service string `ocisConfig:"service" env:"WEBDAV_TRACING_SERVICE"` //TODO: should this be an ID? or the same as Service.Name? +}