diff --git a/CHANGELOG.md b/CHANGELOG.md index f582f68..f1665e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ ml). ## testing [12.0.0-beta] +## [12.1.0-beta] - 2021/07/01 +- [added] JWT on snapshot data + ## [12.0.0-beta] - 2021/05/25 - [added] first version with decoupled configuration diff --git a/ereuse_workbench/erwb.py b/ereuse_workbench/erwb.py index fd47f12..8ed060f 100755 --- a/ereuse_workbench/erwb.py +++ b/ereuse_workbench/erwb.py @@ -1,3 +1,4 @@ +import json import logging.config import subprocess import time @@ -118,8 +119,10 @@ def _submit(url: urlutils.URL, snapshot: Snapshot): t = token or WorkbenchConfig.DH_TOKEN # TODO Get the user's key on the server s = '7KU4ZzsEfe' + snapshot_data = {"type": "Snapshot", + "data": jwt.encode(snapshot.dump(), s, algorithm="HS256", json_encoder=ereuse_utils.JSONEncoder)} r = session.post('{}actions/'.format(url.to_text()), - data=jwt.encode(snapshot.dump(), s, algorithm="HS256", json_encoder=ereuse_utils.JSONEncoder), + data=json.dumps(snapshot_data), headers={ 'Authorization': 'Basic {}'.format(t), 'Content-Type': 'application/json' diff --git a/ereuse_workbench/snapshot.py b/ereuse_workbench/snapshot.py index 526c8cb..df24bc5 100644 --- a/ereuse_workbench/snapshot.py +++ b/ereuse_workbench/snapshot.py @@ -1,3 +1,4 @@ +import json import logging from concurrent.futures import ThreadPoolExecutor from datetime import datetime, timedelta, timezone @@ -217,7 +218,9 @@ def close(self): def encode(self, s): """Convert snapshot to dict object and encoded using PyJWT""" - return jwt.encode(self.dump(), s, algorithm="HS256", json_encoder=self.ENCODER) + snapshot = {"type": "Snapshot", + "data": jwt.encode(self.dump(), s, algorithm="HS256", json_encoder=self.ENCODER)} + return json.dumps(snapshot) class Progress: diff --git a/requirements.txt b/requirements.txt index 29e27a0..3322eba 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,4 +11,4 @@ requests==2.21.0 requests-toolbelt==0.9.1 tqdm==4.32.2 python-decouple==3.3 -pyjwt==2.1.0 \ No newline at end of file +pyjwt>=2.0.0a1 \ No newline at end of file diff --git a/setup.py b/setup.py index 15d3acc..04d9eb6 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ setup( name='ereuse-workbench', - version='12.0.0-beta', + version='12.1.0-beta', url='https://github.com/ereuse/workbench', license='Affero', packages=find_packages(),