From 5b29a68fe22c36a404055f2fe2e4cc466f6e6932 Mon Sep 17 00:00:00 2001 From: Julian Koberg Date: Wed, 6 May 2026 16:08:55 +0200 Subject: [PATCH 1/2] fix(proxy): [OCISDEV-845] skip space reconciliation on signed URL requests 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. Co-Authored-By: Claude Opus 4.6 Signed-off-by: Julian Koberg --- services/proxy/pkg/middleware/space_manager.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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") From 168133f1f231fbcc67afb7ae4a69685b47dfc020 Mon Sep 17 00:00:00 2001 From: Julian Koberg Date: Wed, 6 May 2026 16:11:24 +0200 Subject: [PATCH 2/2] chore(proxy): [OCISDEV-845] add changelog for space manager fix Co-Authored-By: Claude Opus 4.6 Signed-off-by: Julian Koberg --- .../unreleased/fix-space-manager-signed-url.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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