diff --git a/examples/storage-references/gateway.toml b/examples/storage-references/gateway.toml index 5b53a7ce76..35d7b429cf 100644 --- a/examples/storage-references/gateway.toml +++ b/examples/storage-references/gateway.toml @@ -3,9 +3,6 @@ commit_share_to_storage_grant = true commit_share_to_storage_ref = true -[grpc.services.gateway.token_managers.jwt] -expires = 86400 - [grpc.services.storageregistry] [grpc.services.storageregistry.drivers.static] home_provider = "/home" diff --git a/internal/grpc/services/gateway/storageprovider.go b/internal/grpc/services/gateway/storageprovider.go index 6cacf6ce10..b67e74a07f 100644 --- a/internal/grpc/services/gateway/storageprovider.go +++ b/internal/grpc/services/gateway/storageprovider.go @@ -193,7 +193,7 @@ func (s *svc) InitiateFileDownload(ctx context.Context, req *provider.InitiateFi ep, opaque, err := s.webdavRefTransferEndpoint(ctx, statRes.Info.Target, shareChild) if err != nil { return &gateway.InitiateFileDownloadResponse{ - Status: status.NewInternal(ctx, err, "gateway: error creating container on webdav host: "+p), + Status: status.NewInternal(ctx, err, "gateway: error downloading from webdav host: "+p), }, nil } return &gateway.InitiateFileDownloadResponse{ @@ -343,7 +343,7 @@ func (s *svc) InitiateFileUpload(ctx context.Context, req *provider.InitiateFile ep, opaque, err := s.webdavRefTransferEndpoint(ctx, statRes.Info.Target, shareChild) if err != nil { return &gateway.InitiateFileUploadResponse{ - Status: status.NewInternal(ctx, err, "gateway: error resolving webdav host: "+p), + Status: status.NewInternal(ctx, err, "gateway: error uploading to webdav host: "+p), }, nil } return &gateway.InitiateFileUploadResponse{ diff --git a/internal/grpc/services/gateway/webdavstorageprovider.go b/internal/grpc/services/gateway/webdavstorageprovider.go index ba12c9fc80..5c27014571 100644 --- a/internal/grpc/services/gateway/webdavstorageprovider.go +++ b/internal/grpc/services/gateway/webdavstorageprovider.go @@ -20,6 +20,7 @@ package gateway import ( "context" + "fmt" "net/url" "path" "strings" @@ -55,7 +56,7 @@ func (s *svc) webdavRefStat(ctx context.Context, targetURL string, nameQueries . // ownloud-specific fields to get the resource ID and permissions. info, err := c.Stat(ep.filePath) if err != nil { - return nil, errors.Wrap(err, "gateway: error calling stat at the webdav endpoint: "+ep.endpoint) + return nil, errors.Wrap(err, fmt.Sprintf("gateway: error statting %s at the webdav endpoint: %s", ep.filePath, ep.endpoint)) } return normalize(info.(*gowebdav.File)), nil } @@ -77,7 +78,7 @@ func (s *svc) webdavRefLs(ctx context.Context, targetURL string, nameQueries ... // ownloud-specific fields to get the resource ID and permissions. infos, err := c.ReadDir(ep.filePath) if err != nil { - return nil, errors.Wrap(err, "gateway: error calling stat at the webdav endpoint: "+ep.endpoint) + return nil, errors.Wrap(err, fmt.Sprintf("gateway: error listing %s at the webdav endpoint: %s", ep.filePath, ep.endpoint)) } mds := []*provider.ResourceInfo{} @@ -103,7 +104,7 @@ func (s *svc) webdavRefMkdir(ctx context.Context, targetURL string, nameQueries err = c.Mkdir(ep.filePath, 0700) if err != nil { - return errors.Wrap(err, "gateway: error calling mkdir at the webdav endpoint: "+ep.endpoint) + return errors.Wrap(err, fmt.Sprintf("gateway: error creating dir %s at the webdav endpoint: %s", ep.filePath, ep.endpoint)) } return nil } @@ -132,7 +133,7 @@ func (s *svc) webdavRefMove(ctx context.Context, targetURL, src, destination str err = c.Rename(srcEP.filePath, destEP.filePath, true) if err != nil { - return errors.Wrap(err, "gateway: error calling rename at the webdav endpoint: "+srcEP.endpoint) + return errors.Wrap(err, fmt.Sprintf("gateway: error renaming %s to %s at the webdav endpoint: %s", srcEP.filePath, destEP.filePath, srcEP.endpoint)) } return nil } @@ -152,7 +153,7 @@ func (s *svc) webdavRefDelete(ctx context.Context, targetURL string, nameQueries err = c.Remove(ep.filePath) if err != nil { - return errors.Wrap(err, "gateway: error calling remove at the webdav endpoint: "+ep.endpoint) + return errors.Wrap(err, fmt.Sprintf("gateway: error removing %s at the webdav endpoint: %s", ep.filePath, ep.endpoint)) } return nil } diff --git a/internal/http/services/dataprovider/put.go b/internal/http/services/dataprovider/put.go index b38d153084..1bcbfbb65b 100644 --- a/internal/http/services/dataprovider/put.go +++ b/internal/http/services/dataprovider/put.go @@ -63,10 +63,14 @@ func (s *svc) doTusPut(w http.ResponseWriter, r *http.Request) { return } - length, err := strconv.ParseInt(r.Header.Get("Upload-Length"), 10, 64) + length, err := strconv.ParseInt(r.Header.Get("Content-Length"), 10, 64) if err != nil { - w.WriteHeader(http.StatusBadRequest) - return + // Fallback to Upload-Length + length, err = strconv.ParseInt(r.Header.Get("Upload-Length"), 10, 64) + if err != nil { + w.WriteHeader(http.StatusBadRequest) + return + } } dataServerURL := fmt.Sprintf("http://%s%s", r.Host, r.RequestURI) diff --git a/internal/http/services/owncloud/ocdav/put.go b/internal/http/services/owncloud/ocdav/put.go index e1f7c2e7a7..718e896bad 100644 --- a/internal/http/services/owncloud/ocdav/put.go +++ b/internal/http/services/owncloud/ocdav/put.go @@ -202,16 +202,20 @@ func (s *svc) handlePut(w http.ResponseWriter, r *http.Request, ns string) { } } - length, err := strconv.ParseInt(r.Header.Get("Upload-Length"), 10, 64) + length, err := strconv.ParseInt(r.Header.Get("Content-Length"), 10, 64) if err != nil { - w.WriteHeader(http.StatusBadRequest) - return + // Fallback to Upload-Length + length, err = strconv.ParseInt(r.Header.Get("Upload-Length"), 10, 64) + if err != nil { + w.WriteHeader(http.StatusBadRequest) + return + } } opaqueMap := map[string]*typespb.OpaqueEntry{ "Upload-Length": { Decoder: "plain", - Value: []byte(r.Header.Get("Upload-Length")), + Value: []byte(strconv.FormatInt(length, 10)), }, } diff --git a/pkg/storage/utils/localfs/localfs.go b/pkg/storage/utils/localfs/localfs.go index 054cd79bed..5f643499d5 100644 --- a/pkg/storage/utils/localfs/localfs.go +++ b/pkg/storage/utils/localfs/localfs.go @@ -1163,7 +1163,7 @@ func (fs *localfs) propagate(ctx context.Context, leafPath string) error { } parts := strings.Split(strings.TrimPrefix(leafPath, root), "/") - // root never ents in / so the split returns an empty first element, which we can skip + // root never ends in / so the split returns an empty first element, which we can skip // we do not need to chmod the last element because it is the leaf path (< and not <= comparison) for i := 1; i < len(parts); i++ { if err := os.Chtimes(root, fi.ModTime(), fi.ModTime()); err != nil { diff --git a/pkg/token/manager/jwt/jwt.go b/pkg/token/manager/jwt/jwt.go index c92b8ff34b..2a48fef2b6 100644 --- a/pkg/token/manager/jwt/jwt.go +++ b/pkg/token/manager/jwt/jwt.go @@ -32,7 +32,7 @@ import ( "github.com/pkg/errors" ) -const defaultExpiration int64 = 3600 // 1 hour +const defaultExpiration int64 = 86400 // 1 day func init() { registry.Register("jwt", New)