mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-02-21 21:19:01 -06:00
Make webdav namespace configurable across services
This commit is contained in:
7
changelog/unreleased/webdav-ns-config.md
Normal file
7
changelog/unreleased/webdav-ns-config.md
Normal 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
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -64,6 +64,7 @@ type Thumbnail struct {
|
||||
FileSystemStorage FileSystemStorage
|
||||
WebdavAllowInsecure bool
|
||||
RevaGateway string
|
||||
WebdavNamespace string
|
||||
}
|
||||
|
||||
// New initializes a new configuration with or without defaults.
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -49,6 +49,7 @@ type Config struct {
|
||||
Tracing Tracing
|
||||
Service Service
|
||||
OcisPublicURL string
|
||||
WebdavNamespace string
|
||||
|
||||
Context context.Context
|
||||
Supervised bool
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user