Merge pull request #2660 from owncloud/spaces-respect-ocis-url

split spaces webdav url and graph url configuration in base and path parts
This commit is contained in:
Willy Kloucek authored and GitHub committed 2021-10-21 18:01:56 +02:00
commit 235ceed10c
9 files changed
+36 -15

No files matched your search

-1
View File
@@ -1513,7 +1513,6 @@ def notify(ctx):
def ocisServer(storage, accounts_hash_difficulty = 4, volumes = []):
environment = {
"OCIS_URL": "https://ocis-server:9200",
"GRAPH_SPACES_WEBDAV_BASE": "https://ocis-server:9200/dav/spaces/",
"STORAGE_HOME_DRIVER": "%s" % (storage),
"STORAGE_USERS_DRIVER": "%s" % (storage),
"STORAGE_USERS_DRIVER_LOCAL_ROOT": "/srv/app/tmp/ocis/local/root",
@@ -0,0 +1,6 @@
Change: Split spaces webdav url and graph url in base and path
We've fixed the behavior for the spaces webdav url and graph explorer graph url settings, so that they respect the environment variable `OCIS_URL`. Previously oCIS admins needed to set these URLs manually to make spaces and the graph explorer work.
https://github.com/owncloud/ocis/pull/2660
https://github.com/owncloud/ocis/issues/2659
+4 -3
View File
@@ -42,9 +42,10 @@ type Tracing struct {
// GraphExplorer defines the available graph-explorer configuration.
type GraphExplorer struct {
ClientID string
Issuer string
GraphURL string
ClientID string
Issuer string
GraphURLBase string
GraphURLPath string
}
// Config combines all available configuration parts.
+12 -5
View File
@@ -148,11 +148,18 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag {
Destination: &cfg.GraphExplorer.ClientID,
},
&cli.StringFlag{
Name: "graph-url",
Value: flags.OverrideDefaultString(cfg.GraphExplorer.GraphURL, "https://localhost:9200/graph"),
Usage: "Set the url to the graph api service",
EnvVars: []string{"GRAPH_EXPLORER_GRAPH_URL"},
Destination: &cfg.GraphExplorer.GraphURL,
Name: "graph-url-base",
Value: flags.OverrideDefaultString(cfg.GraphExplorer.GraphURLBase, "https://localhost:9200"),
Usage: "Set the base url to the graph api service",
EnvVars: []string{"GRAPH_EXPLORER_GRAPH_URL_BASE", "OCIS_URL"},
Destination: &cfg.GraphExplorer.GraphURLBase,
},
&cli.StringFlag{
Name: "graph-url-path",
Value: flags.OverrideDefaultString(cfg.GraphExplorer.GraphURLPath, "/graph"),
Usage: "Set the url path to the graph api service",
EnvVars: []string{"GRAPH_EXPLORER_GRAPH_URL_PATH"},
Destination: &cfg.GraphExplorer.GraphURLPath,
},
&cli.StringFlag{
Name: "extensions",
+1 -1
View File
@@ -61,7 +61,7 @@ func (p GraphExplorer) ConfigJs(w http.ResponseWriter, r *http.Request) {
if _, err := io.WriteString(w, fmt.Sprintf("window.Iss = \"%v\";", p.config.GraphExplorer.Issuer)); err != nil {
p.logger.Error().Err(err).Msg("Could not write to response writer")
}
if _, err := io.WriteString(w, fmt.Sprintf("window.GraphUrl = \"%v\";", p.config.GraphExplorer.GraphURL)); err != nil {
if _, err := io.WriteString(w, fmt.Sprintf("window.GraphUrl = \"%v\";", p.config.GraphExplorer.GraphURLBase+p.config.GraphExplorer.GraphURLPath)); err != nil {
p.logger.Error().Err(err).Msg("Could not write to response writer")
}
}
+1
View File
@@ -52,6 +52,7 @@ type TokenManager struct {
type Spaces struct {
WebDavBase string
WebDavPath string
DefaultQuota string
}
+9 -2
View File
@@ -143,11 +143,18 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag {
&cli.StringFlag{
Name: "spaces-webdav-base",
Value: flags.OverrideDefaultString(cfg.Spaces.WebDavBase, "https://localhost:9200/dav/spaces/"),
Value: flags.OverrideDefaultString(cfg.Spaces.WebDavBase, "https://localhost:9200"),
Usage: "spaces webdav base URL to use when rendering drive WabDAV URLs",
EnvVars: []string{"GRAPH_SPACES_WEBDAV_BASE"},
EnvVars: []string{"GRAPH_SPACES_WEBDAV_BASE", "OCIS_URL"},
Destination: &cfg.Spaces.WebDavBase,
},
&cli.StringFlag{
Name: "spaces-webdav-path",
Value: flags.OverrideDefaultString(cfg.Spaces.WebDavPath, "/dav/spaces/"),
Usage: "spaces webdav path to use when rendering drive WabDAV URLs",
EnvVars: []string{"GRAPH_SPACES_WEBDAV_PATH"},
Destination: &cfg.Spaces.WebDavPath,
},
&cli.StringFlag{
Name: "default-space-quota",
+2 -2
View File
@@ -60,7 +60,7 @@ func (g Graph) GetDrives(w http.ResponseWriter, r *http.Request) {
return
}
wdu, err := url.Parse(g.config.Spaces.WebDavBase)
wdu, err := url.Parse(g.config.Spaces.WebDavBase + g.config.Spaces.WebDavPath)
if err != nil {
g.logger.Error().Err(err).Msg("error parsing url")
errorcode.GeneralException.Render(w, r, http.StatusInternalServerError, err.Error())
@@ -206,7 +206,7 @@ func (g Graph) CreateDrive(w http.ResponseWriter, r *http.Request) {
return
}
wdu, err := url.Parse(g.config.Spaces.WebDavBase)
wdu, err := url.Parse(g.config.Spaces.WebDavBase + g.config.Spaces.WebDavPath)
if err != nil {
g.logger.Error().Err(err).Msg("error parsing url")
errorcode.GeneralException.Render(w, r, http.StatusInternalServerError, err.Error())
+1 -1
View File
@@ -341,7 +341,7 @@ func defaultPolicies() []config.Policy {
Backend: "http://localhost:9120",
},
{
Endpoint: "/graph-explorer/",
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