Skip to content

feat(settings): add ExternalShare.Write permission for Admin and Space Admin - #4088

Open
dragonchaser wants to merge 1 commit into
opencloud-eu:mainfrom
dragonchaser:backport-wp3-785
Open

dragonchaser wants to merge 1 commit into
opencloud-eu:mainfrom
dragonchaser:backport-wp3-785

Conversation

@dragonchaser

Copy link
Copy Markdown
Member

Adds the ExternalShare.Write permission (sharing with users on other instances) to the default Admin and Space Admin roles and wires its check into graph; nothing calls the check yet because OpenCloud has no multi-instance sharing, so the only visible change is the new permission in those roles.

AI assistance: Claude Code (claude-opus-5-5) ported the change and adapted it to the current code.

@dragonchaser dragonchaser added the Type:Maintenance E.g. technical debt, packaging, etc. label Nov 23, 2026
@codacy-production

codacy-production Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 11 complexity

Metric Results
Complexity 11

View in Codacy

🟢 Coverage 23.91% diff coverage · 0.00% coverage variation

Metric Results
Coverage variation ✅ 0.00% coverage variation (-1.00%)
Diff coverage ✅ 23.91% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (627c375) 94312 28352 30.06%
Head commit (938bc8f) 94348 (+36) 28361 (+9) 30.06% (0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#4088) 46 11 23.91%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@dragonchaser
dragonchaser marked this pull request as ready for review November 23, 2026 13:43
@butonic

butonic commented Nov 23, 2026

Copy link
Copy Markdown
Member

hm, nothing calls hasExternalSharePermission / contextUserHasExternalSharePermission, so all this PR does for admins is add a "Write external share" permission that has no effect. Upstream owncloud/ocis#11931 used it in two places, both of which came with owncloud/ocis#11893 (cross instance sharing) and don't exist here yet:

// Invite, when the recipient is unknown
if s.config.MultiInstance.Enabled && s.hasExternalSharePermission(ctx) {
	user, err = s.identityBackend.AddUser(ctx, objectID, s.config.MultiInstance.InstanceID)
}
// GetUsers, precise lookup by username + instancename
case username != "" && instancename != "" && g.contextUserHasExternalSharePermission(r.Context()):
	users[0], err = g.identityBackend.GetPreciseUser(r.Context(), username, instancename, odataReq)

IMO this should wait for the multi-instance port and then go in with both checks and unit tests for granted / denied. Until then I'd rather not ship the permission.

Some things I'd change regardless:

  • svc.contextUserHasExternalSharePermission in service.go binds a copy of Graph. It only works because svc.permissionsService is assigned a few lines above. Move the call back up and the first request panics on a nil permission service. I'd capture the permission service explicitly, or make the check a plain function that takes it:
    ps := svc.permissionsService
    hasExternal := func(ctx context.Context) bool { return hasExternalSharePermission(ctx, ps) }
  • NewDriveItemPermissionsService keeps growing positional args. The multi-instance port adds the identity backend as well (upstream is at 8). Every new arg is another trailing nil in ~27 test call sites. An options struct (or functional options with defaults) would avoid that churn now and later.
  • The description "allows creating shares to users on other instances" reads like OCM. Admins will assume removing it blocks federated shares, which it doesn't. Maybe: "Allows sharing with users of other instances in a multi-instance deployment. Does not affect OCM federated shares."
  • contextUserHasExternalSharePermission is a copy of contextUserHasFullAccountPerms (including the "mostly copied from canCreateSpace" comment) with a different permission id. A contextUserHasPermission(ctx, id) helper would replace both.
  • The PR description should say which upstream checks are left out and why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type:Maintenance E.g. technical debt, packaging, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants