Mercurial > libervia-web
annotate libervia/server/restricted_bridge.py @ 1375:e943b0c8eec5
pages: cache is skipped if there are query arguments in URL
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 11 Dec 2020 17:35:06 +0100 |
parents | a32f3f47e4a8 |
children | 4c51f22a813a |
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 |
1287 | 49 async def fileHTTPUploadGetSlot( |
50 self, filename, size, content_type, upload_jid, profile): | |
51 return await self.host.bridgeCall( | |
52 "fileHTTPUploadGetSlot", filename, size, content_type, | |
53 upload_jid, profile) | |
1295
0930b06f022f
server (restricted_bridge): added fileSharingDelete and interestRetract
Goffi <goffi@goffi.org>
parents:
1287
diff
changeset
|
54 |
0930b06f022f
server (restricted_bridge): added fileSharingDelete and interestRetract
Goffi <goffi@goffi.org>
parents:
1287
diff
changeset
|
55 async def fileSharingDelete( |
0930b06f022f
server (restricted_bridge): added fileSharingDelete and interestRetract
Goffi <goffi@goffi.org>
parents:
1287
diff
changeset
|
56 self, service_jid, path, namespace, profile): |
0930b06f022f
server (restricted_bridge): added fileSharingDelete and interestRetract
Goffi <goffi@goffi.org>
parents:
1287
diff
changeset
|
57 return await self.host.bridgeCall( |
0930b06f022f
server (restricted_bridge): added fileSharingDelete and interestRetract
Goffi <goffi@goffi.org>
parents:
1287
diff
changeset
|
58 "fileSharingDelete", service_jid, path, namespace, profile) |
0930b06f022f
server (restricted_bridge): added fileSharingDelete and interestRetract
Goffi <goffi@goffi.org>
parents:
1287
diff
changeset
|
59 |
1350
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
60 async def interestsRegisterFileSharing( |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
61 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
|
62 ): |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
63 if extra_s: |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
64 # 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
|
65 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
|
66 if "thumb_url" in extra: |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
67 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
|
68 else: |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
69 extra_s = "" |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
70 |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
71 return await self.host.bridgeCall( |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
72 "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
|
73 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 |
1295
0930b06f022f
server (restricted_bridge): added fileSharingDelete and interestRetract
Goffi <goffi@goffi.org>
parents:
1287
diff
changeset
|
76 async def interestRetract( |
0930b06f022f
server (restricted_bridge): added fileSharingDelete and interestRetract
Goffi <goffi@goffi.org>
parents:
1287
diff
changeset
|
77 self, service_jid, item_id, profile |
0930b06f022f
server (restricted_bridge): added fileSharingDelete and interestRetract
Goffi <goffi@goffi.org>
parents:
1287
diff
changeset
|
78 ): |
0930b06f022f
server (restricted_bridge): added fileSharingDelete and interestRetract
Goffi <goffi@goffi.org>
parents:
1287
diff
changeset
|
79 return await self.host.bridgeCall( |
0930b06f022f
server (restricted_bridge): added fileSharingDelete and interestRetract
Goffi <goffi@goffi.org>
parents:
1287
diff
changeset
|
80 "interestRetract", service_jid, item_id, profile) |
0930b06f022f
server (restricted_bridge): added fileSharingDelete and interestRetract
Goffi <goffi@goffi.org>
parents:
1287
diff
changeset
|
81 |
1315
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
82 async def FISInvite( |
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
83 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
|
84 profile |
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
85 ): |
1350
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
86 if extra_s: |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
87 # 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
|
88 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
|
89 if "thumb_url" in extra: |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
90 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
|
91 else: |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
92 extra_s = "" |
a32f3f47e4a8
server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
Goffi <goffi@goffi.org>
parents:
1331
diff
changeset
|
93 |
1315
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
94 return await self.host.bridgeCall( |
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
95 "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
|
96 extra_s, profile |
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
97 ) |
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
98 |
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
99 async def FISAffiliationsSet( |
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
100 self, service_s, namespace, path, affiliations, profile |
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
101 ): |
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
102 return await self.host.bridgeCall( |
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
103 "FISAffiliationsSet", service_s, namespace, path, affiliations, profile |
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
104 ) |
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
105 |
1331
fe353fceec38
browser (invitation, photos/album): invitation manager improvments:
Goffi <goffi@goffi.org>
parents:
1329
diff
changeset
|
106 async def invitationSimpleCreate( |
fe353fceec38
browser (invitation, photos/album): invitation manager improvments:
Goffi <goffi@goffi.org>
parents:
1329
diff
changeset
|
107 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
|
108 ): |
1315
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
109 return await self.host.bridgeCall( |
1331
fe353fceec38
browser (invitation, photos/album): invitation manager improvments:
Goffi <goffi@goffi.org>
parents:
1329
diff
changeset
|
110 "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
|
111 profile |
1315
991ff12241e0
server (restricted_bridge): added `FISInvite`, `FISAffiliationsSet` and `invitationSimpleCreate`
Goffi <goffi@goffi.org>
parents:
1295
diff
changeset
|
112 ) |