Mercurial > libervia-web
annotate libervia/server/restricted_bridge.py @ 1379:4c51f22a813a
server (restricted_bridge): added `psNodeDelete`, `psNodeAffiliationsSet`, `psItemRetract` and `psInvite`
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 20 Feb 2021 13:49:08 +0100 |
parents | a32f3f47e4a8 |
children | fc20818a5266 |
rev | line source |
---|---|
1287 | 1 #!/usr/bin/env python3 |
2 | |
3 # Libervia: a SàT frontend | |
4 # Copyright (C) 2009-2020 Jérôme Poisson (goffi@goffi.org) | |
5 | |
6 # This program is free software: you can redistribute it and/or modify | |
7 # it under the terms of the GNU Affero General Public License as published by | |
8 # the Free Software Foundation, either version 3 of the License, or | |
9 # (at your option) any later version. | |
10 | |
11 # This program is distributed in the hope that it will be useful, | |
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 # GNU Affero General Public License for more details. | |
15 | |
16 # You should have received a copy of the GNU Affero General Public License | |
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | |
19 from libervia.server.constants import Const as C | |
1350
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
20 from sat.tools.common import data_format |
1287 | 21 |
22 | |
23 class RestrictedBridge: | |
24 """Bridge with limited access, which can be used in browser | |
25 | |
26 Only a few method are implemented, with potentially dangerous argument controlled. | |
27 Security limit is used | |
28 """ | |
29 | |
30 def __init__(self, host): | |
31 self.host = host | |
32 self.security_limit = C.SECURITY_LIMIT | |
33 | |
1329
ed28ad7d484c
browser (cache): new `cache` module to handle cache of roster and identities:
Goffi <goffi@goffi.org>
parents:
1315
diff
changeset
|
34 async def getContacts(self, profile): |
ed28ad7d484c
browser (cache): new `cache` module to handle cache of roster and identities:
Goffi <goffi@goffi.org>
parents:
1315
diff
changeset
|
35 return await self.host.bridgeCall("getContacts", profile) |
ed28ad7d484c
browser (cache): new `cache` module to handle cache of roster and identities:
Goffi <goffi@goffi.org>
parents:
1315
diff
changeset
|
36 |
ed28ad7d484c
browser (cache): new `cache` module to handle cache of roster and identities:
Goffi <goffi@goffi.org>
parents:
1315
diff
changeset
|
37 async def identityGet(self, entity, metadata_filter, use_cache, profile): |
ed28ad7d484c
browser (cache): new `cache` module to handle cache of roster and identities:
Goffi <goffi@goffi.org>
parents:
1315
diff
changeset
|
38 return await self.host.bridgeCall( |
ed28ad7d484c
browser (cache): new `cache` module to handle cache of roster and identities:
Goffi <goffi@goffi.org>
parents:
1315
diff
changeset
|
39 "identityGet", entity, metadata_filter, use_cache, profile) |
ed28ad7d484c
browser (cache): new `cache` module to handle cache of roster and identities:
Goffi <goffi@goffi.org>
parents:
1315
diff
changeset
|
40 |
ed28ad7d484c
browser (cache): new `cache` module to handle cache of roster and identities:
Goffi <goffi@goffi.org>
parents:
1315
diff
changeset
|
41 async def identitiesGet(self, entities, metadata_filter, profile): |
ed28ad7d484c
browser (cache): new `cache` module to handle cache of roster and identities:
Goffi <goffi@goffi.org>
parents:
1315
diff
changeset
|
42 return await self.host.bridgeCall( |
ed28ad7d484c
browser (cache): new `cache` module to handle cache of roster and identities:
Goffi <goffi@goffi.org>
parents:
1315
diff
changeset
|
43 "identitiesGet", entities, metadata_filter, profile) |
ed28ad7d484c
browser (cache): new `cache` module to handle cache of roster and identities:
Goffi <goffi@goffi.org>
parents:
1315
diff
changeset
|
44 |
ed28ad7d484c
browser (cache): new `cache` module to handle cache of roster and identities:
Goffi <goffi@goffi.org>
parents:
1315
diff
changeset
|
45 async def identitiesBaseGet(self, profile): |
ed28ad7d484c
browser (cache): new `cache` module to handle cache of roster and identities:
Goffi <goffi@goffi.org>
parents:
1315
diff
changeset
|
46 return await self.host.bridgeCall( |
ed28ad7d484c
browser (cache): new `cache` module to handle cache of roster and identities:
Goffi <goffi@goffi.org>
parents:
1315
diff
changeset
|
47 "identitiesBaseGet", profile) |
ed28ad7d484c
browser (cache): new `cache` module to handle cache of roster and identities:
Goffi <goffi@goffi.org>
parents:
1315
diff
changeset
|
48 |
1379
4c51f22a813a
server (restricted_bridge): added `psNodeDelete`, `psNodeAffiliationsSet`, `psItemRetract` and `psInvite`
Goffi <goffi@goffi.org>
parents:
1350
diff
changeset
|
49 async def psNodeDelete(self, service_s, node, profile): |
4c51f22a813a
server (restricted_bridge): added `psNodeDelete`, `psNodeAffiliationsSet`, `psItemRetract` and `psInvite`
Goffi <goffi@goffi.org>
parents:
1350
diff
changeset
|
50 return await self.host.bridgeCall( |
4c51f22a813a
server (restricted_bridge): added `psNodeDelete`, `psNodeAffiliationsSet`, `psItemRetract` and `psInvite`
Goffi <goffi@goffi.org>
parents:
1350
diff
changeset
|
51 "psNodeDelete", service_s, node, profile) |
4c51f22a813a
server (restricted_bridge): added `psNodeDelete`, `psNodeAffiliationsSet`, `psItemRetract` and `psInvite`
Goffi <goffi@goffi.org>
parents:
1350
diff
changeset
|
52 |
4c51f22a813a
server (restricted_bridge): added `psNodeDelete`, `psNodeAffiliationsSet`, `psItemRetract` and `psInvite`
Goffi <goffi@goffi.org>
parents:
1350
diff
changeset
|
53 async def psNodeAffiliationsSet(self, service_s, node, affiliations, profile): |
4c51f22a813a
server (restricted_bridge): added `psNodeDelete`, `psNodeAffiliationsSet`, `psItemRetract` and `psInvite`
Goffi <goffi@goffi.org>
parents:
1350
diff
changeset
|
54 return await self.host.bridgeCall( |
4c51f22a813a
server (restricted_bridge): added `psNodeDelete`, `psNodeAffiliationsSet`, `psItemRetract` and `psInvite`
Goffi <goffi@goffi.org>
parents:
1350
diff
changeset
|
55 "psNodeAffiliationsSet", service_s, node, affiliations, profile) |
4c51f22a813a
server (restricted_bridge): added `psNodeDelete`, `psNodeAffiliationsSet`, `psItemRetract` and `psInvite`
Goffi <goffi@goffi.org>
parents:
1350
diff
changeset
|
56 |
4c51f22a813a
server (restricted_bridge): added `psNodeDelete`, `psNodeAffiliationsSet`, `psItemRetract` and `psInvite`
Goffi <goffi@goffi.org>
parents:
1350
diff
changeset
|
57 async def psItemRetract(self, service_s, node, item_id, notify, profile): |
4c51f22a813a
server (restricted_bridge): added `psNodeDelete`, `psNodeAffiliationsSet`, `psItemRetract` and `psInvite`
Goffi <goffi@goffi.org>
parents:
1350
diff
changeset
|
58 return await self.host.bridgeCall( |
4c51f22a813a
server (restricted_bridge): added `psNodeDelete`, `psNodeAffiliationsSet`, `psItemRetract` and `psInvite`
Goffi <goffi@goffi.org>
parents:
1350
diff
changeset
|
59 "psItemRetract", service_s, node, item_id, notify, profile) |
4c51f22a813a
server (restricted_bridge): added `psNodeDelete`, `psNodeAffiliationsSet`, `psItemRetract` and `psInvite`
Goffi <goffi@goffi.org>
parents:
1350
diff
changeset
|
60 |
1287 | 61 async def fileHTTPUploadGetSlot( |
62 self, filename, size, content_type, upload_jid, profile): | |
63 return await self.host.bridgeCall( | |
64 "fileHTTPUploadGetSlot", filename, size, content_type, | |
65 upload_jid, profile) | |
1295
0930b06f022f
server (restricted_bridge): added fileSharingDelete and interestRetract
Goffi <goffi@goffi.org>
parents:
1287
diff
changeset
|
66 |
0930b06f022f
server (restricted_bridge): added fileSharingDelete and interestRetract
Goffi <goffi@goffi.org>
parents:
1287
diff
changeset
|
67 async def fileSharingDelete( |
0930b06f022f
server (restricted_bridge): added fileSharingDelete and interestRetract
Goffi <goffi@goffi.org>
parents:
1287
diff
changeset
|
68 self, service_jid, path, namespace, profile): |
0930b06f022f
server (restricted_bridge): added fileSharingDelete and interestRetract
Goffi <goffi@goffi.org>
parents:
1287
diff
changeset
|
69 return await self.host.bridgeCall( |
0930b06f022f
server (restricted_bridge): added fileSharingDelete and interestRetract
Goffi <goffi@goffi.org>
parents:
1287
diff
changeset
|
70 "fileSharingDelete", service_jid, path, namespace, profile) |
0930b06f022f
server (restricted_bridge): added fileSharingDelete and interestRetract
Goffi <goffi@goffi.org>
parents:
1287
diff
changeset
|
71 |
1350
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
72 async def interestsRegisterFileSharing( |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
73 self, service, repos_type, namespace, path, name, extra_s, profile |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
74 ): |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
75 if extra_s: |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
76 # we only allow "thumb_url" here |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
77 extra = data_format.deserialise(extra_s) |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
78 if "thumb_url" in extra: |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
79 extra_s = data_format.serialise({"thumb_url": extra["thumb_url"]}) |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
80 else: |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
81 extra_s = "" |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
82 |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
83 return await self.host.bridgeCall( |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
84 "interestsRegisterFileSharing", service, repos_type, namespace, path, name, |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
85 extra_s, profile |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
86 ) |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
87 |
1295
0930b06f022f
server (restricted_bridge): added fileSharingDelete and interestRetract
Goffi <goffi@goffi.org>
parents:
1287
diff
changeset
|
88 async def interestRetract( |
0930b06f022f
server (restricted_bridge): added fileSharingDelete and interestRetract
Goffi <goffi@goffi.org>
parents:
1287
diff
changeset
|
89 self, service_jid, item_id, profile |
0930b06f022f
server (restricted_bridge): added fileSharingDelete and interestRetract
Goffi <goffi@goffi.org>
parents:
1287
diff
changeset
|
90 ): |
0930b06f022f
server (restricted_bridge): added fileSharingDelete and interestRetract
Goffi <goffi@goffi.org>
parents:
1287
diff
changeset
|
91 return await self.host.bridgeCall( |
0930b06f022f
server (restricted_bridge): added fileSharingDelete and interestRetract
Goffi <goffi@goffi.org>
parents:
1287
diff
changeset
|
92 "interestRetract", service_jid, item_id, profile) |
0930b06f022f
server (restricted_bridge): added fileSharingDelete and interestRetract
Goffi <goffi@goffi.org>
parents:
1287
diff
changeset
|
93 |
1379
4c51f22a813a
server (restricted_bridge): added `psNodeDelete`, `psNodeAffiliationsSet`, `psItemRetract` and `psInvite`
Goffi <goffi@goffi.org>
parents:
1350
diff
changeset
|
94 async def psInvite( |
4c51f22a813a
server (restricted_bridge): added `psNodeDelete`, `psNodeAffiliationsSet`, `psItemRetract` and `psInvite`
Goffi <goffi@goffi.org>
parents:
1350
diff
changeset
|
95 self, invitee_jid_s, service_s, node, item_id, name, extra_s, profile |
4c51f22a813a
server (restricted_bridge): added `psNodeDelete`, `psNodeAffiliationsSet`, `psItemRetract` and `psInvite`
Goffi <goffi@goffi.org>
parents:
1350
diff
changeset
|
96 ): |
4c51f22a813a
server (restricted_bridge): added `psNodeDelete`, `psNodeAffiliationsSet`, `psItemRetract` and `psInvite`
Goffi <goffi@goffi.org>
parents:
1350
diff
changeset
|
97 return await self.host.bridgeCall( |
4c51f22a813a
server (restricted_bridge): added `psNodeDelete`, `psNodeAffiliationsSet`, `psItemRetract` and `psInvite`
Goffi <goffi@goffi.org>
parents:
1350
diff
changeset
|
98 "psInvite", invitee_jid_s, service_s, node, item_id, name, extra_s, profile |
4c51f22a813a
server (restricted_bridge): added `psNodeDelete`, `psNodeAffiliationsSet`, `psItemRetract` and `psInvite`
Goffi <goffi@goffi.org>
parents:
1350
diff
changeset
|
99 ) |
4c51f22a813a
server (restricted_bridge): added `psNodeDelete`, `psNodeAffiliationsSet`, `psItemRetract` and `psInvite`
Goffi <goffi@goffi.org>
parents:
1350
diff
changeset
|
100 |
1315
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
101 async def FISInvite( |
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
102 self, invitee_jid_s, service_s, repos_type, namespace, path, name, extra_s, |
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
103 profile |
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
104 ): |
1350
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
105 if extra_s: |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
106 # we only allow "thumb_url" here |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
107 extra = data_format.deserialise(extra_s) |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
108 if "thumb_url" in extra: |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
109 extra_s = data_format.serialise({"thumb_url": extra["thumb_url"]}) |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
110 else: |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
111 extra_s = "" |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
112 |
1315
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
113 return await self.host.bridgeCall( |
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
114 "FISInvite", invitee_jid_s, service_s, repos_type, namespace, path, name, |
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
115 extra_s, profile |
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
116 ) |
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
117 |
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
118 async def FISAffiliationsSet( |
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
119 self, service_s, namespace, path, affiliations, profile |
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
120 ): |
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
121 return await self.host.bridgeCall( |
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
122 "FISAffiliationsSet", service_s, namespace, path, affiliations, profile |
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
123 ) |
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
124 |
1331
fe353fceec38
browser (invitation, photos/album): invitation manager improvments:
Goffi <goffi@goffi.org>
parents:
1329
diff
changeset
|
125 async def invitationSimpleCreate( |
fe353fceec38
browser (invitation, photos/album): invitation manager improvments:
Goffi <goffi@goffi.org>
parents:
1329
diff
changeset
|
126 self, invitee_email, invitee_name, url_template, extra_s, profile |
fe353fceec38
browser (invitation, photos/album): invitation manager improvments:
Goffi <goffi@goffi.org>
parents:
1329
diff
changeset
|
127 ): |
1315
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
128 return await self.host.bridgeCall( |
1331
fe353fceec38
browser (invitation, photos/album): invitation manager improvments:
Goffi <goffi@goffi.org>
parents:
1329
diff
changeset
|
129 "invitationSimpleCreate", invitee_email, invitee_name, url_template, extra_s, |
fe353fceec38
browser (invitation, photos/album): invitation manager improvments:
Goffi <goffi@goffi.org>
parents:
1329
diff
changeset
|
130 profile |
1315
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
131 ) |