comparison libervia/server/restricted_bridge.py @ 1287:1f26d8c2afc1

server: restricted_bridge first draft: bridge with a limited set of methods, where arguments are checked or removed, and security_limit is used. This bridge is used for calls from browser.
author Goffi <goffi@goffi.org>
date Fri, 19 Jun 2020 16:47:51 +0200
parents
children 0930b06f022f
comparison
equal deleted inserted replaced
1286:63328c793a9e 1287:1f26d8c2afc1
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
20
21
22 class RestrictedBridge:
23 """Bridge with limited access, which can be used in browser
24
25 Only a few method are implemented, with potentially dangerous argument controlled.
26 Security limit is used
27 """
28
29 def __init__(self, host):
30 self.host = host
31 self.security_limit = C.SECURITY_LIMIT
32
33 async def fileHTTPUploadGetSlot(
34 self, filename, size, content_type, upload_jid, profile):
35 return await self.host.bridgeCall(
36 "fileHTTPUploadGetSlot", filename, size, content_type,
37 upload_jid, profile)