Esempio n. 1
0
def s3_retrieve(key_path: str, study_object_id: str, raw_path:bool=False, number_retries=3) -> bytes:
    """ Takes an S3 file path (key_path), and a study ID.  Takes an optional argument, raw_path,
    which defaults to false.  When set to false the path is prepended to place the file in the
    appropriate study_id folder. """
    if not raw_path:
        key_path = study_object_id + "/" + key_path
    encrypted_data = _do_retrieve(S3_BUCKET, key_path, number_retries=number_retries)['Body'].read()
    return decrypt_server(encrypted_data, study_object_id)
Esempio n. 2
0
def s3_retrieve(key_path,
                study_id,
                raw_path=False,
                number_retries=DEFAULT_S3_RETRIES):
    """ Takes an S3 file path (key_path), and a study ID.  Takes an optional argument, raw_path,
    which defaults to false.  When set to false the path is prepended to place the file in the
    appropriate study_id folder. """
    if not raw_path: key_path = str(study_id) + "/" + key_path
    encrypted_data = _do_retrieve(S3_BUCKET,
                                  key_path,
                                  number_retries=number_retries)
    return encryption.decrypt_server(encrypted_data, study_id)
Esempio n. 3
0
import jinja2
from flask import Flask, render_template, redirect
from raven.contrib.flask import Sentry
from werkzeug.contrib.fixers import ProxyFix

from config import load_django

from api import (participant_administration, admin_api, copy_study_api,
                 data_access_api, data_pipeline_api, mobile_api, survey_api)
from config.settings import SENTRY_ELASTIC_BEANSTALK_DSN, SENTRY_JAVASCRIPT_DSN
from libs.admin_authentication import is_logged_in
from libs.security import set_secret_key
from pages import (admin_pages, mobile_pages, survey_designer,
                   system_admin_pages, data_access_web_form)
from libs import encryption

parser = argparse.ArgumentParser(
    usage='$0 study_id <encrypted-input 1>decrypted-output',
    description='perform master-key decryption')
parser.add_argument('study_id', help='study_id')
parser.add_argument('-key', help='use encryption key', action='store_true')
opt = parser.parse_args()
globals().update(vars(opt))

if key:
    sys.stdout.write(
        encryption.decrypt_server_by_key(sys.stdin.read(), study_id))
else:
    sys.stdout.write(encryption.decrypt_server(sys.stdin.read(), study_id))