Make webdav namespace configurable across services

This commit is contained in:
Ishank Arora
2021-06-21 15:26:45 +02:00
parent 3e815601dd
commit 89f8320c74
10 changed files with 52 additions and 19 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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,
},
}
}

View File

@@ -43,7 +43,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 {

View File

@@ -64,6 +64,7 @@ type Thumbnail struct {
FileSystemStorage FileSystemStorage
WebdavAllowInsecure bool
RevaGateway string
WebdavNamespace string
}
// New initializes a new configuration with or without defaults.

View File

@@ -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,
},
}
}

View File

@@ -29,7 +29,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,
@@ -46,12 +47,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
@@ -160,7 +162,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 {

View File

@@ -49,6 +49,7 @@ type Config struct {
Tracing Tracing
Service Service
OcisPublicURL string
WebdavNamespace string
Context context.Context
Supervised bool

View File

@@ -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,
},
}
}

View File

@@ -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,
},
},