MCPcopy Create free account
hub / github.com/Keeper-Security/Commander / accept_account_transfer_consent

Function accept_account_transfer_consent

keepercommander/api.py:83–122  ·  view source on GitHub ↗
(params)

Source from the content-addressed store, hash-verified

81
82
83def accept_account_transfer_consent(params): # type: (KeeperParams) -> bool
84 share_account_by = params.get_share_account_timestamp()
85 print(constants.ACCOUNT_TRANSFER_MSG.format(share_account_by.strftime('%a, %b %d %Y')))
86
87 expired = datetime.today() > share_account_by
88 input_options = 'Accept/L(ogout)' if expired else 'Accept/L(ater)'
89 answer = input('Do you accept Account Transfer policy? {}: '.format(input_options))
90 answer = answer.lower()
91 if answer.lower() == 'accept':
92 ok = True
93 requests = []
94 if 'share_account_to' in params.settings:
95 for role in params.settings['share_account_to']:
96 request = {
97 'command': 'share_account',
98 'to_role_id': role['role_id'],
99 }
100 if not params.forbid_rsa and 'public_key' in role:
101 encoded_public = utils.base64_url_decode(role['public_key'])
102 public_key = crypto.load_rsa_public_key(encoded_public)
103 transfer_key = crypto.encrypt_rsa(params.data_key, public_key)
104 request['transfer_key'] = utils.base64_url_encode(transfer_key)
105
106 requests.append(request)
107 responses = execute_batch(params, requests)
108 if isinstance(responses, list):
109 for response in responses:
110 if response['result_code'] != 'success':
111 logging.warning('Account Transfer policy acceptance error: %s',
112 response.get('message') or response['result_code'])
113 ok = False
114 if ok and params.forbid_rsa and params.enterprise_ec_key:
115 try:
116 share_data_key_with_enterprise(params)
117 except Exception as e:
118 logging.warning('Account Transfer policy acceptance error: %s', e)
119 ok = False
120 return ok
121 else:
122 return False
123
124
125def share_data_key_with_enterprise(params): # type: (KeeperParams) -> None

Callers

nothing calls this directly

Calls 6

execute_batchFunction · 0.85
formatMethod · 0.80
warningMethod · 0.80
getMethod · 0.80

Tested by

no test coverage detected