From 9662673ac85049e206d6dbd1e321d015ae67109c Mon Sep 17 00:00:00 2001 From: Javier Ferrer Date: Tue, 12 Dec 2023 10:16:36 +0100 Subject: [PATCH] Changelog and linting --- changelog/unreleased/group-capabilities-fix.md | 7 +++++++ .../ocs/handlers/cloud/capabilities/capabilities.go | 2 +- .../ocs/handlers/cloud/capabilities/uploads.go | 10 ---------- .../owncloud/ocs/handlers/cloud/users/users.go | 2 +- 4 files changed, 9 insertions(+), 12 deletions(-) create mode 100644 changelog/unreleased/group-capabilities-fix.md diff --git a/changelog/unreleased/group-capabilities-fix.md b/changelog/unreleased/group-capabilities-fix.md new file mode 100644 index 00000000000..59442686a35 --- /dev/null +++ b/changelog/unreleased/group-capabilities-fix.md @@ -0,0 +1,7 @@ +Bugfix: Fix group-based capabilities + +The group-based capabilities require an authenticated endpoint, as we must query +the logged-in user's groups to get those. This PR moves them to the `getSelf` +endpoint in the user handler. + +https://github.com/cs3org/reva/pull/???? diff --git a/internal/http/services/owncloud/ocs/handlers/cloud/capabilities/capabilities.go b/internal/http/services/owncloud/ocs/handlers/cloud/capabilities/capabilities.go index 35725657784..0c3d4f88f09 100644 --- a/internal/http/services/owncloud/ocs/handlers/cloud/capabilities/capabilities.go +++ b/internal/http/services/owncloud/ocs/handlers/cloud/capabilities/capabilities.go @@ -16,7 +16,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -// Package capabilities contains the capabilities endpoint. +// Package capabilities contains the capabilities handler. package capabilities import ( diff --git a/internal/http/services/owncloud/ocs/handlers/cloud/capabilities/uploads.go b/internal/http/services/owncloud/ocs/handlers/cloud/capabilities/uploads.go index ac28cf20d2b..c38056fc79f 100644 --- a/internal/http/services/owncloud/ocs/handlers/cloud/capabilities/uploads.go +++ b/internal/http/services/owncloud/ocs/handlers/cloud/capabilities/uploads.go @@ -23,9 +23,6 @@ import ( "strings" "github.com/cs3org/reva/internal/http/services/owncloud/ocs/data" - "github.com/cs3org/reva/pkg/appctx" - - "github.com/juliangruber/go-intersect" ) type chunkProtocol string @@ -51,13 +48,6 @@ func (h *Handler) getCapabilitiesForUserAgent(_ context.Context, userAgent strin return data.CapabilitiesData{Capabilities: &c, Version: h.c.Version} } -func ctxUserBelongsToGroups(ctx context.Context, groups []string) bool { - if user, ok := appctx.ContextGetUser(ctx); ok { - return len(intersect.Simple(groups, user.Groups)) > 0 - } - return false -} - func setCapabilitiesForChunkProtocol(cp chunkProtocol, c *data.Capabilities) { switch cp { case chunkV1: diff --git a/internal/http/services/owncloud/ocs/handlers/cloud/users/users.go b/internal/http/services/owncloud/ocs/handlers/cloud/users/users.go index 832eea72fae..6eef1eca356 100644 --- a/internal/http/services/owncloud/ocs/handlers/cloud/users/users.go +++ b/internal/http/services/owncloud/ocs/handlers/cloud/users/users.go @@ -73,7 +73,7 @@ type Users struct { // FIXME home should never be exposed ... even in oc 10 // home TwoFactorAuthEnabled bool `json:"two_factor_auth_enabled" xml:"two_factor_auth_enabled"` - GroupBasedCapabilities CapabilitiesGroupBased `json:"group-capabilities" xml:"group-capabilities"` + GroupBasedCapabilities CapabilitiesGroupBased `json:"group-capabilities" xml:"group-capabilities"` } // CapabilitiesGroupBased holds capabilities based on the groups a user belongs to.