From 69d0650994ef4f9224017a3bd3225a23deafa65e Mon Sep 17 00:00:00 2001 From: kobergj Date: Fri, 22 May 2026 09:45:07 +0200 Subject: [PATCH] fix(proxy): [OCISDEV-845] skip space reconciliation on signed URL requests (#12286) The space management middleware removed users from all project spaces when processing signed URL requests because no OIDC claims are present in that auth context. Return early when claims are nil to prevent the oscillating add/remove cycle. Signed-off-by: Julian Koberg Co-authored-by: Claude Opus 4.6 --- .../unreleased/fix-space-manager-signed-url.md | 15 +++++++++++++++ services/proxy/pkg/middleware/space_manager.go | 12 +++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 changelog/unreleased/fix-space-manager-signed-url.md diff --git a/changelog/unreleased/fix-space-manager-signed-url.md b/changelog/unreleased/fix-space-manager-signed-url.md new file mode 100644 index 00000000000..8eadc22097a --- /dev/null +++ b/changelog/unreleased/fix-space-manager-signed-url.md @@ -0,0 +1,15 @@ +Bugfix: Fix space management middleware removing users from spaces on download + +The space management middleware ran on every authenticated request, including +signed URL requests used for file downloads. Since signed URL auth does not +carry OIDC claims, the middleware interpreted the absence of claims as "user +should have no space access" and removed the user from all project spaces. +On the next OIDC request the user was re-added, causing an oscillating +add/remove cycle that led to intermittent download failures and transient +"space not found" errors. + +The middleware now skips reconciliation entirely when no OIDC claims are +present in the request context. + +https://github.com/owncloud/ocis/pull/12285 +https://github.com/owncloud/ocis/issues/12285 diff --git a/services/proxy/pkg/middleware/space_manager.go b/services/proxy/pkg/middleware/space_manager.go index 1f6a52a72e4..ac9cf5a2d21 100644 --- a/services/proxy/pkg/middleware/space_manager.go +++ b/services/proxy/pkg/middleware/space_manager.go @@ -68,6 +68,10 @@ func (csm claimSpaceManager) ServeHTTP(w http.ResponseWriter, req *http.Request) // no user in context, we omit this request return } + if spaceAssignments == nil { + // no OIDC claims available (e.g. signed URL auth), skip reconciliation + return + } ctx, gwc, err := csm.getCtx() if err != nil { @@ -153,9 +157,15 @@ func (csm claimSpaceManager) evaluateContext(ctx context.Context) (string, map[s return u.GetId().GetOpaqueId(), csm.getSpaceAssignments(ctx) } -// returns a map[spaceID]role +// returns a map[spaceID]role or nil if no OIDC claims are available in the context func (csm claimSpaceManager) getSpaceAssignments(ctx context.Context) map[string]string { claims := oidc.FromContext(ctx) + if claims == nil { + // No OIDC claims in context (e.g. signed URL auth). Skip reconciliation + // to avoid removing the user from all spaces. + return nil + } + values, ok := claims[csm.claimName].([]any) if !ok { csm.logger.Error().Interface("claims", claims).Str("claimname", csm.claimName).Msg("configured claims are not an array")