Skip to content

Add support for creating permission invites (shares) to mail addressses - #3440

Merged
rhafer merged 8 commits into
opencloud-eu:mainfrom
rhafer:invite-guest-mail
Sep 17, 2026
Merged

rhafer merged 8 commits into
opencloud-eu:mainfrom
rhafer:invite-guest-mail

Conversation

@rhafer

@rhafer rhafer commented Sep 1, 2026

Copy link
Copy Markdown
Member

This is reviving #2717, rebased and adapted to the changes we did to the reva APIs since then.

There is still some stuff left to do:

  • introduce a config knob for the feature, disabled by default as this feature does not make much sense (apart from testing purposes e.g. for the UI) without the token creating and authentication features implemented
  • switch to using the email property of the DriveRecipient instead of using objectId and @libregraphibre.graph.recipient.type=mail. (As suggested in: Add support for mail grantees #2717 (review))
  • introduce a separate permission in the settings service that is used to check whether the user is authorized to create a mail invite (if we have the above config know, this can happen in a separate PR)
  • bump reva after Add support for mail grantees reva#785 got merged

The httpyac for the original PR is still supposed to work:

###
// @title initiate first upload
// @name upload1
{{
  $global.filename=new Buffer($random.alphabetic(50)+'.txt', 'utf-8').toString('base64')
  console.log("Generating new filename: " + $global.filename);
}}

### get personal drive
# @name personaldrive
GET {{host}}/graph/v1.0/me/drive?$select=id
Authorization: Basic {{username}}:{{password}}

### Upload file
PUT {{host}}/remote.php/dav/spaces/{{personaldrive.id}}/{{$global.filename}}
Authorization: Basic {{username}}:{{password}}
X-OC-Mtime: 1565233093
Content-Type: text/plain

uploaded content

?? status == 201

### Get file id
PROPFIND {{host}}/remote.php/dav/spaces/{{personaldrive.id}}/{{$global.filename}}
Authorization: Basic {{username}}:{{password}}
?? status == 207
{{

    const {select} = require("xpath");
    try{
        $global.fileid = select("//*[local-name(.)='id']/text()", response.parsedBody)[0].nodeValue;
    }catch(err){
        console.error(err);
    }
    console.log("id:", $global.fileid)    ;
}}

### Get viewer role
# @name roles
GET {{host}}/graph/v1beta1/roleManagement/permissions/roleDefinitions
Authorization: Basic {{username}}:{{password}}
?? status == 200


### Invite a single guest using an email address
POST {{host}}/graph/v1beta1/drives/{{personaldrive.id}}/items/{{$global.fileid}}/invite
Authorization: Basic {{username}}:{{password}}
Content-Type: application/json

{
    "recipients": [
        {
            "objectId": "some.guest@example.com",
            "@libre.graph.recipient.type": "mail"
        }
    ],
    "roles": ["{{roles[0].id}}"]
}


### List existing shares
# @name listshares
GET {{host}}/graph/v1beta1/drives/{{personaldrive.id}}/items/{{$global.fileid}}/permissions
Authorization: Basic {{username}}:{{password}}
?? status == 200
{{
    const shares = response.parsedBody.value;
    $global.shareId = shares[0].id;
}}

### Update permission role
PATCH {{host}}/graph/v1beta1/drives/{{personaldrive.id}}/items/{{$global.fileid}}/permissions/{{$global.shareId}}
Authorization: Basic {{username}}:{{password}}
Content-Type: application/json

{
    "roles": ["{{roles[0].id}}"]
}
?? status == 200

@codacy-production

codacy-production Bot commented Sep 1, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity

Metric Results
Complexity 0

View in Codacy

🟢 Coverage 55.48% diff coverage

Metric Results
Coverage variation Report missing for 071d8591
Diff coverage 55.48% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (071d859) Report Missing Report Missing Report Missing
Head commit (8f1fdf7) 88741 21470 24.19%

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 (#3440) 146 81 55.48%

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%

1 Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

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.

@rhafer rhafer left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maki5 This need yet another rebase :/

Comment thread services/graph/pkg/service/v0/api_driveitem_permissions.go Outdated
Comment thread services/settings/pkg/store/defaults/permissions.go Outdated
@rhafer
rhafer marked this pull request as ready for review September 15, 2026 14:01
@maki5

maki5 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

@rhafer reva PR with permissions check should be merged first, then I will bump reva version and will do another rebase
opencloud-eu/reva#799

@rhafer

rhafer commented Sep 16, 2026

Copy link
Copy Markdown
Member Author

@rhafer reva PR with permissions check should be merged first, then I will bump reva version and will do another rebase opencloud-eu/reva#799

@maki5 Let's please try to get this one merged first. The reva change is pretty much independent and as the feature is disabled by default we can add the permission check as a follow up. To keeps this small and make the review easier I'd suggest the following:

@rhafer rhafer left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few, minor remarks. Good idea to enhance existing recipient validator!

Comment thread services/graph/pkg/service/v0/api_driveitem_permissions.go Outdated
Comment thread services/graph/pkg/service/v0/api_driveitem_permissions.go Outdated
Comment thread services/graph/pkg/service/v0/api_driveitem_permissions_test.go Outdated
Comment thread services/graph/pkg/service/v0/api_driveitem_permissions_test.go Outdated
Comment thread services/graph/pkg/validate/libregraph.go

@aduffeck aduffeck left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm besides the one nitpick

Comment thread services/graph/pkg/service/v0/utils.go Outdated
Comment on lines +127 to +132
lgIdentity := libregraph.Identity{
Id: libregraph.PtrString(cs3UserID.GetOpaqueId()),
LibreGraphUserType: libregraph.PtrString(identity.UserTypeGuest),
}
lgIdentity.SetDisplayName(cs3UserID.GetOpaqueId())
lgIdentity.SetLibreGraphUserType(identity.UserTypeGuest)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
lgIdentity := libregraph.Identity{
Id: libregraph.PtrString(cs3UserID.GetOpaqueId()),
LibreGraphUserType: libregraph.PtrString(identity.UserTypeGuest),
}
lgIdentity.SetDisplayName(cs3UserID.GetOpaqueId())
lgIdentity.SetLibreGraphUserType(identity.UserTypeGuest)
lgIdentity := libregraph.Identity{
Id: libregraph.PtrString(cs3UserID.GetOpaqueId()),
DisplayName: cs3UserID.GetOpaqueId(),
LibreGraphUserType: libregraph.PtrString(identity.UserTypeGuest),
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied in separate commit

@rhafer
rhafer merged commit e0bfca4 into opencloud-eu:main Sep 17, 2026
65 of 66 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants