diff --git a/src/sakia/data/entities/connection.py b/src/sakia/data/entities/connection.py index adf9699d3d6aca72b9f7c6ac698667d329504606..69924bf95bdeaba1c0996c2a07f2c1b21fed0d4d 100644 --- a/src/sakia/data/entities/connection.py +++ b/src/sakia/data/entities/connection.py @@ -12,12 +12,12 @@ class Connection: """ currency = attr.ib(convert=str) pubkey = attr.ib(convert=str) - salt = attr.ib(convert=str) uid = attr.ib(convert=str, default="", cmp=False, hash=False) scrypt_N = attr.ib(convert=int, default=4096) scrypt_r = attr.ib(convert=int, default=16) scrypt_p = attr.ib(convert=int, default=1) blockstamp = attr.ib(convert=block_uid, default=BlockUID.empty(), cmp=False, hash=False) + salt = attr.ib(convert=str, init=False) password = attr.ib(init=False, convert=str, default="", cmp=False, hash=False) def is_identity(self): diff --git a/src/sakia/data/repositories/connections.py b/src/sakia/data/repositories/connections.py index 42adf935987e0c7e3da5572ebfc2cd6f87d64a37..5a80c97a32461a6b06816a143ac3d8b2d7bc151d 100644 --- a/src/sakia/data/repositories/connections.py +++ b/src/sakia/data/repositories/connections.py @@ -16,9 +16,7 @@ class ConnectionsRepo: Commit a connection to the database :param sakia.data.entities.Connection connection: the connection to commit """ - if connection.is_identity(): - connection = attr.assoc(connection, salt="") - connection_tuple = attr.astuple(connection, filter=attr.filters.exclude(Connection.password)) + connection_tuple = attr.astuple(connection, filter=attr.filters.exclude(Connection.password, Connection.salt)) values = ",".join(['?'] * len(connection_tuple)) self._conn.execute("INSERT INTO connections VALUES ({0})".format(values), connection_tuple) @@ -27,14 +25,11 @@ class ConnectionsRepo: Update an existing connection in the database :param sakia.data.entities.Connection connection: the certification to update """ - if connection.is_identity(): - connection = attr.assoc(connection, salt="") - updated_fields = attr.astuple(connection, filter=attr.filters.exclude(Connection.password, + updated_fields = attr.astuple(connection, filter=attr.filters.exclude(Connection.password, Connection.salt, *ConnectionsRepo._primary_keys)) where_fields = attr.astuple(connection, filter=attr.filters.include(*ConnectionsRepo._primary_keys)) self._conn.execute("""UPDATE connections SET - salt=?, uid=?, scrypt_N=?, scrypt_p=?, diff --git a/src/sakia/data/repositories/meta.sql b/src/sakia/data/repositories/meta.sql index 5cf7c205ebae0c573624737cf30f6b6df9f0d475..3b48df09de695779ea9b52159ce4ec81ab72a6e9 100644 --- a/src/sakia/data/repositories/meta.sql +++ b/src/sakia/data/repositories/meta.sql @@ -110,7 +110,6 @@ CREATE TABLE IF NOT EXISTS nodes( CREATE TABLE IF NOT EXISTS connections( currency VARCHAR(30), pubkey VARCHAR(50), - salt VARCHAR(50), uid VARCHAR(255), scrypt_N INT, scrypt_p INT, diff --git a/src/sakia/gui/dialogs/connection_cfg/model.py b/src/sakia/gui/dialogs/connection_cfg/model.py index c1b4f760fb2a2a1040c46712f58538146402e339..14b83a69f06f5abe62a9a34c1090fc257aec03cb 100644 --- a/src/sakia/gui/dialogs/connection_cfg/model.py +++ b/src/sakia/gui/dialogs/connection_cfg/model.py @@ -109,7 +109,9 @@ class ConnectionConfigModel(QObject): """" Publish the self certification of the connection identity """ - return await self.app.documents_service.broadcast_identity(self.connection, self.connection.password) + return await self.app.documents_service.broadcast_identity(self.connection, + self.connection.salt, + self.connection.password) async def check_registered(self): identities_processor = IdentitiesProcessor.instanciate(self.app) diff --git a/src/sakia/gui/sub/password_input/controller.py b/src/sakia/gui/sub/password_input/controller.py index cc2ecf0fb74c3a289b3e8f101d3d94169f4ffc43..c94dd8f40667d1bee87056e499eb4be352da8fce 100644 --- a/src/sakia/gui/sub/password_input/controller.py +++ b/src/sakia/gui/sub/password_input/controller.py @@ -50,8 +50,6 @@ class PasswordInputController(QObject): password_input.view.button_box.rejected.connect(dialog.reject) password_input.view.setParent(dialog) password_input.view.button_box.show() - if connection.password: - return connection.password result = await dialog_async_exec(dialog) if result == QDialog.Accepted: return password_input.get_salt_password() @@ -96,13 +94,8 @@ class PasswordInputController(QObject): self.password_changed.emit(False) def get_salt_password(self): - if self.view.check_remember.isChecked(): - self.connection.salt = self._secret_key - self.connection.password = self._password return self._secret_key, self._password def set_connection(self, connection): if connection: self.connection = connection - self.view.edit_secret_key.setText(connection.salt) - self.view.edit_password.setText(connection.password) diff --git a/src/sakia/gui/sub/password_input/password_input.ui b/src/sakia/gui/sub/password_input/password_input.ui index a57ae51f153e282941cd4869051efe687366a8a1..8f6448f55053d6bba7958f536d148966bfe73d7d 100644 --- a/src/sakia/gui/sub/password_input/password_input.ui +++ b/src/sakia/gui/sub/password_input/password_input.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>400</width> - <height>110</height> + <height>106</height> </rect> </property> <property name="windowTitle"> @@ -31,17 +31,6 @@ </property> </widget> </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QCheckBox" name="check_remember"> - <property name="text"> - <string>Remember during this session</string> - </property> - </widget> - </item> - </layout> - </item> <item> <widget class="QLabel" name="label_info"> <property name="text"> diff --git a/tests/conftest.py b/tests/conftest.py index e52361fbc9fbc7e7981f9fe6356d0f0375ee055a..e2b6b6b4587a41a5522ba5cd3c84bf68b34cb925 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -152,8 +152,7 @@ def application_with_one_connection(application, simple_fake_server, bob): previous_ud_block = [b for b in simple_fake_server.forge.blocks if b.ud][-2] origin_block = simple_fake_server.forge.blocks[0] connection = Connection(currency="test_currency", - pubkey=bob.key.pubkey, - salt=bob.salt, uid=bob.uid, + pubkey=bob.key.pubkey, uid=bob.uid, scrypt_N=mirage.User.SCRYPT_PARAMS.N, scrypt_r=mirage.User.SCRYPT_PARAMS.r, scrypt_p=mirage.User.SCRYPT_PARAMS.p, diff --git a/tests/technical/test_identities_service.py b/tests/technical/test_identities_service.py index f43481d83e9fc36a36e57802275dc9de9995d574..6c969c0be41421745bd29126ea2be7e8b55d8d13 100644 --- a/tests/technical/test_identities_service.py +++ b/tests/technical/test_identities_service.py @@ -16,7 +16,8 @@ async def test_new_block_with_certs(application_with_one_connection, fake_server signature=alice_user_identity.signature) bob_connection = application_with_one_connection.db.connections_repo.get_one(pubkey=bob.key.pubkey) await application_with_one_connection.documents_service.certify(bob_connection, - bob.password, alice_identity) + bob.salt, + bob.password, alice_identity) certs_after_send = application_with_one_connection.identities_service.certifications_sent( bob.key.pubkey) assert len(certs_after_send) == len(certs_before_send) + 1 @@ -43,10 +44,9 @@ async def test_new_block_with_idty(application_with_one_connection, john, simple blockstamp=john.blockstamp, signature=john.identity().signatures[0]) john_connection = Connection(currency="test_currency", - pubkey=john.key.pubkey, - salt=john.salt, uid=john.uid, - scrypt_N=4096, scrypt_r=4, scrypt_p=2, - blockstamp=john.blockstamp) + pubkey=john.key.pubkey, uid=john.uid, + scrypt_N=4096, scrypt_r=4, scrypt_p=2, + blockstamp=john.blockstamp) application_with_one_connection.db.connections_repo.insert(john_connection) application_with_one_connection.db.identities_repo.insert(john_identity) application_with_one_connection.instanciate_services() diff --git a/tests/technical/test_transactions_service.py b/tests/technical/test_transactions_service.py index d7184aca3462218463730e171dffd89021b3294b..388c23c77938571060698a4e4544ba2e12bfc155 100644 --- a/tests/technical/test_transactions_service.py +++ b/tests/technical/test_transactions_service.py @@ -7,8 +7,9 @@ async def test_send_tx_then_validate(application_with_one_connection, fake_serve tx_before_send = application_with_one_connection.transactions_service.transfers(bob.key.pubkey) bob_connection = application_with_one_connection.db.connections_repo.get_one(pubkey=bob.key.pubkey) await application_with_one_connection.documents_service.send_money(bob_connection, - bob.password, - alice.key.pubkey, 10, 0, "Test comment") + bob.salt, + bob.password, + alice.key.pubkey, 10, 0, "Test comment") tx_after_send = application_with_one_connection.transactions_service.transfers(bob.key.pubkey) assert len(tx_before_send) + 1 == len(tx_after_send) assert tx_after_send[-1].state is Transaction.AWAITING diff --git a/tests/unit/data/test_connections_repo.py b/tests/unit/data/test_connections_repo.py index 0f4911312a22f0519e3038e45d8652d9340b64b9..10156e119d9599b48c994be9cab12610fb167d1b 100644 --- a/tests/unit/data/test_connections_repo.py +++ b/tests/unit/data/test_connections_repo.py @@ -5,15 +5,15 @@ def test_add_get_drop_connection(meta_repo): connections_repo = ConnectionsRepo(meta_repo.conn) connections_repo.insert(Connection("testcurrency", "7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ", - "somesalt")) + "someuid")) connection = connections_repo.get_one(currency="testcurrency", pubkey="7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ", - salt="somesalt") + uid="someuid") assert connection.currency == "testcurrency" assert connection.pubkey == "7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ" - assert connection.salt == "somesalt" + assert connection.uid == "someuid" connections_repo.drop(connection) connection = connections_repo.get_one(currency="testcurrency", pubkey="7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ", - salt="somesalt") + uid="someuid") assert connection is None