def save_connection_password(arguments): """ Generate digest for the connection password (for the current host) and save it. """ if len(arguments) < 1: cli_error('The host UUID and (optionally) the password ' 'should be passed as the arguments!') else: my_uuid = try_parse_uuid(arguments.popleft()) password = _get_password_from_arguments(arguments, repeat=True) proceed_with_host_uuid_cli(my_uuid) with db.RDB() as rdbw: my_host = Queries.Inhabitants.get_host_by_uuid(my_uuid, rdbw) my_username = my_host.username _digest = \ crypto.generate_digest(my_username, password, common_settings.HTTP_AUTH_REALM_NODE) Queries.Inhabitants.update_user_digest(my_username, _digest, rdbw) print(u'For host {host} (with user {user}), ' u'saving the following digest: {digest}'.format(host=my_uuid, user=my_username, digest=_digest))
def init_host(arguments): """ Initialize the host and run the first ever authentication. """ if len(arguments) < 2: cli_error('You must pass at least 2 arguments to this command.') else: my_listen_port_str, username = (arguments.popleft(), str(arguments.popleft())) password = _get_password_from_arguments(arguments) try: my_listen_port = int(my_listen_port_str) except ValueError: cli_error('Not an integer port number: %r', my_listen_port_str) if username is not None and password is not None: digest = \ crypto.generate_digest(username, password, common_settings.HTTP_AUTH_REALM_NODE) else: digest = None edition = uhost_settings.detect_edition() UHostApp.init_host(edition=edition, chunk_storage_cb=__create_chunk_storage, proceed_func=proceed_with_host_uuid_cli, on_end_func=__cli_handle_init_finish, username=username, digest=digest, my_listen_port=my_listen_port)
def save_connection_password(arguments): """ Generate digest for the connection password (for the current host) and save it. """ if len(arguments) < 1: cli_error('The host UUID and (optionally) the password ' 'should be passed as the arguments!') else: my_uuid = try_parse_uuid(arguments.popleft()) password = _get_password_from_arguments(arguments, repeat=True) proceed_with_host_uuid_cli(my_uuid) with db.RDB() as rdbw: my_host = Queries.Inhabitants.get_host_by_uuid(my_uuid, rdbw) my_username = my_host.username _digest = \ crypto.generate_digest(my_username, password, common_settings.HTTP_AUTH_REALM_NODE) Queries.Inhabitants.update_user_digest(my_username, _digest, rdbw) print(u'For host {host} (with user {user}), ' u'saving the following digest: {digest}' .format(host=my_uuid, user=my_username, digest=_digest))
def generate_digest(arguments): """ Generate digest for the username. """ if len(arguments) < 1: cli_error('The user name and (optionally) the password should be ' 'passed as the arguments!') else: username = arguments.popleft() password = _get_password_from_arguments(arguments) print('For username {0}, the digest is {1}'.format( username, crypto.generate_digest(str(username), password, common_settings.HTTP_AUTH_REALM_NODE)))
def generate_digest(arguments): """ Generate digest for the username. """ if len(arguments) < 1: cli_error('The user name and (optionally) the password should be ' 'passed as the arguments!') else: username = arguments.popleft() password = _get_password_from_arguments(arguments) print('For username {0}, the digest is {1}' .format(username, crypto.generate_digest( str(username), password, common_settings.HTTP_AUTH_REALM_NODE)))