Skip to content

Commit 6258925

Browse files
committed
Handle public share of encrypted folders
- Create public share template provider - Add view to upload files to encrypted folders - Add new endpoint to update filedrop property of metadata - Allow locking and unlocking folder as anonymous user, but with a share token - Allow getting metadata as anonymous user, but with a share token - Allow uploading filedrop property of metadata as anonymous user, but with a share token - Allow to bypass user agent check by setting the x-e2ee-supported header in requests Signed-off-by: Carl Schwan <carl@carlschwan.eu> Signed-off-by: Louis Chemineau <louis@chmn.me>
1 parent d52490f commit 6258925

37 files changed

+3089
-910
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,6 @@ js/public
9999
css/public
100100

101101
.phpunit.result.cache
102+
103+
104+
js/*

appinfo/routes.php

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
['name' => 'MetaData#getMetaData', 'url' => '/api/v1/meta-data/{id}', 'verb' => 'GET'],
3838
['name' => 'MetaData#updateMetaData', 'url' => '/api/v1/meta-data/{id}', 'verb' => 'PUT'],
3939
['name' => 'MetaData#deleteMetaData', 'url' => '/api/v1/meta-data/{id}', 'verb' => 'DELETE'],
40+
['name' => 'MetaData#addMetadataFileDrop', 'url' => '/api/v1/meta-data/{id}/filedrop', 'verb' => 'PUT'],
4041
['name' => 'Encryption#removeEncryptedFolders', 'url' => '/api/v1/encrypted-files', 'verb' => 'DELETE'],
4142
['name' => 'Encryption#setEncryptionFlag', 'url' => '/api/v1/encrypted/{id}', 'verb' => 'PUT'],
4243
['name' => 'Encryption#removeEncryptionFlag', 'url' => '/api/v1/encrypted/{id}', 'verb' => 'DELETE'],

doc/api.md

+40
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,46 @@ the file with the given file-id
493493

494494
`curl -X PUT https://<user>:<password>@<nextcloud>/ocs/v2.php/apps/end_to_end_encryption/api/v1/meta-data/<file-id> -H "OCS-APIRequest:true"` -d "metaData=<encrypted-meta-data>&e2e-token=<e2e-token-received-during-lock-operation>"
495495

496+
## Update filedrop property of meta-data file
497+
498+
PUT: `<base-url>/meta-data/<file-id>/filedrop`
499+
500+
**Data:**
501+
502+
fileDrop: the filedrop object
503+
e2e-token: token to authenticate that you are the client who currently manipulates the file
504+
505+
**Results:**
506+
507+
200 ok: filedrop successfully updated
508+
509+
404 not found: if the meta-data file doesn't exist or if the user can't access
510+
the file with the given file-id
511+
512+
403 forbidden: if the file was not locked or the client sends the wrong e2e-token
513+
514+
400 bad request: unpredictable internal error
515+
516+
**Result body on success:**
517+
````xml
518+
<?xml version="1.0"?>
519+
<ocs>
520+
<meta>
521+
<status>ok</status>
522+
<statuscode>200</statuscode>
523+
<message>OK</message>
524+
</meta>
525+
<data>
526+
<meta-data>encrypted-meta-data</meta-data>
527+
</data>
528+
</ocs>
529+
````
530+
531+
532+
**Example curl call:**
533+
534+
`curl -X PUT https://<user>:<password>@<nextcloud>/ocs/v2.php/apps/end_to_end_encryption/api/v1/meta-data/<file-id>/filedrop -H "OCS-APIRequest:true"` -d "fileDrop=<filedrop-property>&e2e-token=<e2e-token-received-during-lock-operation>"
535+
496536
## Delete meta-data file
497537

498538
DELETE: `<base-url>/meta-data/<file-id>`

js/end_to_end_encryption-adminSettings.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*!
2+
* Determine if an object is a Buffer
3+
*
4+
* @author Feross Aboukhadijeh <https://feross.org>
5+
* @license MIT
6+
*/
7+
8+
/*!
9+
* The buffer module from node.js, for the browser.
10+
*
11+
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
12+
* @license MIT
13+
*/
14+
15+
/*!
16+
* The buffer module from node.js, for the browser.
17+
*
18+
* @author Feross Aboukhadijeh <https://feross.org>
19+
* @license MIT
20+
*/
21+
22+
/*!
23+
* Vue.js v2.7.14
24+
* (c) 2014-2022 Evan You
25+
* Released under the MIT License.
26+
*/
27+
28+
/*!
29+
* escape-html
30+
* Copyright(c) 2012-2013 TJ Holowaychuk
31+
* Copyright(c) 2015 Andreas Lubbe
32+
* Copyright(c) 2015 Tiancheng "Timothy" Gu
33+
* MIT Licensed
34+
*/
35+
36+
/*!
37+
* focus-trap 7.2.0
38+
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
39+
*/
40+
41+
/*!
42+
* tabbable 6.0.1
43+
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
44+
*/
45+
46+
/*! @license DOMPurify 2.4.4 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.4.4/LICENSE */
47+
48+
/*! For license information please see NcSettingsSection.js.LICENSE.txt */
49+
50+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
51+
52+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */

js/end_to_end_encryption-adminSettings.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/end_to_end_encryption-filedrop.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
/*!
2+
* Copyright (c) 2014, GMO GlobalSign
3+
* Copyright (c) 2015-2022, Peculiar Ventures
4+
* All rights reserved.
5+
*
6+
* Author 2014-2019, Yury Strozhevsky
7+
*
8+
* Redistribution and use in source and binary forms, with or without modification,
9+
* are permitted provided that the following conditions are met:
10+
*
11+
* * Redistributions of source code must retain the above copyright notice, this
12+
* list of conditions and the following disclaimer.
13+
*
14+
* * Redistributions in binary form must reproduce the above copyright notice, this
15+
* list of conditions and the following disclaimer in the documentation and/or
16+
* other materials provided with the distribution.
17+
*
18+
* * Neither the name of the copyright holder nor the names of its
19+
* contributors may be used to endorse or promote products derived from
20+
* this software without specific prior written permission.
21+
*
22+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
26+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29+
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32+
*
33+
*/
34+
35+
/*!
36+
* MIT License
37+
*
38+
* Copyright (c) Peculiar Ventures. All rights reserved.
39+
*
40+
* Permission is hereby granted, free of charge, to any person obtaining a copy
41+
* of this software and associated documentation files (the "Software"), to deal
42+
* in the Software without restriction, including without limitation the rights
43+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
44+
* copies of the Software, and to permit persons to whom the Software is
45+
* furnished to do so, subject to the following conditions:
46+
*
47+
* The above copyright notice and this permission notice shall be included in all
48+
* copies or substantial portions of the Software.
49+
*
50+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
51+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
52+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
53+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
54+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
55+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
56+
* SOFTWARE.
57+
*
58+
*/
59+
60+
/*!
61+
* The buffer module from node.js, for the browser.
62+
*
63+
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
64+
* @license MIT
65+
*/
66+
67+
/*!
68+
* The buffer module from node.js, for the browser.
69+
*
70+
* @author Feross Aboukhadijeh <https://feross.org>
71+
* @license MIT
72+
*/
73+
74+
/*!
75+
* Vue.js v2.7.14
76+
* (c) 2014-2022 Evan You
77+
* Released under the MIT License.
78+
*/
79+
80+
/*!
81+
* escape-html
82+
* Copyright(c) 2012-2013 TJ Holowaychuk
83+
* Copyright(c) 2015 Andreas Lubbe
84+
* Copyright(c) 2015 Tiancheng "Timothy" Gu
85+
* MIT Licensed
86+
*/
87+
88+
/*! *****************************************************************************
89+
Copyright (C) Microsoft. All rights reserved.
90+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
91+
this file except in compliance with the License. You may obtain a copy of the
92+
License at http://www.apache.org/licenses/LICENSE-2.0
93+
94+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
95+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
96+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
97+
MERCHANTABLITY OR NON-INFRINGEMENT.
98+
99+
See the Apache Version 2.0 License for specific language governing permissions
100+
and limitations under the License.
101+
***************************************************************************** */
102+
103+
/*! *****************************************************************************
104+
Copyright (c) Microsoft Corporation.
105+
106+
Permission to use, copy, modify, and/or distribute this software for any
107+
purpose with or without fee is hereby granted.
108+
109+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
110+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
111+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
112+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
113+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
114+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
115+
PERFORMANCE OF THIS SOFTWARE.
116+
***************************************************************************** */
117+
118+
/*! @license DOMPurify 2.4.4 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.4.4/LICENSE */
119+
120+
/*! Hammer.JS - v2.0.7 - 2016-04-22
121+
* http://hammerjs.github.io/
122+
*
123+
* Copyright (c) 2016 Jorik Tangelder;
124+
* Licensed under the MIT license */
125+
126+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
127+
128+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
129+
130+
/**
131+
* @copyright Copyright (c) 2022 Louis Chemineau <louis@chmn.me>
132+
*
133+
* @author Louis Chemineau <louis@chmn.me>
134+
*
135+
* @license AGPL-3.0-or-later
136+
*
137+
* This program is free software: you can redistribute it and/or modify
138+
* it under the terms of the GNU Affero General Public License as
139+
* published by the Free Software Foundation, either version 3 of the
140+
* License, or (at your option) any later version.
141+
*
142+
* This program is distributed in the hope that it will be useful,
143+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
144+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
145+
* GNU Affero General Public License for more details.
146+
*
147+
* You should have received a copy of the GNU Affero General Public License
148+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
149+
*
150+
*/

js/end_to_end_encryption-filedrop.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/end_to_end_encryption-settings.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*!
2+
* The buffer module from node.js, for the browser.
3+
*
4+
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
5+
* @license MIT
6+
*/
7+
8+
/*!
9+
* The buffer module from node.js, for the browser.
10+
*
11+
* @author Feross Aboukhadijeh <https://feross.org>
12+
* @license MIT
13+
*/
14+
15+
/*!
16+
* Vue.js v2.7.14
17+
* (c) 2014-2022 Evan You
18+
* Released under the MIT License.
19+
*/
20+
21+
/*!
22+
* escape-html
23+
* Copyright(c) 2012-2013 TJ Holowaychuk
24+
* Copyright(c) 2015 Andreas Lubbe
25+
* Copyright(c) 2015 Tiancheng "Timothy" Gu
26+
* MIT Licensed
27+
*/
28+
29+
/*!
30+
* focus-trap 7.2.0
31+
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
32+
*/
33+
34+
/*!
35+
* tabbable 6.0.1
36+
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
37+
*/
38+
39+
/*! @license DOMPurify 2.4.4 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.4.4/LICENSE */
40+
41+
/*! For license information please see NcCheckboxRadioSwitch.js.LICENSE.txt */
42+
43+
/*! For license information please see NcModal.js.LICENSE.txt */
44+
45+
/*! For license information please see NcSettingsSection.js.LICENSE.txt */
46+
47+
/*! Hammer.JS - v2.0.7 - 2016-04-22
48+
* http://hammerjs.github.io/
49+
*
50+
* Copyright (c) 2016 Jorik Tangelder;
51+
* Licensed under the MIT license */
52+
53+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
54+
55+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */

js/end_to_end_encryption-settings.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/AppInfo/Application.php

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use OCA\EndToEndEncryption\Capabilities;
2828
use OCA\EndToEndEncryption\Connector\Sabre\LockPlugin;
2929
use OCA\EndToEndEncryption\Connector\Sabre\RedirectRequestPlugin;
30+
use OCA\EndToEndEncryption\E2EEPublicShareTemplateProvider;
3031
use OCA\EndToEndEncryption\EncryptionManager;
3132
use OCA\EndToEndEncryption\IKeyStorage;
3233
use OCA\EndToEndEncryption\IMetaDataStorage;
@@ -68,6 +69,7 @@ public function register(IRegistrationContext $context): void {
6869
$context->registerServiceAlias(IKeyStorage::class, KeyStorage::class);
6970
$context->registerServiceAlias(IMetaDataStorage::class, MetaDataStorage::class);
7071
$context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class);
72+
$context->registerPublicShareTemplateProvider(E2EEPublicShareTemplateProvider::class);
7173
}
7274

7375
/**

0 commit comments

Comments
 (0)