1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-25 02:00:06 +00:00

Merge pull request #4896 from haiwen/office-convert-jwt

pyjwt==2.1.*
This commit is contained in:
Daniel Pan 2021-05-11 13:35:07 +08:00 committed by GitHub
commit a6ac0e28b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -14,6 +14,6 @@ djangorestframework==3.11.1
python-dateutil
requests
pillow
pyjwt
pyjwt==2.1.*
pycryptodome
requests_oauthlib

View File

@ -1121,7 +1121,7 @@ if HAS_OFFICE_CONVERTER:
def add_office_convert_task(file_id, doctype, raw_path):
payload = {'exp': int(time.time()) + 300, }
token = jwt.encode(payload, seahub.settings.SECRET_KEY, algorithm='HS256')
headers = {"Authorization": "Token %s" % token.decode()}
headers = {"Authorization": "Token %s" % token}
params = {'file_id': file_id, 'doctype': doctype, 'raw_path': raw_path}
url = urljoin(OFFICE_CONVERTOR_ROOT, '/add-task')
requests.get(url, params, headers=headers)
@ -1130,7 +1130,7 @@ if HAS_OFFICE_CONVERTER:
def query_office_convert_status(file_id, doctype):
payload = {'exp': int(time.time()) + 300, }
token = jwt.encode(payload, seahub.settings.SECRET_KEY, algorithm='HS256')
headers = {"Authorization": "Token %s" % token.decode()}
headers = {"Authorization": "Token %s" % token}
params = {'file_id': file_id, 'doctype': doctype}
url = urljoin(OFFICE_CONVERTOR_ROOT, '/query-status')
d = requests.get(url, params, headers=headers)
@ -1158,7 +1158,7 @@ if HAS_OFFICE_CONVERTER:
url = urljoin(OFFICE_CONVERTOR_ROOT, '/get-converted-page')
payload = {'exp': int(time.time()) + 300, }
token = jwt.encode(payload, seahub.settings.SECRET_KEY, algorithm='HS256')
headers = {"Authorization": "Token %s" % token.decode()}
headers = {"Authorization": "Token %s" % token}
params = {'static_filename': static_filename, 'file_id': file_id}
try:
ret = requests.get(url, params, headers=headers)