annotate libervia/server/restricted_bridge.py @ 1291:6daab90bfb8a

pages (js): added `nunjucks` requirement
author Goffi <goffi@goffi.org>
date Fri, 19 Jun 2020 16:47:51 +0200
parents 1f26d8c2afc1
children 0930b06f022f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1287
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python3
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
2
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
3 # Libervia: a SàT frontend
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # Copyright (C) 2009-2020 Jérôme Poisson (goffi@goffi.org)
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
5
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
6 # This program is free software: you can redistribute it and/or modify
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # it under the terms of the GNU Affero General Public License as published by
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # the Free Software Foundation, either version 3 of the License, or
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # (at your option) any later version.
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
10
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
11 # This program is distributed in the hope that it will be useful,
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # GNU Affero General Public License for more details.
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
15
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
16 # You should have received a copy of the GNU Affero General Public License
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
18
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
19 from libervia.server.constants import Const as C
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
20
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
21
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 class RestrictedBridge:
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
23 """Bridge with limited access, which can be used in browser
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
24
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
25 Only a few method are implemented, with potentially dangerous argument controlled.
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
26 Security limit is used
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
27 """
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
28
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
29 def __init__(self, host):
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
30 self.host = host
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
31 self.security_limit = C.SECURITY_LIMIT
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
32
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
33 async def fileHTTPUploadGetSlot(
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
34 self, filename, size, content_type, upload_jid, profile):
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
35 return await self.host.bridgeCall(
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
36 "fileHTTPUploadGetSlot", filename, size, content_type,
1f26d8c2afc1 server: restricted_bridge first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 upload_jid, profile)