How to use the keepercommander.params.KeeperParams function in keepercommander

To help you get started, weā€™ve selected a few keepercommander examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Keeper-Security / Commander / unit-tests / data_vault.py View on Github external
def get_user_params():
    p = params.KeeperParams(server='https://test.keepersecurity.com/', device_id=_DEVICE_ID)
    p.config['device_id'] = base64.urlsafe_b64encode(_DEVICE_ID).decode('utf-8').rstrip('=')
    p.user = _USER_NAME
    p.password = _USER_PASSWORD
    return p
github Keeper-Security / Commander / tests / test_commands.py View on Github external
def setUpClass(cls):
        cls.params = KeeperParams()
        read_config_file(cls.params)
        api.login(cls.params)
        TestConnectedCommands.wipe_out_data()
github Keeper-Security / Commander / keepercommander / commands / register.py View on Github external
for r in password_rules:
                    m = re.match(r['pattern'], pwd)
                    if r['match']:
                        if m is None:
                            failed_rules.append(r['description'])
                    else:
                        if m is not None:
                            failed_rules.append(r['description'])
                if len(failed_rules) == 0:
                    password = pwd
                else:
                    logging.error(rs['password_rules_intro'])
                    for fr in failed_rules:
                        logging.error(fr)

        new_params = KeeperParams()
        new_params.server = params.server
        data_center = kwargs.get('data_center')
        if data_center:
            parts = list(urlsplit(new_params.server))
            host = parts[1]
            port = ''
            colon_pos = host.rfind(':')
            if colon_pos > 0:
                port = host[colon_pos:]
                host = host[:colon_pos]
            suffix = '.eu' if data_center == 'eu' else '.com'
            if not host.endswith(suffix):
                dot_pos = host.rfind('.')
                if dot_pos > 0:
                    host = host[:dot_pos] + suffix
            parts[1] = host + port
github Keeper-Security / Commander / keepercommander / __main__.py View on Github external
def get_params_from_config(config_filename):
    params = KeeperParams()
    params.config_filename = config_filename or 'config.json'

    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'].lower()

                if 'server' in params.config:
                    params.server = params.config['server']

                if 'password' in params.config:
                    params.password = params.config['password']
github Keeper-Security / Commander / keepercommander / custom / add_record_to_shared_folder.py View on Github external
# |_|\_\___\___| .__/\___|_|
#              |_|
#
# Keeper Commander
# Copyright 2018 Keeper Security Inc.
# Contact: ops@keepersecurity.com
#
# 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 = 'your_keeper_email'
params.password = 'your_keeper_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='someone@company.com', url='https://google.com', folder=shared_folder_uid, generate=True, force=True)
print('Added record to shared folder')
github Keeper-Security / Commander / keepercommander / commands / register.py View on Github external
'client_key': api.encrypt_aes(os.urandom(32), data_key)
        }
        if verification_code:
            rq['verification_code'] = verification_code

        rs = api.run_command(new_params, rq)
        if rs['result'] == 'success':
            logging.info("Created account: %s ", email)

            if kwargs.get('question'):
                if not kwargs.get('answer'):
                    print('...' + 'Security Question: '.rjust(24) + kwargs['question'])
                    kwargs['answer'] = input('...' + 'Security Answer: '.rjust(24))
                if kwargs.get('answer'):
                    try:
                        param1 = KeeperParams()
                        param1.server = new_params.server
                        param1.user = email
                        param1.password = password
                        param1.rest_context.device_id = params.rest_context.device_id
                        api.login(param1)
                        answer = kwargs['answer'].lower().replace(' ', '')
                        rq = {
                            'command': 'set_data_key_backup',
                            'version': 2,
                            'data_key_backup': api.create_encryption_params(answer, backup_salt, iterations, data_key),
                            'security_question': kwargs['question'],
                            'security_answer_salt': base64.urlsafe_b64encode(backup_salt).decode().rstrip('='),
                            'security_answer_iterations': iterations,
                            'security_answer_hash': base64.urlsafe_b64encode(api.derive_key(answer, backup_salt, iterations)).decode().rstrip('=')
                        }
                        api.communicate(param1, rq)
github Keeper-Security / Commander / keepercommander / custom / get_audit_log.py View on Github external
#              |_|
#
# Keeper Commander
# Copyright 2019 Keeper Security Inc.
# Contact: ops@keepersecurity.com
#
# Example showing how to access the raw enterprise event logs
# for some custom processing.
#

import getpass

from keepercommander.params import KeeperParams
from keepercommander import api

my_params = KeeperParams()

while not my_params.user:
    my_params.user = input('User(Email): ')

while not my_params.password:
    my_params.password = getpass.getpass(prompt='Master Password: ', stream=None)

events = []
finished = False
# UNIX epoch time in seconds
last_event_time = 0
logged_ids = set()

print('Downloading ', end='', flush=True)

while not finished:
github Keeper-Security / Commander / keepercommander / custom / create_delete.py View on Github external
# Contact: ops@keepersecurity.com
#
# Example showing how to create a record and upload
# to the server, then deleting the record from the
# server.
#

import getpass
import string
import random

from keepercommander.record import Record
from keepercommander.params import KeeperParams
from keepercommander import display, api

my_params = KeeperParams()

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: ', stream=None)

api.sync_down(my_params)

# Add record 
r = Record()
r.title = 'Test Record'
r.login = 'someone@company.com'

# generate a 32-char random password
r.password = ''.join(random.SystemRandom().choice(string.printable) for _ in range(32))