Ejemplo n.º 1
0
    def get(self):
        showid = self.get_argument('showid')
        shares = self.get_arguments('share')
        passphrase = cryptohelper.recover_passphrase(shares)
        privkey_show = yield get_show_privatekey(showid, passphrase)

        result = {
            'showid': showid,
            'users': [],
        }
        users = yield get_user_keypair_from_showid(showid)
        for user in users:
            user_id = user['id']
            user_privkey_pem = cryptohelper.decrypt_blob(
                privkey_show, user['enc_private_key'])
            cur_result = {
                'id': user_id,
                'publickey': user['public_key'],
            }
            user_privkey = cryptohelper.import_key(user_privkey_pem)
            access_tokens = yield get_user_tokens(user_id)
            for key, value in access_tokens.items():
                if not isinstance(value, bytes):
                    continue
                cur_result[key] = cryptohelper.decrypt_blob(
                    user_privkey, value)
            result['users'].append(cur_result)
        return self.api_response(result)
Ejemplo n.º 2
0
    def get(self):
        showid = self.get_argument('showid')
        shares = self.get_arguments('share')
        passphrase = cryptohelper.recover_passphrase(shares)
        privkey_show = yield get_show_privatekey(showid, passphrase)

        result = {
            'showid': showid,
            'users': [],
        }
        users = yield get_user_keypair_from_showid(showid)
        for user in users:
            user_id = user['id']
            user_privkey_pem = cryptohelper.decrypt_blob(
                privkey_show,
                user['enc_private_key']
            )
            cur_result = {
                'id': user_id,
                'publickey': user['public_key'],
            }
            user_privkey = cryptohelper.import_key(user_privkey_pem)
            access_tokens = yield get_user_tokens(user_id)
            for key, value in access_tokens.items():
                if not isinstance(value, bytes):
                    continue
                cur_result[key] = cryptohelper.decrypt_blob(
                    user_privkey,
                    value
                )
            result['users'].append(cur_result)
        return self.api_response(result)
Ejemplo n.º 3
0
 def get(self):
     showid = self.get_argument('showtime_id')
     shares = self.get_arguments('share')
     passphrase = self.get_argument('passphrase', None)
     if not (bool(shares) ^ bool(passphrase)):
         return self.error(
             400,
             'Either shares or passphrase needs to be provided'
         )
     if not passphrase:
         passphrase = cryptohelper.recover_passphrase(shares)
     privkey_show = yield get_show_privatekey(showid, passphrase)
     show_info = yield get_showtime(showid)
     result = {
         'showid': showid,
         'date': show_info['date'],
         'users': [],
     }
     users = yield get_user_keypair_from_showid(showid)
     for user in users:
         user_id = user['id']
         user_blob = yield get_user(user_id)
         user_privkey_pem = cryptohelper.decrypt_blob(
             privkey_show,
             user['enc_private_key']
         )
         meta = dict(showid=showid, **user_blob)
         cur_result = {
             'id': user_id,
             'meta': meta,
             'publickey': user['public_key'],
             'privatekey': user_privkey_pem,
             'services': {},
         }
         user_privkey = cryptohelper.import_key(user_privkey_pem)
         access_tokens = yield get_user_tokens(user_id)
         if access_tokens is not None:
             for key, value in access_tokens.items():
                 if not isinstance(value, bytes):
                     continue
                 cur_result['services'][key] = cryptohelper.decrypt_blob(
                     user_privkey,
                     value
                 )
         else:
             cur_result['services'] = {}
         result['users'].append(cur_result)
     return self.api_response(result)