fix yet more offenses

This commit is contained in:
A.Unger
2021-11-05 14:26:02 +01:00
parent 8202f7b2ad
commit b94c0e683f
4 changed files with 7 additions and 43 deletions

View File

@@ -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 {

View File

@@ -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"},
//},

View File

@@ -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 {

View File

@@ -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",