diff --git a/changelog/unreleased/webdav-ns-config.md b/changelog/unreleased/webdav-ns-config.md new file mode 100644 index 000000000..298e35de4 --- /dev/null +++ b/changelog/unreleased/webdav-ns-config.md @@ -0,0 +1,7 @@ +Bugfix: Make webdav namespace configurable across services + +The WebDAV namespace is used across various services, but it was previously +hardcoded in some of the services. This PR uses the same environment variable +to set the config correctly across the services. + +https://github.com/owncloud/ocis/pull/2198 \ No newline at end of file diff --git a/graph/pkg/config/config.go b/graph/pkg/config/config.go index 433e9e72f..b2f5f58bb 100644 --- a/graph/pkg/config/config.go +++ b/graph/pkg/config/config.go @@ -65,15 +65,16 @@ type Reva struct { // Config combines all available configuration parts. type Config struct { - File string - Log Log - Debug Debug - HTTP HTTP - Server Server - Tracing Tracing - Ldap Ldap - OpenIDConnect OpenIDConnect - Reva Reva + File string + WebdavNamespace string + Log Log + Debug Debug + HTTP HTTP + Server Server + Tracing Tracing + Ldap Ldap + OpenIDConnect OpenIDConnect + Reva Reva Context context.Context Supervised bool diff --git a/graph/pkg/flagset/flagset.go b/graph/pkg/flagset/flagset.go index c4734797a..8b96cbf37 100644 --- a/graph/pkg/flagset/flagset.go +++ b/graph/pkg/flagset/flagset.go @@ -209,5 +209,12 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"REVA_GATEWAY_ADDR"}, Destination: &cfg.Reva.Address, }, + &cli.StringFlag{ + Name: "webdav-namespace", + Value: flags.OverrideDefaultString(cfg.WebdavNamespace, "/home"), + Usage: "Namespace prefix for the webdav endpoint", + EnvVars: []string{"STORAGE_WEBDAV_NAMESPACE"}, + Destination: &cfg.WebdavNamespace, + }, } } diff --git a/graph/pkg/service/v0/drives.go b/graph/pkg/service/v0/drives.go index c1573deff..d818c7c44 100644 --- a/graph/pkg/service/v0/drives.go +++ b/graph/pkg/service/v0/drives.go @@ -44,7 +44,7 @@ func (g Graph) GetRootDriveChildren(w http.ResponseWriter, r *http.Request) { } ctx := r.Context() - fn := "/home" + fn := g.config.WebdavNamespace client, err := g.GetClient() if err != nil { diff --git a/thumbnails/pkg/config/config.go b/thumbnails/pkg/config/config.go index d825831c7..7f8a97a81 100644 --- a/thumbnails/pkg/config/config.go +++ b/thumbnails/pkg/config/config.go @@ -64,6 +64,7 @@ type Thumbnail struct { FileSystemStorage FileSystemStorage WebdavAllowInsecure bool RevaGateway string + WebdavNamespace string } // New initializes a new configuration with or without defaults. diff --git a/thumbnails/pkg/flagset/flagset.go b/thumbnails/pkg/flagset/flagset.go index acf389665..c1c68b8aa 100644 --- a/thumbnails/pkg/flagset/flagset.go +++ b/thumbnails/pkg/flagset/flagset.go @@ -162,6 +162,13 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag { Usage: "--thumbnail-resolution 16x16 [--thumbnail-resolution 32x32]", EnvVars: []string{"THUMBNAILS_RESOLUTIONS"}, }, + &cli.StringFlag{ + Name: "webdav-namespace", + Value: flags.OverrideDefaultString(cfg.Thumbnail.WebdavNamespace, "/home"), + Usage: "Namespace prefix for the webdav endpoint", + EnvVars: []string{"STORAGE_WEBDAV_NAMESPACE"}, + Destination: &cfg.Thumbnail.WebdavNamespace, + }, } } diff --git a/thumbnails/pkg/service/v0/service.go b/thumbnails/pkg/service/v0/service.go index 1736fffcf..26ddfeb2c 100644 --- a/thumbnails/pkg/service/v0/service.go +++ b/thumbnails/pkg/service/v0/service.go @@ -30,7 +30,8 @@ func NewService(opts ...Option) v0proto.ThumbnailServiceHandler { logger.Fatal().Err(err).Msg("resolutions not configured correctly") } svc := Thumbnail{ - serviceID: options.Config.Server.Namespace + "." + options.Config.Server.Name, + serviceID: options.Config.Server.Namespace + "." + options.Config.Server.Name, + webdavNamespace: options.Config.Thumbnail.WebdavNamespace, manager: thumbnail.NewSimpleManager( resolutions, options.ThumbnailStorage, @@ -47,12 +48,13 @@ func NewService(opts ...Option) v0proto.ThumbnailServiceHandler { // Thumbnail implements the GRPC handler. type Thumbnail struct { - serviceID string - manager thumbnail.Manager - webdavSource imgsource.Source - cs3Source imgsource.Source - logger log.Logger - cs3Client gateway.GatewayAPIClient + serviceID string + webdavNamespace string + manager thumbnail.Manager + webdavSource imgsource.Source + cs3Source imgsource.Source + logger log.Logger + cs3Client gateway.GatewayAPIClient } // GetThumbnail retrieves a thumbnail for an image @@ -161,7 +163,7 @@ func (g Thumbnail) handleWebdavSource(ctx context.Context, req *v0proto.GetThumb statPath = path.Join("/public", src.PublicLinkToken, req.Filepath) } else { auth = src.RevaAuthorization - statPath = path.Join("/home", req.Filepath) + statPath = path.Join(g.webdavNamespace, req.Filepath) } sRes, err := g.stat(statPath, auth) if err != nil { diff --git a/webdav/pkg/config/config.go b/webdav/pkg/config/config.go index 9cb6e08da..16fc4618b 100644 --- a/webdav/pkg/config/config.go +++ b/webdav/pkg/config/config.go @@ -49,6 +49,7 @@ type Config struct { Tracing Tracing Service Service OcisPublicURL string + WebdavNamespace string Context context.Context Supervised bool diff --git a/webdav/pkg/flagset/flagset.go b/webdav/pkg/flagset/flagset.go index d60bed265..0d8a29b95 100644 --- a/webdav/pkg/flagset/flagset.go +++ b/webdav/pkg/flagset/flagset.go @@ -148,6 +148,13 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"OCIS_PUBLIC_URL", "OCIS_URL"}, Destination: &cfg.OcisPublicURL, }, + &cli.StringFlag{ + Name: "webdav-namespace", + Value: flags.OverrideDefaultString(cfg.WebdavNamespace, "/home"), + Usage: "Namespace prefix for the /webdav endpoint", + EnvVars: []string{"STORAGE_WEBDAV_NAMESPACE"}, + Destination: &cfg.WebdavNamespace, + }, } } diff --git a/webdav/pkg/service/v0/service.go b/webdav/pkg/service/v0/service.go index ee253cf42..de5125e1d 100644 --- a/webdav/pkg/service/v0/service.go +++ b/webdav/pkg/service/v0/service.go @@ -89,7 +89,7 @@ func (g Webdav) Thumbnail(w http.ResponseWriter, r *http.Request) { Height: tr.Height, Source: &thumbnails.GetThumbnailRequest_Cs3Source{ Cs3Source: &thumbnails.CS3Source{ - Path: path.Join("/home", tr.Filepath), + Path: path.Join(g.config.WebdavNamespace, tr.Filepath), Authorization: t, }, },