From 6ff8a3cd27acad8ec8361ba7218f3605c24109c8 Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Tue, 18 Jul 2023 15:04:10 +0200 Subject: [PATCH] test infinity changes Signed-off-by: Christian Richter --- go.mod | 2 + go.sum | 4 +- .../http/services/datagateway/datagateway.go | 38 +++---- .../http/services/owncloud/ocdav/avatars.go | 3 +- .../services/owncloud/ocdav/config/config.go | 88 +++++++++++++++ .../http/services/owncloud/ocdav/dav.go | 3 +- .../http/services/owncloud/ocdav/meta.go | 3 +- .../http/services/owncloud/ocdav/ocdav.go | 101 ++---------------- .../owncloud/ocdav/propfind/propfind.go | 17 ++- .../http/services/owncloud/ocdav/put.go | 12 --- .../http/services/owncloud/ocdav/spaces.go | 5 +- .../http/services/owncloud/ocdav/trashbin.go | 3 +- .../http/services/owncloud/ocdav/tus.go | 13 --- .../services/owncloud/ocdav/validation.go | 4 +- .../http/services/owncloud/ocdav/versions.go | 3 +- .../http/services/owncloud/ocdav/webdav.go | 2 +- .../cs3org/reva/v2/pkg/micro/ocdav/option.go | 15 +-- .../reva/v2/pkg/rgrpc/todo/pool/connection.go | 21 +++- vendor/modules.txt | 4 +- 19 files changed, 176 insertions(+), 165 deletions(-) create mode 100644 vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/config/config.go diff --git a/go.mod b/go.mod index 425b38eb71..9a9ac51740 100644 --- a/go.mod +++ b/go.mod @@ -340,3 +340,5 @@ require ( replace github.com/cs3org/go-cs3apis => github.com/2403905/go-cs3apis v0.0.0-20230517122726-727045414fd1 // replace github.com/cs3org/reva/v2 => github.com/micbar/reva/v2 v2.0.0-20230626125956-c381fe19a108 + +replace github.com/cs3org/reva/v2 => github.com/dragonchaser/reva/v2 v2.4.1-0.20230721092423-decf58981cfd diff --git a/go.sum b/go.sum index 525a672a52..fc7c95e8ea 100644 --- a/go.sum +++ b/go.sum @@ -625,8 +625,6 @@ github.com/crewjam/httperr v0.2.0 h1:b2BfXR8U3AlIHwNeFFvZ+BV1LFvKLlzMjzaTnZMybNo github.com/crewjam/httperr v0.2.0/go.mod h1:Jlz+Sg/XqBQhyMjdDiC+GNNRzZTD7x39Gu3pglZ5oH4= github.com/crewjam/saml v0.4.13 h1:TYHggH/hwP7eArqiXSJUvtOPNzQDyQ7vwmwEqlFWhMc= github.com/crewjam/saml v0.4.13/go.mod h1:igEejV+fihTIlHXYP8zOec3V5A8y3lws5bQBFsTm4gA= -github.com/cs3org/reva/v2 v2.15.1-0.20230718140539-0af2a07c7fd9 h1:ycV7H1siLmMiRmc9kaS0WonysHYUT7irvH4FDDAghqQ= -github.com/cs3org/reva/v2 v2.15.1-0.20230718140539-0af2a07c7fd9/go.mod h1:4z5EQghS2LhSWZWocH51Dw9VAs16No1zSFvFgQtgS7w= github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8 h1:Z9lwXumT5ACSmJ7WGnFl+OMLLjpz5uR2fyz7dC255FI= github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8/go.mod h1:4abs/jPXcmJzYoYGF91JF9Uq9s/KL5n1jvFDix8KcqY= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= @@ -659,6 +657,8 @@ github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyG github.com/dnsimple/dnsimple-go v0.63.0/go.mod h1:O5TJ0/U6r7AfT8niYNlmohpLbCSG+c71tQlGr9SeGrg= github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= +github.com/dragonchaser/reva/v2 v2.4.1-0.20230721092423-decf58981cfd h1:ngsy/v6TBnhJ2CqrXUmQBhlEhUs3y/TOMu7e2kSuonY= +github.com/dragonchaser/reva/v2 v2.4.1-0.20230721092423-decf58981cfd/go.mod h1:4z5EQghS2LhSWZWocH51Dw9VAs16No1zSFvFgQtgS7w= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e h1:rcHHSQqzCgvlwP0I/fQ8rQMn/MpHE5gWSLdtpxtP6KQ= diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/datagateway/datagateway.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/datagateway/datagateway.go index 5e66ad413d..69fe36f5ea 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/datagateway/datagateway.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/datagateway/datagateway.go @@ -58,8 +58,8 @@ func init() { global.Register("datagateway", New) } -// TransferClaims are custom claims for a JWT token to be used between the metadata and data gateways. -type TransferClaims struct { +// transferClaims are custom claims for a JWT token to be used between the metadata and data gateways. +type transferClaims struct { jwt.StandardClaims Target string `json:"target"` } @@ -161,24 +161,7 @@ func addCorsHeader(res http.ResponseWriter) { headers.Set("Access-Control-Allow-Methods", "GET, POST, OPTIONS, HEAD") } -// Verify a transfer token against the given secret -func Verify(ctx context.Context, token string, secret string) (*TransferClaims, error) { - j, err := jwt.ParseWithClaims(token, &TransferClaims{}, func(token *jwt.Token) (interface{}, error) { - return []byte(secret), nil - }) - - if err != nil { - return nil, errors.Wrap(err, "error parsing token") - } - - if claims, ok := j.Claims.(*TransferClaims); ok && j.Valid { - return claims, nil - } - err = errtypes.InvalidCredentials("token invalid") - return nil, err -} - -func (s *svc) verify(ctx context.Context, r *http.Request) (*TransferClaims, error) { +func (s *svc) verify(ctx context.Context, r *http.Request) (*transferClaims, error) { // Extract transfer token from request header. If not existing, assume that it's the last path segment instead. token := r.Header.Get(TokenTransportHeader) if token == "" { @@ -186,7 +169,20 @@ func (s *svc) verify(ctx context.Context, r *http.Request) (*TransferClaims, err r.Header.Set(TokenTransportHeader, token) } - return Verify(ctx, token, s.conf.TransferSharedSecret) + j, err := jwt.ParseWithClaims(token, &transferClaims{}, func(token *jwt.Token) (interface{}, error) { + return []byte(s.conf.TransferSharedSecret), nil + }) + + if err != nil { + return nil, errors.Wrap(err, "error parsing token") + } + + if claims, ok := j.Claims.(*transferClaims); ok && j.Valid { + return claims, nil + } + + err = errtypes.InvalidCredentials("token invalid") + return nil, err } func (s *svc) doHead(w http.ResponseWriter, r *http.Request) { diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/avatars.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/avatars.go index 89d3559272..49cbb60390 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/avatars.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/avatars.go @@ -22,6 +22,7 @@ import ( "encoding/hex" "net/http" + "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/config" "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/net" "github.com/cs3org/reva/v2/pkg/appctx" "github.com/cs3org/reva/v2/pkg/rhttp/router" @@ -31,7 +32,7 @@ import ( type AvatarsHandler struct { } -func (h *AvatarsHandler) init(c *Config) error { +func (h *AvatarsHandler) init(c *config.Config) error { return nil } diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/config/config.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/config/config.go new file mode 100644 index 0000000000..2e00de97d2 --- /dev/null +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/config/config.go @@ -0,0 +1,88 @@ +package config + +import "github.com/cs3org/reva/v2/pkg/sharedconf" + +// Config holds the config options that need to be passed down to all ocdav handlers +type Config struct { + Prefix string `mapstructure:"prefix"` + // FilesNamespace prefixes the namespace, optionally with user information. + // Example: if FilesNamespace is /users/{{substr 0 1 .Username}}/{{.Username}} + // and received path is /docs the internal path will be: + // /users///docs + FilesNamespace string `mapstructure:"files_namespace"` + // WebdavNamespace prefixes the namespace, optionally with user information. + // Example: if WebdavNamespace is /users/{{substr 0 1 .Username}}/{{.Username}} + // and received path is /docs the internal path will be: + // /users///docs + WebdavNamespace string `mapstructure:"webdav_namespace"` + SharesNamespace string `mapstructure:"shares_namespace"` + GatewaySvc string `mapstructure:"gatewaysvc"` + Timeout int64 `mapstructure:"timeout"` + Insecure bool `mapstructure:"insecure"` + // If true, HTTP COPY will expect the HTTP-TPC (third-party copy) headers + EnableHTTPTpc bool `mapstructure:"enable_http_tpc"` + PublicURL string `mapstructure:"public_url"` + FavoriteStorageDriver string `mapstructure:"favorite_storage_driver"` + FavoriteStorageDrivers map[string]map[string]interface{} `mapstructure:"favorite_storage_drivers"` + Version string `mapstructure:"version"` + VersionString string `mapstructure:"version_string"` + Edition string `mapstructure:"edition"` + Product string `mapstructure:"product"` + ProductName string `mapstructure:"product_name"` + ProductVersion string `mapstructure:"product_version"` + AllowPropfindDepthInfinitiy bool `mapstructure:"allow_depth_infinity"` + + TransferSharedSecret string `mapstructure:"transfer_shared_secret"` + + NameValidation NameValidation `mapstructure:"validation"` + + MachineAuthAPIKey string `mapstructure:"machine_auth_apikey"` +} + +// NameValidation is the validation configuration for file and folder names +type NameValidation struct { + InvalidChars []string `mapstructure:"invalid_chars"` + MaxLength int `mapstructure:"max_length"` +} + +// Init initializes the configuration +func (c *Config) Init() { + // note: default c.Prefix is an empty string + c.GatewaySvc = sharedconf.GetGatewaySVC(c.GatewaySvc) + + if c.FavoriteStorageDriver == "" { + c.FavoriteStorageDriver = "memory" + } + + if c.Version == "" { + c.Version = "10.0.11.5" + } + + if c.VersionString == "" { + c.VersionString = "10.0.11" + } + + if c.Product == "" { + c.Product = "reva" + } + + if c.ProductName == "" { + c.ProductName = "reva" + } + + if c.ProductVersion == "" { + c.ProductVersion = "10.0.11" + } + + if c.Edition == "" { + c.Edition = "community" + } + + if c.NameValidation.InvalidChars == nil { + c.NameValidation.InvalidChars = []string{"\f", "\r", "\n", "\\"} + } + + if c.NameValidation.MaxLength == 0 { + c.NameValidation.MaxLength = 255 + } +} diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/dav.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/dav.go index b3a133b241..6a2d66b911 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/dav.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/dav.go @@ -28,6 +28,7 @@ import ( userv1beta1 "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1" provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" + "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/config" "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/errors" "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/net" "github.com/cs3org/reva/v2/pkg/appctx" @@ -57,7 +58,7 @@ type DavHandler struct { SharesHandler *WebDavHandler } -func (h *DavHandler) init(c *Config) error { +func (h *DavHandler) init(c *config.Config) error { h.AvatarsHandler = new(AvatarsHandler) if err := h.AvatarsHandler.init(c); err != nil { return err diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/meta.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/meta.go index 169f9fd3fe..09e54bfa25 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/meta.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/meta.go @@ -27,6 +27,7 @@ import ( rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1" provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" + "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/config" "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/errors" "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/net" "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/prop" @@ -41,7 +42,7 @@ type MetaHandler struct { VersionsHandler *VersionsHandler } -func (h *MetaHandler) init(c *Config) error { +func (h *MetaHandler) init(c *config.Config) error { h.VersionsHandler = new(VersionsHandler) return h.VersionsHandler.init(c) } diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/ocdav.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/ocdav.go index e96e1b445f..a96d11ebf4 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/ocdav.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/ocdav.go @@ -29,6 +29,7 @@ import ( userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1" provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" + "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/config" "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/net" "github.com/cs3org/reva/v2/pkg/appctx" ctxpkg "github.com/cs3org/reva/v2/pkg/ctx" @@ -37,7 +38,6 @@ import ( "github.com/cs3org/reva/v2/pkg/rhttp" "github.com/cs3org/reva/v2/pkg/rhttp/global" "github.com/cs3org/reva/v2/pkg/rhttp/router" - "github.com/cs3org/reva/v2/pkg/sharedconf" "github.com/cs3org/reva/v2/pkg/storage/favorite" "github.com/cs3org/reva/v2/pkg/storage/favorite/registry" "github.com/cs3org/reva/v2/pkg/storage/utils/templates" @@ -57,91 +57,8 @@ func init() { global.Register("ocdav", New) } -// Config holds the config options that need to be passed down to all ocdav handlers -type Config struct { - Prefix string `mapstructure:"prefix"` - // FilesNamespace prefixes the namespace, optionally with user information. - // Example: if FilesNamespace is /users/{{substr 0 1 .Username}}/{{.Username}} - // and received path is /docs the internal path will be: - // /users///docs - FilesNamespace string `mapstructure:"files_namespace"` - // WebdavNamespace prefixes the namespace, optionally with user information. - // Example: if WebdavNamespace is /users/{{substr 0 1 .Username}}/{{.Username}} - // and received path is /docs the internal path will be: - // /users///docs - WebdavNamespace string `mapstructure:"webdav_namespace"` - SharesNamespace string `mapstructure:"shares_namespace"` - GatewaySvc string `mapstructure:"gatewaysvc"` - Timeout int64 `mapstructure:"timeout"` - Insecure bool `mapstructure:"insecure"` - // If true, HTTP COPY will expect the HTTP-TPC (third-party copy) headers - EnableHTTPTpc bool `mapstructure:"enable_http_tpc"` - PublicURL string `mapstructure:"public_url"` - FavoriteStorageDriver string `mapstructure:"favorite_storage_driver"` - FavoriteStorageDrivers map[string]map[string]interface{} `mapstructure:"favorite_storage_drivers"` - Version string `mapstructure:"version"` - VersionString string `mapstructure:"version_string"` - Edition string `mapstructure:"edition"` - Product string `mapstructure:"product"` - ProductName string `mapstructure:"product_name"` - ProductVersion string `mapstructure:"product_version"` - // optional, if set will unpack the transfer token and directly send uploads to the data provider - TransferSharedSecret string `mapstructure:"transfer_shared_secret"` - - NameValidation NameValidation `mapstructure:"validation"` - - MachineAuthAPIKey string `mapstructure:"machine_auth_apikey"` -} - -// NameValidation is the validation configuration for file and folder names -type NameValidation struct { - InvalidChars []string `mapstructure:"invalid_chars"` - MaxLength int `mapstructure:"max_length"` -} - -func (c *Config) init() { - // note: default c.Prefix is an empty string - c.GatewaySvc = sharedconf.GetGatewaySVC(c.GatewaySvc) - - if c.FavoriteStorageDriver == "" { - c.FavoriteStorageDriver = "memory" - } - - if c.Version == "" { - c.Version = "10.0.11.5" - } - - if c.VersionString == "" { - c.VersionString = "10.0.11" - } - - if c.Product == "" { - c.Product = "reva" - } - - if c.ProductName == "" { - c.ProductName = "reva" - } - - if c.ProductVersion == "" { - c.ProductVersion = "10.0.11" - } - - if c.Edition == "" { - c.Edition = "community" - } - - if c.NameValidation.InvalidChars == nil { - c.NameValidation.InvalidChars = []string{"\f", "\r", "\n", "\\"} - } - - if c.NameValidation.MaxLength == 0 { - c.NameValidation.MaxLength = 255 - } -} - type svc struct { - c *Config + c *config.Config webDavHandler *WebDavHandler davHandler *DavHandler favoritesManager favorite.Manager @@ -153,17 +70,17 @@ type svc struct { nameValidators []Validator } -func (s *svc) Config() *Config { +func (s *svc) Config() *config.Config { return s.c } -func getFavoritesManager(c *Config) (favorite.Manager, error) { +func getFavoritesManager(c *config.Config) (favorite.Manager, error) { if f, ok := registry.NewFuncs[c.FavoriteStorageDriver]; ok { return f(c.FavoriteStorageDrivers[c.FavoriteStorageDriver]) } return nil, errtypes.NotFound("driver not found: " + c.FavoriteStorageDriver) } -func getLockSystem(c *Config) (LockSystem, error) { +func getLockSystem(c *config.Config) (LockSystem, error) { // TODO in memory implementation selector, err := pool.GatewaySelector(c.GatewaySvc) if err != nil { @@ -174,12 +91,12 @@ func getLockSystem(c *Config) (LockSystem, error) { // New returns a new ocdav service func New(m map[string]interface{}, log *zerolog.Logger) (global.Service, error) { - conf := &Config{} + conf := &config.Config{} if err := mapstructure.Decode(m, conf); err != nil { return nil, err } - conf.init() + conf.Init() fm, err := getFavoritesManager(conf) if err != nil { @@ -194,9 +111,9 @@ func New(m map[string]interface{}, log *zerolog.Logger) (global.Service, error) } // NewWith returns a new ocdav service -func NewWith(conf *Config, fm favorite.Manager, ls LockSystem, _ *zerolog.Logger, selector pool.Selectable[gateway.GatewayAPIClient]) (global.Service, error) { +func NewWith(conf *config.Config, fm favorite.Manager, ls LockSystem, _ *zerolog.Logger, selector pool.Selectable[gateway.GatewayAPIClient]) (global.Service, error) { // be safe - init the conf again - conf.init() + conf.Init() s := &svc{ c: conf, diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/propfind/propfind.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/propfind/propfind.go index 6091caffb6..07c58174dc 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/propfind/propfind.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/propfind/propfind.go @@ -38,6 +38,7 @@ import ( provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" typesv1beta1 "github.com/cs3org/go-cs3apis/cs3/types/v1beta1" "github.com/cs3org/reva/v2/internal/grpc/services/storageprovider" + "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/config" "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/errors" "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/net" "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/prop" @@ -168,13 +169,15 @@ func NewMultiStatusResponseXML() *MultiStatusResponseXML { type Handler struct { PublicURL string selector pool.Selectable[gateway.GatewayAPIClient] + c *config.Config } // NewHandler returns a new PropfindHandler instance -func NewHandler(publicURL string, selector pool.Selectable[gateway.GatewayAPIClient]) *Handler { +func NewHandler(publicURL string, selector pool.Selectable[gateway.GatewayAPIClient], c *config.Config) *Handler { return &Handler{ PublicURL: publicURL, selector: selector, + c: c, } } @@ -244,6 +247,18 @@ func (p *Handler) HandleSpacesPropfind(w http.ResponseWriter, r *http.Request, s return } + if depth == net.DepthInfinity && !p.c.AllowPropfindDepthInfinitiy { + span.RecordError(errors.ErrInvalidDepth) + span.SetStatus(codes.Error, "DEPTH: infinity is not supported") + span.SetAttributes(semconv.HTTPStatusCodeKey.Int(http.StatusBadRequest)) + sublog.Debug().Str("depth", dh).Msg(errors.ErrInvalidDepth.Error()) + w.WriteHeader(http.StatusBadRequest) + m := fmt.Sprintf("Invalid Depth header value: %v", dh) + b, err := errors.Marshal(http.StatusBadRequest, m, "") + errors.HandleWebdavError(&sublog, w, b, err) + return + } + pf, status, err := ReadPropfind(r.Body) if err != nil { sublog.Debug().Err(err).Msg("error reading propfind request") diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/put.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/put.go index e6e8322f7b..58063e5ee2 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/put.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/put.go @@ -298,18 +298,6 @@ func (s *svc) handlePut(ctx context.Context, w http.ResponseWriter, r *http.Requ } } - // if we know the transfer secret we can directly talk to the dataprovider - if s.c.TransferSharedSecret != "" { - claims, err := datagateway.Verify(ctx, token, s.c.TransferSharedSecret) - if err != nil { - log.Error().Err(err).Msg("error verifying transfer token") - w.WriteHeader(http.StatusInternalServerError) - return - } - // directly send request to target - ep = claims.Target - } - httpReq, err := rhttp.NewRequest(ctx, http.MethodPut, ep, r.Body) if err != nil { w.WriteHeader(http.StatusInternalServerError) diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/spaces.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/spaces.go index b915ce63b0..a5404b102c 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/spaces.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/spaces.go @@ -22,6 +22,7 @@ import ( "net/http" "path" + "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/config" "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/errors" "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/net" "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/propfind" @@ -38,7 +39,7 @@ type SpacesHandler struct { useLoggedInUserNS bool } -func (h *SpacesHandler) init(c *Config) error { +func (h *SpacesHandler) init(c *config.Config) error { h.gatewaySvc = c.GatewaySvc h.namespace = path.Join("/", c.WebdavNamespace) h.useLoggedInUserNS = true @@ -78,7 +79,7 @@ func (h *SpacesHandler) Handler(s *svc, trashbinHandler *TrashbinHandler) http.H var err error switch r.Method { case MethodPropfind: - p := propfind.NewHandler(config.PublicURL, s.gatewaySelector) + p := propfind.NewHandler(config.PublicURL, s.gatewaySelector, config) p.HandleSpacesPropfind(w, r, spaceID) case MethodProppatch: status, err = s.handleSpacesProppatch(w, r, spaceID) diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/trashbin.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/trashbin.go index 78de68e4af..6e7f19aef1 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/trashbin.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/trashbin.go @@ -29,6 +29,7 @@ import ( "strings" "time" + "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/config" "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/errors" "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/net" "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/prop" @@ -51,7 +52,7 @@ type TrashbinHandler struct { namespace string } -func (h *TrashbinHandler) init(c *Config) error { +func (h *TrashbinHandler) init(c *config.Config) error { h.gatewaySvc = c.GatewaySvc h.namespace = path.Join("/", c.FilesNamespace) return nil diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/tus.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/tus.go index 0d4e30fa7c..5371472f71 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/tus.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/tus.go @@ -32,7 +32,6 @@ import ( link "github.com/cs3org/go-cs3apis/cs3/sharing/link/v1beta1" provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" typespb "github.com/cs3org/go-cs3apis/cs3/types/v1beta1" - "github.com/cs3org/reva/v2/internal/http/services/datagateway" "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/errors" "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/net" "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/spacelookup" @@ -255,18 +254,6 @@ func (s *svc) handleTusPost(ctx context.Context, w http.ResponseWriter, r *http. } var httpRes *http.Response - // if we know the transfer secret we can directly talk to the dataprovider - if s.c.TransferSharedSecret != "" { - claims, err := datagateway.Verify(ctx, token, s.c.TransferSharedSecret) - if err != nil { - log.Error().Err(err).Msg("error verifying transfer token") - w.WriteHeader(http.StatusInternalServerError) - return - } - // directly send request to target - ep = claims.Target - } - httpReq, err := rhttp.NewRequest(ctx, http.MethodPatch, ep, r.Body) if err != nil { log.Debug().Err(err).Msg("wrong request") diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/validation.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/validation.go index 859a9d65ea..168b3106b5 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/validation.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/validation.go @@ -4,13 +4,15 @@ import ( "errors" "fmt" "strings" + + "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/config" ) // Validator validates strings type Validator func(string) error // ValidatorsFromConfig returns the configured Validators -func ValidatorsFromConfig(c *Config) []Validator { +func ValidatorsFromConfig(c *config.Config) []Validator { // we always want to exclude empty names vals := []Validator{notEmpty()} diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/versions.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/versions.go index ae249c1a6f..1f6099597d 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/versions.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/versions.go @@ -23,6 +23,7 @@ import ( "net/http" "path" + "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/config" "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/errors" "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/net" "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/propfind" @@ -40,7 +41,7 @@ import ( type VersionsHandler struct { } -func (h *VersionsHandler) init(c *Config) error { +func (h *VersionsHandler) init(c *config.Config) error { return nil } diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/webdav.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/webdav.go index e471bfdf41..3a50b760a3 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/webdav.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/webdav.go @@ -72,7 +72,7 @@ func (h *WebDavHandler) Handler(s *svc) http.Handler { var status int // status 0 means the handler already sent the response switch r.Method { case MethodPropfind: - p := propfind.NewHandler(config.PublicURL, s.gatewaySelector) + p := propfind.NewHandler(config.PublicURL, s.gatewaySelector, config) p.HandlePathPropfind(w, r, ns) case MethodLock: status, err = s.handleLock(w, r, ns) diff --git a/vendor/github.com/cs3org/reva/v2/pkg/micro/ocdav/option.go b/vendor/github.com/cs3org/reva/v2/pkg/micro/ocdav/option.go index 00da05f59b..838710cd9f 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/micro/ocdav/option.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/micro/ocdav/option.go @@ -24,6 +24,7 @@ import ( gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1" "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav" + "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/config" "github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool" "github.com/cs3org/reva/v2/pkg/storage/favorite" "github.com/rs/zerolog" @@ -43,9 +44,8 @@ type Options struct { Context context.Context // Metrics *metrics.Metrics // Flags []cli.Flag - Name string - JWTSecret string - TransferSecret string + Name string + JWTSecret string FavoriteManager favorite.Manager GatewaySelector pool.Selectable[gateway.GatewayAPIClient] @@ -63,7 +63,7 @@ type Options struct { MetricsSubsystem string // ocdav.* is internal so we need to set config options individually - config ocdav.Config + config config.Config lockSystem ocdav.LockSystem AllowCredentials bool AllowedOrigins []string @@ -110,13 +110,6 @@ func JWTSecret(s string) Option { } } -// TransferSecret provides a function to set the transfer secret option. -func TransferSecret(s string) Option { - return func(o *Options) { - o.config.TransferSharedSecret = s - } -} - // MachineAuthAPIKey provides a function to set the machine auth api key option. func MachineAuthAPIKey(s string) Option { return func(o *Options) { diff --git a/vendor/github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool/connection.go b/vendor/github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool/connection.go index 253ee7f8f7..ea7488f63b 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool/connection.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool/connection.go @@ -20,8 +20,11 @@ package pool import ( "crypto/tls" + "os" + "strconv" rtrace "github.com/cs3org/reva/v2/pkg/trace" + "github.com/pkg/errors" "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc" "google.golang.org/grpc" "google.golang.org/grpc/credentials" @@ -29,13 +32,12 @@ import ( ) var ( - maxCallRecvMsgSize = 10240000 + _defaultMaxCallRecvMsgSize = 10240000 ) // NewConn creates a new connection to a grpc server // with open census tracing support. // TODO(labkode): make grpc tls configurable. -// TODO make maxCallRecvMsgSize configurable, raised from the default 4MB to be able to list 10k files func NewConn(address string, opts ...Option) (*grpc.ClientConn, error) { options := ClientOptions{} @@ -69,11 +71,24 @@ func NewConn(address string, opts ...Option) (*grpc.ClientConn, error) { } } + // NOTE: We need to configure some grpc options in a central place. + // If many services configure the (e.g.) gateway client differently, one will be pick randomly. This leads to inconsistencies when using the single binary. + // To avoid inconsistencies and race conditions we get the configuration here. + // Please do NOT follow the pattern of calling `os.Getenv` in the wild without consulting docu team first. + maxRcvMsgSize := _defaultMaxCallRecvMsgSize + if e := os.Getenv("OCIS_GRPC_MAX_RECEIVED_MESSAGE_SIZE"); e != "" { + s, err := strconv.Atoi(e) + if err != nil || s <= 0 { + return nil, errors.Wrap(err, "grpc max message size is not a valid int") + } + maxRcvMsgSize = s + } + conn, err := grpc.Dial( address, grpc.WithTransportCredentials(cred), grpc.WithDefaultCallOptions( - grpc.MaxCallRecvMsgSize(maxCallRecvMsgSize), + grpc.MaxCallRecvMsgSize(maxRcvMsgSize), ), grpc.WithStreamInterceptor(otelgrpc.StreamClientInterceptor( otelgrpc.WithTracerProvider( diff --git a/vendor/modules.txt b/vendor/modules.txt index 2c0054fa3c..388fba5207 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -352,7 +352,7 @@ github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1 github.com/cs3org/go-cs3apis/cs3/storage/registry/v1beta1 github.com/cs3org/go-cs3apis/cs3/tx/v1beta1 github.com/cs3org/go-cs3apis/cs3/types/v1beta1 -# github.com/cs3org/reva/v2 v2.15.1-0.20230718140539-0af2a07c7fd9 +# github.com/cs3org/reva/v2 v2.15.1-0.20230718140539-0af2a07c7fd9 => github.com/dragonchaser/reva/v2 v2.4.1-0.20230721092423-decf58981cfd ## explicit; go 1.20 github.com/cs3org/reva/v2/cmd/revad/internal/grace github.com/cs3org/reva/v2/cmd/revad/runtime @@ -420,6 +420,7 @@ github.com/cs3org/reva/v2/internal/http/services/meshdirectory github.com/cs3org/reva/v2/internal/http/services/metrics github.com/cs3org/reva/v2/internal/http/services/ocmd github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav +github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/config github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/errors github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/net github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/prop @@ -2206,3 +2207,4 @@ stash.kopano.io/kgol/oidc-go ## explicit; go 1.13 stash.kopano.io/kgol/rndm # github.com/cs3org/go-cs3apis => github.com/2403905/go-cs3apis v0.0.0-20230517122726-727045414fd1 +# github.com/cs3org/reva/v2 => github.com/dragonchaser/reva/v2 v2.4.1-0.20230721092423-decf58981cfd