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

[spaces 2/2] /dav/spaces endpoint #1803

Merged
merged 14 commits into from
Aug 12, 2021
Merged

[spaces 2/2] /dav/spaces endpoint #1803

merged 14 commits into from
Aug 12, 2021

Conversation

butonic
Copy link
Contributor

@butonic butonic commented Jun 18, 2021

I split #1776 into two PRs:

  1. the initial list spaces implementation
  2. the new /dav/spaces endpoint to access storage with relative references

This is the second PR about spaces. It

  • adds a new ocdav handler for /dav/spaces
  • refactors the ocdav handlers to make them reusable for /dav/spaces and /(web)dav requests
  • adds logic to the gateway to forward relative References to the storage providers
  • adds logic to the storageprovider to only prefix mountpoints for absolute References
  • changes the CreateDir signature in the storage.FS interface to allow creating folders with relative References
  • adds a new datatx spaces implementation
  • update storage drivers to distinguish relative vs absolute References and at least handle absolute references for path and id only based access

Examples

When using ocis clients would use the /graph/v1.0/me/drives endpoint to ge a listing of the spaces/driles a user has access to (try using the /graph-explorer that comes with ocis):

{
    "value": [
        {
            "driveType": "personal",
            "id": "1284d238-aa92-42ce-bdc4-0b0000009157!1d2e72be-da48-42c5-b7b5-49eb8e5fa482",
            "lastModifiedDateTime": "2021-07-20T18:18:06.240248736Z",
            "name": "root",
            "owner": {
                "user": {
                    "id": "f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c"
                }
            },
            "root": {
                "id": "1284d238-aa92-42ce-bdc4-0b0000009157!1d2e72be-da48-42c5-b7b5-49eb8e5fa482",
                "webDavUrl": "https://localhost:9200/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157!1d2e72be-da48-42c5-b7b5-49eb8e5fa482"
            }
        },
        {
            "driveType": "share",
            "id": "1284d238-aa92-42ce-bdc4-0b0000009157!1d89c2f8-a800-4e3c-997d-d969f29de142",
            "lastModifiedDateTime": "2021-07-21T08:40:41.887071968Z",
            "name": "from einstein",
            "owner": {
                "user": {
                    "id": "4c510ada-c86b-4815-8820-42cdf82c3d51"
                }
            },
            "root": {
                "id": "1284d238-aa92-42ce-bdc4-0b0000009157!1d89c2f8-a800-4e3c-997d-d969f29de142",
                "webDavUrl": "https://localhost:9200/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157!1d89c2f8-a800-4e3c-997d-d969f29de142"
            }
        }
    ]
}

The webDavUrl properties can then be used to browse the space using normal webdav:

curl -X PROPFIND 'https://cloud.ocis.test/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157!1d89c2f8-a800-4e3c-997d-d969f29de142/' -u marie:radioactivity
<?xml version="1.0" encoding="utf-8"?>
<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:oc="http://owncloud.org/ns">
    <d:response>
        <d:href>/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157!1d89c2f8-a800-4e3c-997d-d969f29de142/</d:href>
        <d:propstat>
            <d:prop>
                <oc:id>MTI4NGQyMzgtYWE5Mi00MmNlLWJkYzQtMGIwMDAwMDA5MTU3OjFkODljMmY4LWE4MDAtNGUzYy05OTdkLWQ5NjlmMjlkZTE0Mg==</oc:id>
                <oc:fileid>MTI4NGQyMzgtYWE5Mi00MmNlLWJkYzQtMGIwMDAwMDA5MTU3OjFkODljMmY4LWE4MDAtNGUzYy05OTdkLWQ5NjlmMjlkZTE0Mg==</oc:fileid>
                <d:getetag>&#34;f8d8c4396d8ef37d5eaa0584cb4460ff&#34;</d:getetag>
                <oc:permissions>S</oc:permissions>
                <d:resourcetype>
                    <d:collection/>
                </d:resourcetype>
                <oc:size>345396172</oc:size>
                <d:getlastmodified>Wed, 21 Jul 2021 08:44:38 GMT</d:getlastmodified>
                <oc:favorite>0</oc:favorite>
            </d:prop>
            <d:status>HTTP/1.1 200 OK</d:status>
        </d:propstat>
    </d:response>
    <d:response>
        <d:href>/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157!1d89c2f8-a800-4e3c-997d-d969f29de142/ffmpeg-4.4-full_build/</d:href>
        <d:propstat>
            <d:prop>
                <oc:id>MTI4NGQyMzgtYWE5Mi00MmNlLWJkYzQtMGIwMDAwMDA5MTU3OjAxYzZkOWRkLThkMDgtNGIyNy1hMzZmLTEwMjIwZDdiOThlOA==</oc:id>
                <oc:fileid>MTI4NGQyMzgtYWE5Mi00MmNlLWJkYzQtMGIwMDAwMDA5MTU3OjAxYzZkOWRkLThkMDgtNGIyNy1hMzZmLTEwMjIwZDdiOThlOA==</oc:fileid>
                <d:getetag>&#34;7aadd18a32470de2d5371b7db813987f&#34;</d:getetag>
                <oc:permissions>S</oc:permissions>
                <d:resourcetype>
                    <d:collection/>
                </d:resourcetype>
                <oc:size>345396172</oc:size>
                <d:getlastmodified>Wed, 21 Jul 2021 08:44:38 GMT</d:getlastmodified>
                <oc:favorite>0</oc:favorite>
            </d:prop>
            <d:status>HTTP/1.1 200 OK</d:status>
        </d:propstat>
    </d:response>
</d:multistatus>

Navigating into subfolders happens using relative URLs:

curl -X PROPFIND 'https://cloud.ocis.test/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157!1d89c2f8-a800-4e3c-997d-d969f29de142/ffmpeg-4.4-full_build/bin/' -u marie:radioactivity
<?xml version="1.0" encoding="utf-8"?>
<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:oc="http://owncloud.org/ns">
    <d:response>
        <d:href>/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157!1d89c2f8-a800-4e3c-997d-d969f29de142/ffmpeg-4.4-full_build/bin/</d:href>
        <d:propstat>
            <d:prop>
                <oc:id>MTI4NGQyMzgtYWE5Mi00MmNlLWJkYzQtMGIwMDAwMDA5MTU3OjczNGM4NGQwLWNiYWItNGNhYS05YmQ3LWE1ZWYwYzM1ZTVhNA==</oc:id>
                <oc:fileid>MTI4NGQyMzgtYWE5Mi00MmNlLWJkYzQtMGIwMDAwMDA5MTU3OjczNGM4NGQwLWNiYWItNGNhYS05YmQ3LWE1ZWYwYzM1ZTVhNA==</oc:fileid>
                <d:getetag>&#34;5d7ef09c6250be66843b639ceb156349&#34;</d:getetag>
                <oc:permissions>S</oc:permissions>
                <d:resourcetype>
                    <d:collection/>
                </d:resourcetype>
                <oc:size>337036800</oc:size>
                <d:getlastmodified>Wed, 21 Jul 2021 08:44:38 GMT</d:getlastmodified>
                <oc:favorite>0</oc:favorite>
            </d:prop>
            <d:status>HTTP/1.1 200 OK</d:status>
        </d:propstat>
    </d:response>
    <d:response>
        <d:href>/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157!1d89c2f8-a800-4e3c-997d-d969f29de142/ffmpeg-4.4-full_build/bin/ffmpeg.exe</d:href>
        <d:propstat>
            <d:prop>
                <oc:id>MTI4NGQyMzgtYWE5Mi00MmNlLWJkYzQtMGIwMDAwMDA5MTU3OmZhMjQzODVhLWVhM2UtNDQ3OC1hZTNlLWRlZTY2YjVlODcwMQ==</oc:id>
                <oc:fileid>MTI4NGQyMzgtYWE5Mi00MmNlLWJkYzQtMGIwMDAwMDA5MTU3OmZhMjQzODVhLWVhM2UtNDQ3OC1hZTNlLWRlZTY2YjVlODcwMQ==</oc:fileid>
                <d:getetag>&#34;64259a52e69bcdd8ac8d707c4a234577&#34;</d:getetag>
                <oc:permissions>S</oc:permissions>
                <d:resourcetype></d:resourcetype>
                <d:getcontentlength>112424960</d:getcontentlength>
                <d:getcontenttype>application/x-msdos-program</d:getcontenttype>
                <d:getlastmodified>Fri, 09 Apr 2021 09:16:00 GMT</d:getlastmodified>
                <oc:checksums>
                    <oc:checksum>SHA1:82a787896f0d78a822b14dc3ec40dbf54d6fd049 MD5:544ff37775a43daaf30a7731fec87bfe ADLER32:abcf52ac</oc:checksum>
                </oc:checksums>
                <oc:favorite>0</oc:favorite>
            </d:prop>
            <d:status>HTTP/1.1 200 OK</d:status>
        </d:propstat>
    </d:response>
    <d:response>
        <d:href>/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157!1d89c2f8-a800-4e3c-997d-d969f29de142/ffmpeg-4.4-full_build/bin/ffprobe.exe</d:href>
        <d:propstat>
            <d:prop>
                <oc:id>MTI4NGQyMzgtYWE5Mi00MmNlLWJkYzQtMGIwMDAwMDA5MTU3OjA0MGY5Zjk0LWY3NjUtNDU1Ni1hYTI4LTk2NjdhNzUzNjA5NA==</oc:id>
                <oc:fileid>MTI4NGQyMzgtYWE5Mi00MmNlLWJkYzQtMGIwMDAwMDA5MTU3OjA0MGY5Zjk0LWY3NjUtNDU1Ni1hYTI4LTk2NjdhNzUzNjA5NA==</oc:fileid>
                <d:getetag>&#34;c29362f5c52c4eb212c86714b13d2c16&#34;</d:getetag>
                <oc:permissions>S</oc:permissions>
                <d:resourcetype></d:resourcetype>
                <d:getcontentlength>112323072</d:getcontentlength>
                <d:getcontenttype>application/x-msdos-program</d:getcontenttype>
                <d:getlastmodified>Fri, 09 Apr 2021 09:16:00 GMT</d:getlastmodified>
                <oc:checksums>
                    <oc:checksum>SHA1:44104ae8b9872779566848a08370128ef21ea919 MD5:50877f3904a0ec73bb7fab5771527b2f ADLER32:ff40105e</oc:checksum>
                </oc:checksums>
                <oc:favorite>0</oc:favorite>
            </d:prop>
            <d:status>HTTP/1.1 200 OK</d:status>
        </d:propstat>
    </d:response>
    <d:response>
        <d:href>/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157!1d89c2f8-a800-4e3c-997d-d969f29de142/ffmpeg-4.4-full_build/bin/ffplay.exe</d:href>
        <d:propstat>
            <d:prop>
                <oc:id>MTI4NGQyMzgtYWE5Mi00MmNlLWJkYzQtMGIwMDAwMDA5MTU3OmVlYWMzMjlmLTU1NzYtNGY3Mi1iNzZlLWEwMmQzM2MzYzUzMA==</oc:id>
                <oc:fileid>MTI4NGQyMzgtYWE5Mi00MmNlLWJkYzQtMGIwMDAwMDA5MTU3OmVlYWMzMjlmLTU1NzYtNGY3Mi1iNzZlLWEwMmQzM2MzYzUzMA==</oc:fileid>
                <d:getetag>&#34;2fc643027b8cdaff07f0cd933bb188ff&#34;</d:getetag>
                <oc:permissions>S</oc:permissions>
                <d:resourcetype></d:resourcetype>
                <d:getcontentlength>112288768</d:getcontentlength>
                <d:getcontenttype>application/x-msdos-program</d:getcontenttype>
                <d:getlastmodified>Fri, 09 Apr 2021 09:16:00 GMT</d:getlastmodified>
                <oc:checksums>
                    <oc:checksum>SHA1:415cc678c4f24038f1b36d59e504611c743a940a MD5:19701fd1916d811072bbd72209fa8d72 ADLER32:7d7cd134</oc:checksum>
                </oc:checksums>
                <oc:favorite>0</oc:favorite>
            </d:prop>
            <d:status>HTTP/1.1 200 OK</d:status>
        </d:propstat>
    </d:response>
</d:multistatus>

TODO

@update-docs
Copy link

update-docs bot commented Jun 18, 2021

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.

@lgtm-com
Copy link

lgtm-com bot commented Jun 18, 2021

This pull request introduces 1 alert and fixes 18 when merging a79de7f into 9740eed - view on LGTM.com

new alerts:

  • 1 for Uncontrolled data used in path expression

fixed alerts:

  • 18 for Uncontrolled data used in path expression

@lgtm-com
Copy link

lgtm-com bot commented Jun 18, 2021

This pull request introduces 1 alert and fixes 18 when merging 9eb6ab6 into 9740eed - view on LGTM.com

new alerts:

  • 1 for Uncontrolled data used in path expression

fixed alerts:

  • 18 for Uncontrolled data used in path expression

@lgtm-com
Copy link

lgtm-com bot commented Jun 22, 2021

This pull request introduces 1 alert and fixes 18 when merging a80e3f0 into 567ec47 - view on LGTM.com

new alerts:

  • 1 for Uncontrolled data used in path expression

fixed alerts:

  • 18 for Uncontrolled data used in path expression

@lgtm-com
Copy link

lgtm-com bot commented Jun 23, 2021

This pull request introduces 1 alert and fixes 18 when merging 683a307 into 3a9efaa - view on LGTM.com

new alerts:

  • 1 for Uncontrolled data used in path expression

fixed alerts:

  • 18 for Uncontrolled data used in path expression

@ishank011
Copy link
Contributor

@butonic can you also add sample expected requests and responses in the description once this PR is finished?

@lgtm-com
Copy link

lgtm-com bot commented Jul 8, 2021

This pull request introduces 1 alert and fixes 18 when merging 7058dd1 into 7d21c54 - view on LGTM.com

new alerts:

  • 1 for Uncontrolled data used in path expression

fixed alerts:

  • 18 for Uncontrolled data used in path expression

@lgtm-com
Copy link

lgtm-com bot commented Jul 16, 2021

This pull request introduces 1 alert and fixes 18 when merging 490b0c8 into 7df477f - view on LGTM.com

new alerts:

  • 1 for Uncontrolled data used in path expression

fixed alerts:

  • 18 for Uncontrolled data used in path expression

@C0rby C0rby force-pushed the dav-spaces branch 2 times, most recently from da7108b to ac604bc Compare July 19, 2021 09:37
@lgtm-com
Copy link

lgtm-com bot commented Jul 19, 2021

This pull request introduces 1 alert and fixes 18 when merging ac604bc into 7df477f - view on LGTM.com

new alerts:

  • 1 for Uncontrolled data used in path expression

fixed alerts:

  • 18 for Uncontrolled data used in path expression

@butonic butonic marked this pull request as ready for review July 21, 2021 08:48
@butonic butonic requested a review from labkode as a code owner July 21, 2021 08:48
@butonic butonic requested a review from ishank011 July 21, 2021 08:48
@butonic
Copy link
Contributor Author

butonic commented Jul 26, 2021

@ishank011 I rebased, please review

@lgtm-com
Copy link

lgtm-com bot commented Jul 26, 2021

This pull request fixes 30 alerts when merging b26fa94 into e11a198 - view on LGTM.com

fixed alerts:

  • 30 for Uncontrolled data used in path expression

@ishank011
Copy link
Contributor

@butonic I'm not sure about having the new protocol in datatx since it's not exactly a protocol. I think we can add the relavant checks in tus/simple and frame the requests accordingly. Also, won't spaces support TUS?

@butonic
Copy link
Contributor Author

butonic commented Aug 10, 2021

@ishank011 @labkode rebased and adressed review. Good to merge?

@lgtm-com
Copy link

lgtm-com bot commented Aug 10, 2021

This pull request fixes 30 alerts when merging 29c03b3 into b317948 - view on LGTM.com

fixed alerts:

  • 30 for Uncontrolled data used in path expression

butonic and others added 13 commits August 11, 2021 18:35
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
@lgtm-com
Copy link

lgtm-com bot commented Aug 11, 2021

This pull request fixes 30 alerts when merging c13d9b1 into ec4099d - view on LGTM.com

fixed alerts:

  • 30 for Uncontrolled data used in path expression

Copy link
Contributor

@ishank011 ishank011 left a comment

Choose a reason for hiding this comment

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

@butonic couple of minor comments, we can merge then.

internal/grpc/services/storageprovider/storageprovider.go Outdated Show resolved Hide resolved
internal/http/services/owncloud/ocdav/put.go Show resolved Hide resolved
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
@lgtm-com
Copy link

lgtm-com bot commented Aug 12, 2021

This pull request fixes 30 alerts when merging f0ecf47 into 04a1cf2 - view on LGTM.com

fixed alerts:

  • 30 for Uncontrolled data used in path expression

@ishank011 ishank011 merged commit 756bdce into cs3org:master Aug 12, 2021
@butonic butonic deleted the dav-spaces branch August 12, 2021 10:56
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.

4 participants