Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): sharing NG links #7743

Merged
merged 13 commits into from
Nov 28, 2023
Merged

feat(api): sharing NG links #7743

merged 13 commits into from
Nov 28, 2023

Conversation

micbar
Copy link
Contributor

@micbar micbar commented Nov 16, 2023

This adds the implementation for the new libregraph create link endpoint. We also added the needed LibreGraph to CS3 conversions for both directions.

Description

Currently out of Scope

  • Password Policy on the reva side
  • Custom error codes
  • Edit and Delete link
  • SetPassword endpoint

Examples

We have the following link Types defined:

Type value Description
internal Creates an internal link.
view Creates a read-only link to the item.
edit Creates an read-write link to the item.
blocksDownload Creates a read-only link that blocks download to the item. Could be SecureView in the future. Not implemented yet.
createOnly Creates an upload-only link to the item AKA Secret File Drop. This is only available on folders.
upload Link that allows upload and listing. This is only available on folders.

Create an internal link

curl -L 'https://localhost:9200/graph/v1beta1/drives/storage-users-1%24some-admin-user-id-0000-000000000000/items/storage-users-1$some-admin-user-id-0000-000000000000!80794c68-471b-4262-9390-ea1897d0615f/createLink' \
-H 'Content-Type: application/json' \
-H 'Authorization: Basic YWRtaW46YWRtaW4=' \
--data-raw '{
    "type": "internal",
    "displayName" : "Internal Link",
    "@libre.graph.quickLink": false
}'

Response

It returns a single libregraph permission object.

[
    {
        "id": "bQTPAtcLHJaMWgC",
        "link": {
            "@libre.graph.displayName": "Internal Link",
            "@libre.graph.quickLink": false,
            "preventsDownload": false,
            "type": "internal",
            "webUrl": "https://localhost:9200/s/HEqCVsRGYyqFAOb"
        }
    }
]

Create an "edit" link with password and expiration date and set it as "quicklink"

curl -L 'https://localhost:9200/graph/v1beta1/drives/storage-users-1%24some-admin-user-id-0000-000000000000/items/storage-users-1$some-admin-user-id-0000-000000000000!80794c68-471b-4262-9390-ea1897d0615f/createLink' \
-H 'Content-Type: application/json' \
-H 'Authorization: Basic YWRtaW46YWRtaW4=' \
--data-raw '{
    "type": "edit",
    "displayName" : "Edit Link 2",
    "@libre.graph.quickLink": true,
    "expirationDateTime": "2023-12-01T14:00:00.000Z",
    "password": "test"
}'

Response

[
    {
        "expirationDateTime": "2023-12-01T15:00:00+01:00",
        "id": "xEihvNfwyFYBSvj",
        "link": {
            "@libre.graph.displayName": "Edit Link 2",
            "@libre.graph.quickLink": true,
            "preventsDownload": false,
            "type": "edit",
            "webUrl": "https://localhost:9200/s/rkxqsKVVOnxAiiq"
        }
    }
]

List "SharedByMe"

curl -L 'https://localhost:9200/graph/v1beta1/me/drive/sharedByMe/' \
-H 'Authorization: Basic YWRtaW46YWRtaW4='

Response

It now lists

  • group shares
  • user shares
  • public links
{
    "value": [
        {
            "eTag": "\"e0196954e810a4ba2bcac3cd096a9056\"",
            "file": {
                "mimeType": "text/plain"
            },
            "id": "storage-users-1$some-admin-user-id-0000-000000000000!9cce03e2-e5f9-4e4d-8cb9-dede0de5864a",
            "lastModifiedDateTime": "2023-11-07T23:47:34.691995+01:00",
            "name": "New file.txt",
            "parentReference": {
                "driveId": "storage-users-1$some-admin-user-id-0000-000000000000",
                "driveType": "personal",
                "id": "storage-users-1$some-admin-user-id-0000-000000000000!some-admin-user-id-0000-000000000000"
            },
            "permissions": [
                {
                    "grantedToV2": {
                        "user": {
                            "displayName": "Maurice Moss",
                            "id": "058bff95-6708-4fe5-91e4-9ea3d377588b"
                        }
                    },
                    "id": "storage-users-1:some-admin-user-id-0000-000000000000:8fa31297-66e1-462d-b578-7d4609f0f7e6",
                    "roles": [
                        "b1e2218d-eef8-4d4c-b82d-0f1a1b48f3b5"
                    ]
                },
                {
                    "grantedToV2": {
                        "group": {
                            "displayName": "physics-lovers",
                            "id": "262982c1-2362-4afa-bfdf-8cbfef64a06e"
                        }
                    },
                    "id": "storage-users-1:some-admin-user-id-0000-000000000000:cdfe5992-3c24-46fd-9e72-7d99c32f76b3",
                    "roles": [
                        "2d00ce52-1fc2-4dbc-8b95-a73b73395f5a"
                    ]
                },
                {
                    "grantedToV2": {
                        "user": {
                            "displayName": "Marie Skłodowska Curie",
                            "id": "f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c"
                        }
                    },
                    "id": "storage-users-1:some-admin-user-id-0000-000000000000:f0df6dd1-3c72-4af4-890b-081cb3b27cca",
                    "roles": [
                        "b1e2218d-eef8-4d4c-b82d-0f1a1b48f3b5"
                    ]
                },
                {
                    "expirationDateTime": "2023-11-30T23:59:59+01:00",
                    "id": "ffxjKOjUkweFvWI",
                    "link": {
                        "@libre.graph.displayName": "Link",
                        "@libre.graph.quickLink": true,
                        "preventsDownload": false,
                        "type": "edit",
                        "webUrl": "https://localhost:9200/s/PvurbCSDdCCTRau"
                    }
                }
            ],
            "size": 4
        }
    ]
}

Related Issue

Motivation and Context

How Has This Been Tested?

  • Unit tests:
  • Integration Tests:
  • Manual API tests:
  • ...

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

Copy link

update-docs bot commented Nov 16, 2023

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

@micbar micbar force-pushed the sharing-ng-links branch 7 times, most recently from ce2a96a to 2bf00c9 Compare November 21, 2023 21:44
@micbar micbar force-pushed the sharing-ng-links branch 2 times, most recently from 3ebf71f to e7cb21b Compare November 25, 2023 09:36
@micbar micbar marked this pull request as ready for review November 25, 2023 10:11
@micbar micbar requested review from rhafer and fschade November 25, 2023 10:12
@micbar micbar mentioned this pull request Nov 25, 2023
22 tasks
Copy link
Contributor

@fschade fschade left a comment

Choose a reason for hiding this comment

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

a few minor things, but im not able to create a link via the api, see comment. Any reva changes needed?

services/graph/pkg/linktype/linktype.go Show resolved Hide resolved
services/graph/pkg/linktype/linktype.go Show resolved Hide resolved
services/graph/pkg/linktype/linktype.go Show resolved Hide resolved
services/graph/pkg/linktype/linktype.go Show resolved Hide resolved
services/graph/pkg/service/v0/links.go Outdated Show resolved Hide resolved
services/graph/pkg/service/v0/links.go Show resolved Hide resolved
@micbar micbar requested a review from fschade November 27, 2023 14:29
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

88.3% 88.3% Coverage
0.0% 0.0% Duplication

@fschade fschade merged commit eb6ec13 into master Nov 28, 2023
3 checks passed
@delete-merged-branch delete-merged-branch bot deleted the sharing-ng-links branch November 28, 2023 13:58
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.

2 participants