Skip to content

Commit

Permalink
Changelog and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
javfg committed Dec 12, 2023
1 parent d7de201 commit 9662673
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
7 changes: 7 additions & 0 deletions changelog/unreleased/group-capabilities-fix.md
Original file line number Diff line number Diff line change
@@ -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/????
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 9662673

Please sign in to comment.