From b94c0e683fdf69603c08e257cbd2d80aac2aa37d Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Fri, 5 Nov 2021 14:26:02 +0100 Subject: [PATCH] fix yet more offenses --- accounts/pkg/command/server.go | 10 ---------- accounts/pkg/config/env.go | 26 -------------------------- ocis-pkg/config/config.go | 2 -- web/pkg/config/config.go | 12 +++++++----- 4 files changed, 7 insertions(+), 43 deletions(-) diff --git a/accounts/pkg/command/server.go b/accounts/pkg/command/server.go index 9ca1112b4b..8de6f9d8f6 100644 --- a/accounts/pkg/command/server.go +++ b/accounts/pkg/command/server.go @@ -35,16 +35,6 @@ func Server(cfg *config.Config) *cli.Command { return err } - // TODO(this is not in the cli context anymore) - //if origins := ctx.StringSlice("cors-allowed-origins"); len(origins) != 0 { - // cfg.HTTP.CORS.AllowedOrigins = origins - //} - //if methods := ctx.StringSlice("cors-allowed-methods"); len(methods) != 0 { - // cfg.HTTP.CORS.AllowedMethods = methods - //} - //if headers := ctx.StringSlice("cors-allowed-headers"); len(headers) != 0 { - // cfg.HTTP.CORS.AllowedOrigins = headers - //} return nil }, Action: func(c *cli.Context) error { diff --git a/accounts/pkg/config/env.go b/accounts/pkg/config/env.go index 6b5e39c132..d2193575b4 100644 --- a/accounts/pkg/config/env.go +++ b/accounts/pkg/config/env.go @@ -134,29 +134,3 @@ func structMappings(cfg *Config) []mapping { }, } } - -// TODO(refs) What is with the variables with no destination defined? -//&cli.StringSliceFlag{ -//Name: "cors-allowed-origins", -//Value: cli.NewStringSlice("*"), -//Usage: "Set the allowed CORS origins", -//EnvVars: []string{"ACCOUNTS_CORS_ALLOW_ORIGINS", "OCIS_CORS_ALLOW_ORIGINS"}, -//}, -//&cli.StringSliceFlag{ -//Name: "cors-allowed-methods", -//Value: cli.NewStringSlice("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"), -//Usage: "Set the allowed CORS origins", -//EnvVars: []string{"ACCOUNTS_CORS_ALLOW_METHODS", "OCIS_CORS_ALLOW_METHODS"}, -//}, -//&cli.StringSliceFlag{ -//Name: "cors-allowed-headers", -//Value: cli.NewStringSlice("Authorization", "Origin", "Content-Type", "Accept", "X-Requested-With"), -//Usage: "Set the allowed CORS origins", -//EnvVars: []string{"ACCOUNTS_CORS_ALLOW_HEADERS", "OCIS_CORS_ALLOW_HEADERS"}, -//}, -//&cli.BoolFlag{ -//Name: "cors-allow-credentials", -//Value: flags.OverrideDefaultBool(cfg.HTTP.CORS.AllowCredentials, true), -//Usage: "Allow credentials for CORS", -//EnvVars: []string{"ACCOUNTS_CORS_ALLOW_CREDENTIALS", "OCIS_CORS_ALLOW_CREDENTIALS"}, -//}, diff --git a/ocis-pkg/config/config.go b/ocis-pkg/config/config.go index da41c2b775..7cec4f664d 100644 --- a/ocis-pkg/config/config.go +++ b/ocis-pkg/config/config.go @@ -130,7 +130,6 @@ func New() *Config { } } -// TODO(refs) refactoir refactor this outside type mapping struct { EnvVars []string // name of the EnvVars var. Destination interface{} // memory address of the original config value to modify. @@ -148,7 +147,6 @@ func GetEnv() []string { } // UnmapEnv loads values from the gooconf.Config argument and sets them in the expected destination. -// TODO(refs) can we avoid repetition here? func (c *Config) UnmapEnv(gooconf *gofig.Config) error { vals := structMappings(c) for i := range vals { diff --git a/web/pkg/config/config.go b/web/pkg/config/config.go index f6ad152e7c..5a85684e70 100644 --- a/web/pkg/config/config.go +++ b/web/pkg/config/config.go @@ -8,6 +8,8 @@ import ( gofig "github.com/gookit/config/v2" ) +const defaultIngressURL = "https://localhost:9200" + // Log defines the available logging configuration. type Log struct { Level string `mapstructure:"level"` @@ -50,9 +52,9 @@ type Asset struct { type WebConfig struct { Server string `json:"server,omitempty" mapstructure:"server"` Theme string `json:"theme,omitempty" mapstructure:"theme"` - Version string `json:"version,omitempty" mapstructure:"version"` // TODO what is version used for? + Version string `json:"version,omitempty" mapstructure:"version"` OpenIDConnect OIDC `json:"openIdConnect,omitempty" mapstructure:"oids"` - Apps []string `json:"apps" mapstructure:"apps"` // TODO add nil as empty when https://go-review.googlesource.com/c/go/+/205897/ is released + Apps []string `json:"apps" mapstructure:"apps"` ExternalApps []ExternalApp `json:"external_apps,omitempty" mapstructure:"external_apps"` Options map[string]interface{} `json:"options,omitempty" mapstructure:"options"` } @@ -140,15 +142,15 @@ func DefaultConfig() *Config { }, Web: Web{ Path: "", - ThemeServer: "https://localhost:9200", + ThemeServer: defaultIngressURL, ThemePath: "/themes/owncloud/theme.json", Config: WebConfig{ - Server: "https://localhost:9200", + Server: defaultIngressURL, Theme: "", Version: "0.1.0", OpenIDConnect: OIDC{ MetadataURL: "", - Authority: "https://localhost:9200", + Authority: defaultIngressURL, ClientID: "web", ResponseType: "code", Scope: "openid profile email",