Merge pull request #41 from owncloud/use-ocis-proxy

This commit is contained in:
Alex Unger
2020-08-06 16:46:33 +02:00
committed by GitHub
4 changed files with 19 additions and 6 deletions

View File

@@ -85,7 +85,7 @@ THUMBNAILS_FILESYSTEMSTORAGE_ROOT
: Root path of the filesystem storage directory, defaults to `<os tempdir>/ocis-thumbnails/`
THUMBNAILS_WEBDAVSOURCE_BASEURL
: Base url for a webdav api, defaults to `htp://localhost:9140/remote.php/webdav/`
: Base url for a webdav api, defaults to `https://localhost:9200/remote.php/webdav/`
THUMBNAILS_RESOLUTIONS
: List of resolutions supported by the service, defaults to `["16x16", "32x32", "64x64", "128x128"]
@@ -155,7 +155,7 @@ If you prefer to configure the service with commandline flags you can see the av
: Root path of the filesystem storage directory, defaults to `<os tempdir>/ocis-thumbnails/`
--webdavsource-baseurl
: Base url for a webdav api, defaults to `htp://localhost:9140/remote.php/webdav/`
: Base url for a webdav api, defaults to `https://localhost:9200/remote.php/webdav/`
--thumbnail-resolution
: List of resolutions supported by the service, defaults to `["16x16", "32x32", "64x64", "128x128"]

View File

@@ -48,7 +48,8 @@ type FileSystemStorage struct {
// WebDavSource defines the available webdav source configuration.
type WebDavSource struct {
BaseURL string
BaseURL string
Insecure bool
}
// FileSystemSource defines the available filesystem source configuration.

View File

@@ -148,11 +148,18 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag {
},
&cli.StringFlag{
Name: "webdavsource-baseurl",
Value: "http://localhost:9140/remote.php/webdav/",
Value: "https://localhost:9200/remote.php/webdav/",
Usage: "Base url for a webdav api",
EnvVars: []string{"THUMBNAILS_WEBDAVSOURCE_BASEURL"},
Destination: &cfg.Thumbnail.WebDavSource.BaseURL,
},
&cli.BoolFlag{
Name: "webdavsource-insecure",
Value: true,
Usage: "Whether to skip certificate checks",
EnvVars: []string{"THUMBNAILS_WEBDAVSOURCE_INSECURE"},
Destination: &cfg.Thumbnail.WebDavSource.Insecure,
},
&cli.StringSliceFlag{
Name: "thumbnail-resolution",
Value: cli.NewStringSlice("16x16", "32x32", "64x64", "128x128", "1920x1080", "3840x2160", "7680x4320"),

View File

@@ -2,6 +2,7 @@ package imgsource
import (
"context"
"crypto/tls"
"fmt"
"image"
"net/http"
@@ -14,13 +15,15 @@ import (
// NewWebDavSource creates a new webdav instance.
func NewWebDavSource(cfg config.WebDavSource) WebDav {
return WebDav{
baseURL: cfg.BaseURL,
baseURL: cfg.BaseURL,
insecure: cfg.Insecure,
}
}
// WebDav implements the Source interface for webdav services
type WebDav struct {
baseURL string
baseURL string
insecure bool
}
// Get downloads the file from a webdav service
@@ -32,6 +35,8 @@ func (s WebDav) Get(ctx context.Context, file string) (image.Image, error) {
return nil, fmt.Errorf("could not get the image \"%s\" error: %s", file, err.Error())
}
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: s.insecure}
auth := authorization(ctx)
if auth == "" {
return nil, fmt.Errorf("could not get image \"%s\" error: authorization is missing", file)