Revert "refactor config values to constants"

This reverts commit f53504158b.
This commit is contained in:
A.Unger
2021-11-17 13:56:14 +01:00
parent f53504158b
commit a34f5b6434
5 changed files with 85 additions and 74 deletions
+30 -29
View File
@@ -226,6 +226,7 @@ func DefaultConfig() *Config {
OIDC: OIDC{
Issuer: "https://localhost:9200",
Insecure: true,
//Insecure: true,
UserinfoCache: Cache{
Size: 1024,
TTL: 10,
@@ -246,16 +247,15 @@ func DefaultConfig() *Config {
UserOIDCClaim: "email",
UserCS3Claim: "mail",
MachineAuthAPIKey: "change-me-please",
Context: nil,
Policies: defaultPolicies(),
//AutoprovisionAccounts: false,
//EnableBasicAuth: false,
//InsecureBackends: false,
Context: nil,
Policies: defaultPolicies(),
}
}
func defaultPolicies() []Policy {
const idpBackend = "http://localhost:9130"
const revaBackend = "http://localhost:9140"
const ingressBackendURL = "https://demo.owncloud.com"
return []Policy{
{
Name: "ocis",
@@ -266,19 +266,19 @@ func defaultPolicies() []Policy {
},
{
Endpoint: "/.well-known/",
Backend: idpBackend,
Backend: "http://localhost:9130",
},
{
Endpoint: "/konnect/",
Backend: idpBackend,
Backend: "http://localhost:9130",
},
{
Endpoint: "/signin/",
Backend: idpBackend,
Backend: "http://localhost:9130",
},
{
Endpoint: "/archiver",
Backend: revaBackend,
Backend: "http://localhost:9140",
},
{
Type: RegexRoute,
@@ -287,7 +287,7 @@ func defaultPolicies() []Policy {
},
{
Endpoint: "/ocs/",
Backend: revaBackend,
Backend: "http://localhost:9140",
},
{
Type: QueryRoute,
@@ -296,31 +296,31 @@ func defaultPolicies() []Policy {
},
{
Endpoint: "/remote.php/",
Backend: revaBackend,
Backend: "http://localhost:9140",
},
{
Endpoint: "/dav/",
Backend: revaBackend,
Backend: "http://localhost:9140",
},
{
Endpoint: "/webdav/",
Backend: revaBackend,
Backend: "http://localhost:9140",
},
{
Endpoint: "/status.php",
Backend: revaBackend,
Backend: "http://localhost:9140",
},
{
Endpoint: "/index.php/",
Backend: revaBackend,
Backend: "http://localhost:9140",
},
{
Endpoint: "/data",
Backend: revaBackend,
Backend: "http://localhost:9140",
},
{
Endpoint: "/app/",
Backend: revaBackend,
Backend: "http://localhost:9140",
},
{
Endpoint: "/graph/",
@@ -335,6 +335,7 @@ func defaultPolicies() []Policy {
Endpoint: "/api/v0/accounts",
Backend: "http://localhost:9181",
},
// TODO the lookup needs a better mechanism
{
Endpoint: "/accounts.js",
Backend: "http://localhost:9181",
@@ -358,53 +359,53 @@ func defaultPolicies() []Policy {
},
{
Endpoint: "/.well-known/",
Backend: idpBackend,
Backend: "http://localhost:9130",
},
{
Endpoint: "/konnect/",
Backend: idpBackend,
Backend: "http://localhost:9130",
},
{
Endpoint: "/signin/",
Backend: revaBackend,
Backend: "http://localhost:9130",
},
{
Endpoint: "/archiver",
Backend: revaBackend,
Backend: "http://localhost:9140",
},
{
Endpoint: "/ocs/",
Backend: ingressBackendURL,
Backend: "https://demo.owncloud.com",
ApacheVHost: true,
},
{
Endpoint: "/remote.php/",
Backend: ingressBackendURL,
Backend: "https://demo.owncloud.com",
ApacheVHost: true,
},
{
Endpoint: "/dav/",
Backend: ingressBackendURL,
Backend: "https://demo.owncloud.com",
ApacheVHost: true,
},
{
Endpoint: "/webdav/",
Backend: ingressBackendURL,
Backend: "https://demo.owncloud.com",
ApacheVHost: true,
},
{
Endpoint: "/status.php",
Backend: ingressBackendURL,
Backend: "https://demo.owncloud.com",
ApacheVHost: true,
},
{
Endpoint: "/index.php/",
Backend: ingressBackendURL,
Backend: "https://demo.owncloud.com",
ApacheVHost: true,
},
{
Endpoint: "/data",
Backend: ingressBackendURL,
Backend: "https://demo.owncloud.com",
ApacheVHost: true,
},
},
+2 -4
View File
@@ -27,12 +27,10 @@ func Server(opts ...Option) (*http.Server, error) {
), nil
}
const contentTypeHeader = "Content-Type"
// health implements the health check.
func health(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set(contentTypeHeader, "text/plain")
w.Header().Set("Content-Type", "text/plain")
w.WriteHeader(http.StatusOK)
// TODO(tboerger): check if services are up and running
@@ -46,7 +44,7 @@ func health(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
// ready implements the ready check.
func ready(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set(contentTypeHeader, "text/plain")
w.Header().Set("Content-Type", "text/plain")
w.WriteHeader(http.StatusOK)
// TODO(tboerger): check if services are up and running