Commit a538d2fa authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Fixed share_with for archive/raw queries/downloads. #314

parent a7554083
Pipeline #78637 passed with stages
in 20 minutes and 35 seconds
...@@ -167,6 +167,8 @@ class ArchiveDownloadResource(Resource): ...@@ -167,6 +167,8 @@ class ArchiveDownloadResource(Resource):
common.logger.error('upload files do not exist', upload_id=upload_id) common.logger.error('upload files do not exist', upload_id=upload_id)
continue continue
upload_files._is_authorized = create_authorization_predicate(
upload_id=upload_id, calc_id=calc_id)
with upload_files.read_archive(calc_id) as archive: with upload_files.read_archive(calc_id) as archive:
f = BytesIO(orjson.dumps( f = BytesIO(orjson.dumps(
archive[calc_id].to_dict(), archive[calc_id].to_dict(),
...@@ -311,6 +313,8 @@ class ArchiveQueryResource(Resource): ...@@ -311,6 +313,8 @@ class ArchiveQueryResource(Resource):
if with_embargo: if with_embargo:
access = 'restricted' access = 'restricted'
upload_files._is_authorized = create_authorization_predicate(
upload_id=upload_id, calc_id=calc_id)
else: else:
access = 'public' access = 'public'
...@@ -330,8 +334,8 @@ class ArchiveQueryResource(Resource): ...@@ -330,8 +334,8 @@ class ArchiveQueryResource(Resource):
# We simply skip this entry # We simply skip this entry
pass pass
except Restricted: except Restricted:
# TODO in reality this should not happen # this should not happen
pass common.logger.error('supposedly unreachable code', upload_id=upload_id, calc_id=calc_id)
except Exception as e: except Exception as e:
if raise_errors: if raise_errors:
raise e raise e
......
...@@ -320,7 +320,6 @@ def create_authorization_predicate(upload_id, calc_id=None): ...@@ -320,7 +320,6 @@ def create_authorization_predicate(upload_id, calc_id=None):
if g.user.user_id == upload.user_id: if g.user.user_id == upload.user_id:
return True return True
# TODO I doubt if shared_with is actually working
if calc_id is not None: if calc_id is not None:
try: try:
calc = processing.Calc.get(calc_id) calc = processing.Calc.get(calc_id)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment