Merge pull request #2199 from ishank011/webdav-ns-config
Make webdav namespace configurable across services
This commit is contained in:
@@ -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.
|
// Config combines all available configuration parts.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
File string
|
File string
|
||||||
Log Log
|
WebdavNamespace string
|
||||||
Debug Debug
|
Log Log
|
||||||
HTTP HTTP
|
Debug Debug
|
||||||
Server Server
|
HTTP HTTP
|
||||||
Tracing Tracing
|
Server Server
|
||||||
Ldap Ldap
|
Tracing Tracing
|
||||||
OpenIDConnect OpenIDConnect
|
Ldap Ldap
|
||||||
Reva Reva
|
OpenIDConnect OpenIDConnect
|
||||||
|
Reva Reva
|
||||||
|
|
||||||
Context context.Context
|
Context context.Context
|
||||||
Supervised bool
|
Supervised bool
|
||||||
|
|||||||
@@ -209,5 +209,12 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag {
|
|||||||
EnvVars: []string{"REVA_GATEWAY_ADDR"},
|
EnvVars: []string{"REVA_GATEWAY_ADDR"},
|
||||||
Destination: &cfg.Reva.Address,
|
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,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ func (g Graph) GetRootDriveChildren(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
|
|
||||||
fn := "/home"
|
fn := g.config.WebdavNamespace
|
||||||
|
|
||||||
client, err := g.GetClient()
|
client, err := g.GetClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ type Thumbnail struct {
|
|||||||
FileSystemStorage FileSystemStorage
|
FileSystemStorage FileSystemStorage
|
||||||
WebdavAllowInsecure bool
|
WebdavAllowInsecure bool
|
||||||
RevaGateway string
|
RevaGateway string
|
||||||
|
WebdavNamespace string
|
||||||
}
|
}
|
||||||
|
|
||||||
// New initializes a new configuration with or without defaults.
|
// 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]",
|
Usage: "--thumbnail-resolution 16x16 [--thumbnail-resolution 32x32]",
|
||||||
EnvVars: []string{"THUMBNAILS_RESOLUTIONS"},
|
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,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ func NewService(opts ...Option) v0proto.ThumbnailServiceHandler {
|
|||||||
logger.Fatal().Err(err).Msg("resolutions not configured correctly")
|
logger.Fatal().Err(err).Msg("resolutions not configured correctly")
|
||||||
}
|
}
|
||||||
svc := Thumbnail{
|
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(
|
manager: thumbnail.NewSimpleManager(
|
||||||
resolutions,
|
resolutions,
|
||||||
options.ThumbnailStorage,
|
options.ThumbnailStorage,
|
||||||
@@ -47,12 +48,13 @@ func NewService(opts ...Option) v0proto.ThumbnailServiceHandler {
|
|||||||
|
|
||||||
// Thumbnail implements the GRPC handler.
|
// Thumbnail implements the GRPC handler.
|
||||||
type Thumbnail struct {
|
type Thumbnail struct {
|
||||||
serviceID string
|
serviceID string
|
||||||
manager thumbnail.Manager
|
webdavNamespace string
|
||||||
webdavSource imgsource.Source
|
manager thumbnail.Manager
|
||||||
cs3Source imgsource.Source
|
webdavSource imgsource.Source
|
||||||
logger log.Logger
|
cs3Source imgsource.Source
|
||||||
cs3Client gateway.GatewayAPIClient
|
logger log.Logger
|
||||||
|
cs3Client gateway.GatewayAPIClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetThumbnail retrieves a thumbnail for an image
|
// 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)
|
statPath = path.Join("/public", src.PublicLinkToken, req.Filepath)
|
||||||
} else {
|
} else {
|
||||||
auth = src.RevaAuthorization
|
auth = src.RevaAuthorization
|
||||||
statPath = path.Join("/home", req.Filepath)
|
statPath = path.Join(g.webdavNamespace, req.Filepath)
|
||||||
}
|
}
|
||||||
sRes, err := g.stat(statPath, auth)
|
sRes, err := g.stat(statPath, auth)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ type Config struct {
|
|||||||
Tracing Tracing
|
Tracing Tracing
|
||||||
Service Service
|
Service Service
|
||||||
OcisPublicURL string
|
OcisPublicURL string
|
||||||
|
WebdavNamespace string
|
||||||
|
|
||||||
Context context.Context
|
Context context.Context
|
||||||
Supervised bool
|
Supervised bool
|
||||||
|
|||||||
@@ -148,6 +148,13 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag {
|
|||||||
EnvVars: []string{"OCIS_PUBLIC_URL", "OCIS_URL"},
|
EnvVars: []string{"OCIS_PUBLIC_URL", "OCIS_URL"},
|
||||||
Destination: &cfg.OcisPublicURL,
|
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,
|
Height: tr.Height,
|
||||||
Source: &thumbnails.GetThumbnailRequest_Cs3Source{
|
Source: &thumbnails.GetThumbnailRequest_Cs3Source{
|
||||||
Cs3Source: &thumbnails.CS3Source{
|
Cs3Source: &thumbnails.CS3Source{
|
||||||
Path: path.Join("/home", tr.Filepath),
|
Path: path.Join(g.config.WebdavNamespace, tr.Filepath),
|
||||||
Authorization: t,
|
Authorization: t,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user