Files
opencloud/proxy/pkg/config/defaults/defaultconfig.go
Jörn Friedrich Dreyer 0e88cb1bec Use embeddable ocdav go micro service (#3397)
* allow proxy to route to micro service

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* use go micre ocdav service instead of reva frontend

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* add missing gateway default config

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* update reva branch for testing

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* add changelog

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* add missing comands

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* bump reva version

Signed-off-by: jkoberg <jkoberg@owncloud.com>

* tidy

Signed-off-by: jkoberg <jkoberg@owncloud.com>

* bump reva again

Signed-off-by: jkoberg <jkoberg@owncloud.com>

* a blind mans config change

Signed-off-by: jkoberg <jkoberg@owncloud.com>

* add ocdav to must start extensions

Signed-off-by: jkoberg <jkoberg@owncloud.com>

* fail when neither backend nor service is set

Signed-off-by: jkoberg <jkoberg@owncloud.com>

Co-authored-by: jkoberg <jkoberg@owncloud.com>
2022-04-12 11:27:24 +02:00

204 lines
4.6 KiB
Go

package defaults
import (
"path"
"strings"
"github.com/owncloud/ocis/ocis-pkg/config/defaults"
"github.com/owncloud/ocis/proxy/pkg/config"
)
func DefaultConfig() *config.Config {
return &config.Config{
Debug: config.Debug{
Addr: "127.0.0.1:9205",
Token: "",
},
HTTP: config.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: config.Service{
Name: "proxy",
},
OIDC: config.OIDC{
Issuer: "https://localhost:9200",
Insecure: true,
//Insecure: true,
UserinfoCache: config.UserinfoCache{
Size: 1024,
TTL: 10,
},
},
TokenManager: config.TokenManager{
JWTSecret: "Pive-Fumkiu4",
},
PolicySelector: nil,
Reva: config.Reva{
Address: "127.0.0.1:9142",
},
PreSignedURL: config.PreSignedURL{
AllowedHTTPMethods: []string{"GET"},
Enabled: true,
},
AccountBackend: "accounts",
UserOIDCClaim: "email",
UserCS3Claim: "mail",
MachineAuthAPIKey: "change-me-please",
AutoprovisionAccounts: false,
EnableBasicAuth: false,
InsecureBackends: false,
}
}
func DefaultPolicies() []config.Policy {
return []config.Policy{
{
Name: "ocis",
Routes: []config.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: config.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: config.QueryRoute,
Endpoint: "/remote.php/?preview=1",
Backend: "http://localhost:9115",
},
{
Endpoint: "/remote.php/",
Service: "ocdav",
},
{
Endpoint: "/dav/",
Service: "ocdav",
},
{
Endpoint: "/webdav/",
Service: "ocdav",
},
{
Endpoint: "/status.php",
Service: "ocdav",
},
{
Endpoint: "/index.php/",
Service: "ocdav",
},
{
Endpoint: "/apps/",
Service: "ocdav",
},
{
Endpoint: "/data",
Backend: "http://localhost:9140",
},
{
Endpoint: "/app/", // /app or /apps? ocdav only handles /apps
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",
},
},
},
}
}
func EnsureDefaults(cfg *config.Config) {
// provide with defaults for shared logging, since we need a valid destination address for BindEnv.
if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil {
cfg.Log = &config.Log{
Level: cfg.Commons.Log.Level,
Pretty: cfg.Commons.Log.Pretty,
Color: cfg.Commons.Log.Color,
File: cfg.Commons.Log.File,
}
} else if cfg.Log == nil {
cfg.Log = &config.Log{}
}
// provide with defaults for shared tracing, since we need a valid destination address for BindEnv.
if cfg.Tracing == nil && cfg.Commons != nil && cfg.Commons.Tracing != nil {
cfg.Tracing = &config.Tracing{
Enabled: cfg.Commons.Tracing.Enabled,
Type: cfg.Commons.Tracing.Type,
Endpoint: cfg.Commons.Tracing.Endpoint,
Collector: cfg.Commons.Tracing.Collector,
}
} else if cfg.Tracing == nil {
cfg.Tracing = &config.Tracing{}
}
}
func Sanitize(cfg *config.Config) {
// sanitize config
if cfg.Policies == nil {
cfg.Policies = DefaultPolicies()
}
if cfg.PolicySelector == nil {
cfg.PolicySelector = &config.PolicySelector{
Static: &config.StaticSelectorConf{
Policy: "ocis",
},
}
}
if cfg.HTTP.Root != "/" {
cfg.HTTP.Root = strings.TrimSuffix(cfg.HTTP.Root, "/")
}
}