Merge pull request #11348 from 2403905/issue-10857

Fix the reva log interceptor. Implemented the Unwrap interface to all…
This commit is contained in:
Roman Perekhod
2025-05-26 09:19:12 +02:00
committed by GitHub
6 changed files with 33 additions and 8 deletions

View File

@@ -0,0 +1,7 @@
Bugfix: Fix the reva log interceptor
Fix the reva log interceptor. Implemented the Unwrap interface to allow TUS middleware to handle correctly
SetReadDeadline and SetWriteDeadline functions and to avoid the error during the upload.
https://github.com/owncloud/ocis/pull/11348
https://github.com/owncloud/ocis/issues/10857

2
go.mod
View File

@@ -67,7 +67,7 @@ require (
github.com/open-policy-agent/opa v1.4.2
github.com/orcaman/concurrent-map v1.0.0
github.com/owncloud/libre-graph-api-go v1.0.5-0.20250217093259-fa3804be6c27
github.com/owncloud/reva/v2 v2.0.0-20250502110034-f92362f1143d
github.com/owncloud/reva/v2 v2.0.0-20250523085723-637bba95d4ee
github.com/pkg/errors v0.9.1
github.com/pkg/xattr v0.4.10
github.com/prometheus/client_golang v1.21.1

4
go.sum
View File

@@ -886,8 +886,8 @@ github.com/orcaman/concurrent-map v1.0.0/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CF
github.com/ovh/go-ovh v1.1.0/go.mod h1:AxitLZ5HBRPyUd+Zl60Ajaag+rNTdVXWIkzfrVuTXWA=
github.com/owncloud/libre-graph-api-go v1.0.5-0.20250217093259-fa3804be6c27 h1:ID8s5lGBntmrlI6TbDAjTzRyHucn3bVM2wlW+HBplv4=
github.com/owncloud/libre-graph-api-go v1.0.5-0.20250217093259-fa3804be6c27/go.mod h1:+gT+x62AS9u2Farh9wE2uYmgdvTg0MQgsSI62D+xoRg=
github.com/owncloud/reva/v2 v2.0.0-20250502110034-f92362f1143d h1:tOtuFzGDsOoVf8Y9KbU9aDQvGvlUKctSBYf+jPYTXXE=
github.com/owncloud/reva/v2 v2.0.0-20250502110034-f92362f1143d/go.mod h1:vynpm6URhGypkIv9EVC7C+MHu3LwsqaINkMCSUnyZ0o=
github.com/owncloud/reva/v2 v2.0.0-20250523085723-637bba95d4ee h1:8CH2loM7QjPYli1RxuHhM1unpKj+vgE38gMwqZMXde0=
github.com/owncloud/reva/v2 v2.0.0-20250523085723-637bba95d4ee/go.mod h1:IKut/lONAPK0aNGSnI05tOq752YSMrRa2Sr+MFPuknk=
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw=
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0=
github.com/pablodz/inotifywaitgo v0.0.7 h1:1ii49dGBnRn0t1Sz7RGZS6/NberPEDQprwKHN49Bv6U=

View File

@@ -31,6 +31,7 @@ import (
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
"github.com/mitchellh/mapstructure"
"github.com/owncloud/reva/v2/internal/http/interceptors/auth/credential/registry"
tokenregistry "github.com/owncloud/reva/v2/internal/http/interceptors/auth/token/registry"
tokenwriterregistry "github.com/owncloud/reva/v2/internal/http/interceptors/auth/tokenwriter/registry"
@@ -46,7 +47,6 @@ import (
"github.com/owncloud/reva/v2/pkg/token"
tokenmgr "github.com/owncloud/reva/v2/pkg/token/manager/registry"
"github.com/owncloud/reva/v2/pkg/utils"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
"github.com/rs/zerolog"
semconv "go.opentelemetry.io/otel/semconv/v1.20.0"
@@ -186,13 +186,11 @@ func New(m map[string]interface{}, unprotected []string, tp trace.TracerProvider
return
}
log := appctx.GetLogger(r.Context())
isUnprotectedEndpoint := false
// For unprotected URLs, we try to authenticate the request in case some service needs it,
// but don't return any errors if it fails.
if utils.Skip(r.URL.Path, unprotected) {
log.Info().Msg("skipping auth check for: " + r.URL.Path)
isUnprotectedEndpoint = true
}
@@ -245,7 +243,11 @@ func authenticateUser(w http.ResponseWriter, r *http.Request, conf *config, toke
}
}
log.Warn().Msg("core access token not set")
if isUnprotectedEndpoint {
log.Info().Msgf("skipping auth check for: %s", r.URL.Path)
} else {
log.Warn().Msgf("core access token not set for URL %s", r.URL.Path)
}
userAgentCredKeys := getCredsForUserAgent(r.UserAgent(), conf.CredentialsByUserAgent, conf.CredentialChain)

View File

@@ -130,6 +130,7 @@ type commonLoggingResponseWriter interface {
http.Flusher
Status() int
Size() int
Unwrap() http.ResponseWriter
}
// responseLogger is wrapper of http.ResponseWriter that keeps track of its HTTP
@@ -170,6 +171,11 @@ func (l *responseLogger) Flush() {
}
}
// Unwrap returns the underlying wrapped http.ResponseWriter.
func (l responseLogger) Unwrap() http.ResponseWriter {
return l.w
}
type hijackLogger struct {
responseLogger
}
@@ -183,6 +189,11 @@ func (l *hijackLogger) Hijack() (net.Conn, *bufio.ReadWriter, error) {
return conn, rw, err
}
// Unwrap returns the underlying wrapped http.ResponseWriter.
func (l hijackLogger) Unwrap() http.ResponseWriter {
return l.w
}
type closeNotifyWriter struct {
loggingResponseWriter
http.CloseNotifier
@@ -193,3 +204,8 @@ type hijackCloseNotifier struct {
http.Hijacker
http.CloseNotifier
}
// Unwrap returns the underlying wrapped http.ResponseWriter.
func (l hijackCloseNotifier) Unwrap() http.ResponseWriter {
return l.loggingResponseWriter
}

2
vendor/modules.txt vendored
View File

@@ -1235,7 +1235,7 @@ github.com/orcaman/concurrent-map
# github.com/owncloud/libre-graph-api-go v1.0.5-0.20250217093259-fa3804be6c27
## explicit; go 1.18
github.com/owncloud/libre-graph-api-go
# github.com/owncloud/reva/v2 v2.0.0-20250502110034-f92362f1143d
# github.com/owncloud/reva/v2 v2.0.0-20250523085723-637bba95d4ee
## explicit; go 1.24
github.com/owncloud/reva/v2/cmd/revad/internal/grace
github.com/owncloud/reva/v2/cmd/revad/runtime