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

Method post_login_processing

keepercommander/loginv3.py:361–431  ·  view source on GitHub ↗

Processing after login Returns True if authentication is successful and False otherwise.

(params: KeeperParams, resp: APIRequest_pb2.LoginResponse, new_password_if_reset_required=None)

Source from the content-addressed store, hash-verified

359
360 @staticmethod
361 def post_login_processing(params: KeeperParams, resp: APIRequest_pb2.LoginResponse, new_password_if_reset_required=None):
362 """Processing after login
363
364 Returns True if authentication is successful and False otherwise.
365 """
366 params.user = resp.primaryUsername
367 params.account_uid_bytes = resp.accountUid
368 session_token = CommonHelperMethods.bytes_to_url_safe_str(resp.encryptedSessionToken)
369 params.session_token = session_token
370
371 login_type_message = LoginV3Flow.get_data_key(params, resp)
372 params.password = None
373 params.clone_code = utils.base64_url_encode(resp.cloneCode)
374 loader.store_config_properties(params)
375
376 LoginV3Flow.populateAccountSummary(params)
377
378 if resp.sessionTokenType != APIRequest_pb2.NO_RESTRICTION:
379 # This is not a happy-path login. Let the user know what's wrong.
380 if resp.sessionTokenType in (APIRequest_pb2.PURCHASE, APIRequest_pb2.RESTRICT):
381 params.session_token = None
382 msg = (
383 'Your Keeper account has expired. Please open the Keeper app to renew or visit the Web '
384 'Vault at https://keepersecurity.com/vault'
385 )
386 raise Exception(msg)
387 elif resp.sessionTokenType == APIRequest_pb2.ACCOUNT_RECOVERY:
388 if new_password_if_reset_required:
389 print('Resetting expired Master Password.\n', file=sys.stderr)
390 LoginV3API.change_master_password(params, new_password_if_reset_required) # always returns False
391 return False
392 elif new_password_if_reset_required is None:
393 print('Your Master Password has expired, you are required to change it before you can login.\n', file=sys.stderr)
394 if LoginV3Flow.change_master_password(params):
395 return False
396 # Return exception if password change fails
397 params.clear_session()
398 raise Exception('Change password failed')
399 elif resp.sessionTokenType == APIRequest_pb2.SHARE_ACCOUNT:
400 print('Account transfer required', file=sys.stderr)
401 accepted = api.accept_account_transfer_consent(params)
402 if accepted:
403 return False
404 else:
405 params.clear_session()
406 raise Exception('Account transfer logout')
407 else:
408 raise Exception('Please log into the web Vault to update your account settings.')
409
410 if params.license and 'account_type' in params.license:
411 if params.license['account_type'] == 2:
412 try:
413 rs = api.communicate_rest(params, None, 'enterprise/get_enterprise_public_key',
414 rs_type=breachwatch_pb2.EnterprisePublicKeyResponse)
415 if rs.enterpriseECCPublicKey:
416 params.enterprise_ec_key = crypto.load_ec_public_key(rs.enterpriseECCPublicKey)
417 if rs.enterprisePublicKey:
418 params.enterprise_rsa_key = crypto.load_rsa_public_key(rs.enterprisePublicKey)

Callers 1

loginMethod · 0.80

Calls 8

BreachWatchClass · 0.85
bytes_to_url_safe_strMethod · 0.80
get_data_keyMethod · 0.80
clear_sessionMethod · 0.80
getMethod · 0.80
debugMethod · 0.45

Tested by

no test coverage detected