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 <julian.koberg@kiteworks.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
af3e16b838
commit
69d0650994
2 files changed
+26
-1
No files matched your search
@@ -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
|
||||
@@ -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")
|
||||
|
||||
Reference in new issue
Block a user