Mercurial > libervia-web
diff libervia/web/server/restricted_bridge.py @ 1600:0a4433a343a3
browser (calls): implement WebRTC file sharing:
- Send file through WebRTC when the new `file` button is used during a call.
- Show a confirmation dialog and download file sent by WebRTC.
rel 442
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 06 Apr 2024 13:06:17 +0200 |
parents | 7941444c1671 |
children | 6feac4a25e60 |
line wrap: on
line diff
--- a/libervia/web/server/restricted_bridge.py Tue Mar 05 16:40:25 2024 +0100 +++ b/libervia/web/server/restricted_bridge.py Sat Apr 06 13:06:17 2024 +0200 @@ -16,11 +16,16 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +from libervia.backend.core import exceptions +from libervia.backend.core.log import getLogger from libervia.backend.tools.common import data_format -from libervia.backend.core import exceptions + from libervia.web.server.constants import Const as C +log = getLogger(__name__) + + class RestrictedBridge: """bridge with limited access, which can be used in browser @@ -94,6 +99,32 @@ return await self.host.bridge_call( "external_disco_get", entity, profile) + async def file_jingle_send( + self, + peer_jid: str, + filepath: str, + name: str, + file_desc: str, + extra_s: str, + profile: str + ) -> str: + self.no_service_profile(profile) + if filepath: + # The file sending must be done P2P from the browser directly (the file is + # from end-user machine), and its data must be set in "extra". + # "filepath" must NOT be used in this case, as it would link a local file + # (i.e. from the backend machine), which is an obvious security issue. + log.warning( + f'"filepath" user by {profile!r} in file_jingle_send, this is not ' + "allowed, hack attempt?" + ) + raise exceptions.PermissionError( + "Using a filepath is not allowed." + ) + return await self.host.bridge_call( + "file_jingle_send", peer_jid, "", name, file_desc, extra_s, profile + ) + async def history_get( self, from_jid: str,