def setUpClass(cls): cls.params = KeeperParams() read_config_file(cls.params) cls.params.user = cls.params.config['enterprise']['user'] cls.params.password = cls.params.config['enterprise']['password'] api.login(cls.params) TestEnterpriseCommands.wipe_out_data()
def setUpClass(cls): cls.params1 = KeeperParams() config_filename = os.path.join(os.path.dirname(__file__), 'cross-enterprise.json') with open(config_filename, 'r') as f: config = json.load(f) cls.params1.server = config['server'] device_id = base64.urlsafe_b64decode(config['device_id'] + '==') cls.params1.rest_context.device_id = device_id cls.params1.user = config['user'] cls.params1.password = config['password'] cls.params1.config = config api.login(cls.params1) cls.params2 = KeeperParams() cls.params2.server = cls.params1.server cls.params2.rest_context.device_id = cls.params1.rest_context.device_id cls.params2.user = config['enterprise2']['user'] cls.params2.password = config['enterprise2']['password'] api.login(cls.params2)
def setUpClass(cls): cls.params1 = KeeperParams() config_filename = os.path.join(os.path.dirname(__file__), 'cross-enterprise.json') with open(config_filename, 'r') as f: config = json.load(f) cls.params1.server = config['server'] cls.params1.user = config['user'] cls.params1.password = config['password'] cls.params1.device_private_key = config['private_key'] cls.params1.device_token = config['device_token'] cls.params1.clone_code = config['clone_code'] cls.params1.config = config api.login(cls.params1) cls.params2 = KeeperParams() cls.params2.server = cls.params1.server cls.params2.device_private_key = cls.params1.device_private_key cls.params2.device_token = cls.params1.device_token cls.params2.clone_code = cls.params1.clone_code cls.params2.user = config['enterprise2']['user'] cls.params2.password = config['enterprise2']['password'] api.login(cls.params2)
def login(email, password=None, keeper_server='https://keepersecurity.com/api/v2/', config_file='myconfig.json'): if os.path.exists(config_file): params = get_params_from_config(config_file) else: params = KeeperParams() params.config_filename = config_file params.user = email params.password = password if password else '' params.server = keeper_server params.config['server'] = params.server api.login(params) api.sync_down(params) return params
if os.path.isfile(params.config_filename): with open(params.config_filename, 'r') as f: params.config = json.load(f) if 'user' in params.config: params.user = params.config['user'] if 'password' in params.config: params.password = params.config['password'] if 'device_id' in params.config: device_id = base64.urlsafe_b64decode( params.config['device_id'] + '==') params.rest_context.device_id = device_id my_params = KeeperParams() read_config_file(my_params) while not my_params.user: my_params.user = getpass.getpass(prompt='User(Email): ', stream=None) while not my_params.password: my_params.password = getpass.getpass(prompt='Master Password: '******'Record UID: ', stream=None) api.sync_down(my_params) # See record.py for available fields # or call display.formatted_records(record) to show all record details
self.errors.append(message) def clear_errors(self): self.errors.clear() def has_error(self): return len(self.errors) > 0 # Configure logging slh = ScriptLogHandler() slh.setLevel(logging.WARNING) logging.root.addHandler(slh) # Create parameters my_params = KeeperParams() my_params.user = '' # Keeper account name. 'config.json' file, 'user' property my_params.password = '' # Keeper account password. my_params.device_token = '' # Device Token. 'config.json' file, 'device_token' property my_params.device_private_key = '' # Device Key. 'config.json' file, 'private_key' property # Login to Keeper api.login(my_params) # Load the Enterprise configuration state api.query_enterprise(my_params) # Create team/user mapping if 'users' in my_params.enterprise and 'team_users' in my_params.enterprise: # params.enterprise['users'] is a list of all users in enterprise # params.enterprise['team_users'] is a list of team <-> user pairs
def setUpClass(cls): cls.params = KeeperParams() read_config_file(cls.params, 'enterprise.json') api.login(cls.params) TestEnterpriseCommands.wipe_out_data()
def setUpClass(cls): cls.params = KeeperParams() read_config_file(cls.params) api.login(cls.params) TestConnectedCommands.wipe_out_data()
# |_|\_\___\___| .__/\___|_| # |_| # # Keeper Commander # Copyright 2018 Keeper Security Inc. # Contact: [email protected] # # Example showing how to add a new or existing record # to an existing shared folder. # from keepercommander.params import KeeperParams from keepercommander import api from keepercommander.commands.record import RecordAddCommand params = KeeperParams() # Inputs - hard coded for demo purposes params.user = '******' params.password = '******' shared_folder_uid = 'your_shared_folder_uid' # Login and sync api.sync_down(params) command = RecordAddCommand() record_uid = command.execute(params, title='Test Record', login='******', url='https://google.com', folder=shared_folder_uid,
def get_params(config_filename): params = KeeperParams() params.config_filename = 'config.json' if config_filename: params.config_filename = config_filename try: with open(params.config_filename) as config_file: try: params.config = json.load(config_file) if 'user' in params.config: params.user = params.config['user'] if 'server' in params.config: params.server = params.config['server'] if 'password' in params.config: params.password = params.config['password'] if 'challenge' in params.config: try: import keepercommander.yubikey.yubikey challenge = params.config['challenge'] params.password = keepercommander.yubikey.yubikey.get_response(challenge) except Exception as e: print(e) sys.exit(1) if 'timedelay' in params.config: params.timedelay = params.config['timedelay'] if 'mfa_token' in params.config: params.mfa_token = params.config['mfa_token'] if 'mfa_type' in params.config: params.mfa_type = params.config['mfa_type'] if 'commands' in params.config: params.commands = params.config['commands'] if 'plugins' in params.config: params.plugins = params.config['plugins'] if 'debug' in params.config: params.debug = params.config['debug'] except: print('Error: Unable to parse JSON file ' + params.config_filename) raise except IOError: if config_filename: print('Error: Unable to open config file ' + config_filename) pass if not params.server: params.server = 'https://keeperapp.com/v2/' return params
def get_params_from_config(config_filename): params = KeeperParams() params.config_filename = 'config.json' if config_filename: params.config_filename = config_filename try: with open(params.config_filename) as config_file: try: params.config = json.load(config_file) if 'user' in params.config: params.user = params.config['user'] if 'server' in params.config: params.server = params.config['server'] if 'password' in params.config: params.password = params.config['password'] if 'challenge' in params.config: try: import keepercommander.yubikey.yubikey challenge = params.config['challenge'] params.password = keepercommander.yubikey.yubikey.get_response( challenge) except Exception as e: print(e) sys.exit(1) if 'timedelay' in params.config: params.timedelay = params.config['timedelay'] if 'mfa_token' in params.config: params.mfa_token = params.config['mfa_token'] if 'mfa_type' in params.config: params.mfa_type = params.config['mfa_type'] if 'commands' in params.config: params.commands = params.config['commands'] if 'plugins' in params.config: params.plugins = params.config['plugins'] if 'debug' in params.config: params.debug = params.config['debug'] except: print('Error: Unable to parse JSON file ' + params.config_filename) raise except IOError: if config_filename: print('Error: Unable to open config file ' + config_filename) pass if not params.server: params.server = 'https://keepersecurity.com/api/v2/' return params