diff --git a/changelog/unreleased/fix-spaces-ocis-url.md b/changelog/unreleased/fix-spaces-ocis-url.md new file mode 100644 index 000000000..b7a7f35a4 --- /dev/null +++ b/changelog/unreleased/fix-spaces-ocis-url.md @@ -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 diff --git a/graph-explorer/pkg/config/config.go b/graph-explorer/pkg/config/config.go index 8bb1cde8e..12653c78c 100644 --- a/graph-explorer/pkg/config/config.go +++ b/graph-explorer/pkg/config/config.go @@ -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. diff --git a/graph-explorer/pkg/flagset/flagset.go b/graph-explorer/pkg/flagset/flagset.go index 540780e47..06acd9502 100644 --- a/graph-explorer/pkg/flagset/flagset.go +++ b/graph-explorer/pkg/flagset/flagset.go @@ -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", diff --git a/graph-explorer/pkg/service/v0/service.go b/graph-explorer/pkg/service/v0/service.go index 7099161af..d2d0820bd 100644 --- a/graph-explorer/pkg/service/v0/service.go +++ b/graph-explorer/pkg/service/v0/service.go @@ -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") } } diff --git a/graph/pkg/config/config.go b/graph/pkg/config/config.go index 402147277..d766029db 100644 --- a/graph/pkg/config/config.go +++ b/graph/pkg/config/config.go @@ -52,6 +52,7 @@ type TokenManager struct { type Spaces struct { WebDavBase string + WebDavPath string DefaultQuota string } diff --git a/graph/pkg/flagset/flagset.go b/graph/pkg/flagset/flagset.go index 4357d0ba8..39326e878 100644 --- a/graph/pkg/flagset/flagset.go +++ b/graph/pkg/flagset/flagset.go @@ -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", diff --git a/graph/pkg/service/v0/drives.go b/graph/pkg/service/v0/drives.go index 3507d68e6..7d7380987 100644 --- a/graph/pkg/service/v0/drives.go +++ b/graph/pkg/service/v0/drives.go @@ -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()) diff --git a/proxy/pkg/proxy/proxy.go b/proxy/pkg/proxy/proxy.go index a9a4af06d..a863fd5e9 100644 --- a/proxy/pkg/proxy/proxy.go +++ b/proxy/pkg/proxy/proxy.go @@ -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