From 7e3538053649a9bf88f704b06154e5a6b4a23e73 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Sat, 4 May 2024 06:50:09 +0200 Subject: [PATCH 1/8] Fix ui crash when data is empty --- gui/src/gui/quickaccess.py | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/gui/src/gui/quickaccess.py b/gui/src/gui/quickaccess.py index b2a272e..100b2c6 100644 --- a/gui/src/gui/quickaccess.py +++ b/gui/src/gui/quickaccess.py @@ -71,6 +71,8 @@ class GoldwardenQuickAccessApp(Adw.Application): # totp code if keyval == Gdk.KEY_t or keyval == Gdk.KEY_T: + if self.filtered_logins[self.selected_index]["totp"] == "": + return if auto_type_combo: self.run_autotype(totp.totp(self.filtered_logins[self.selected_index]["totp"])) if copy_combo: @@ -154,15 +156,34 @@ class GoldwardenQuickAccessApp(Adw.Application): for i in self.filtered_logins: action_row = Adw.ActionRow() - action_row.set_title(i["name"]) - action_row.set_subtitle(i["username"]) + if "name" in i: + action_row.set_title(i["name"]) + else: + action_row.set_title("[no name]") + if "username" in i: + action_row.set_subtitle(i["username"]) + action_row.username = i["username"] + else: + action_row.set_subtitle("[no username]") + action_row.username = "[no username]" + if "password" in i: + action_row.password = i["password"] + else: + action_row.password = "[no password]" + if "uri" in i: + action_row.uri = i["uri"] + else: + action_row.uri = "[no uri]" + if "uuid" in i: + action_row.uuid = i["uuid"] + else: + action_row.uuid = "[no uuid]" + if "totp" in i: + action_row.totp = i["totp"] + else: + action_row.totp = "" action_row.set_icon_name("dialog-password") action_row.set_activatable(True) - action_row.password = i["password"] - action_row.username = i["username"] - action_row.uuid = i["uuid"] - action_row.uri = i["uri"] - action_row.totp = i["totp"] self.results_list.append(action_row) # select the nth item From ac0f8a1c26e5a47cf9c9a77c9e2cfc360ba639ed Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Sat, 4 May 2024 22:29:29 +0200 Subject: [PATCH 2/8] Update Readme.md --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 7220a43..4626d0e 100644 --- a/Readme.md +++ b/Readme.md @@ -67,6 +67,6 @@ For instructions on specific features, also consult the wiki page for the featur ### Contributing Interested in contributing a feature or bug-fix? Great! Here is some information on how to set up your development environment: -https://github.com/quexten/goldwarden/cli/wiki/Setting-up-the-Development-Environment +https://github.com/quexten/goldwarden/wiki/Setting-up-the-Development-Environment After that, create a PR. If you encounter any issues, feel free to open a discussion thread. From 4c478f2c4ecd2fbbcb9f07cf4ce7e17892bdb295 Mon Sep 17 00:00:00 2001 From: lollilol <38194372+lollilol@users.noreply.github.com> Date: Sun, 5 May 2024 23:34:04 +0200 Subject: [PATCH 3/8] fix link to "getting started" --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 4626d0e..16e5140 100644 --- a/Readme.md +++ b/Readme.md @@ -61,7 +61,7 @@ go install github.com/quexten/goldwarden@latest ``` ### Setup and Usage -To get started, follow the instructions provided in the wiki https://github.com/quexten/goldwarden/cli/wiki/Getting-Started. +To get started, follow the instructions provided in the wiki [https://github.com/quexten/goldwarden/cli/wiki/Getting-Started](https://github.com/quexten/goldwarden/wiki/Getting-Started). For instructions on specific features, also consult the wiki page for the feature. ### Contributing From bee4e77e0dff3083fb724a6cbc187a2058eba224 Mon Sep 17 00:00:00 2001 From: Shane Blackthorne Date: Thu, 9 May 2024 12:32:29 -0700 Subject: [PATCH 4/8] fixed PKGBUILD --- .github/workflows/PKGBUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/PKGBUILD b/.github/workflows/PKGBUILD index a1f0728..b512183 100644 --- a/.github/workflows/PKGBUILD +++ b/.github/workflows/PKGBUILD @@ -12,7 +12,7 @@ sha256sums=('57555dab4afd4fc60785e8ad34f41932988b4cd2ce130daaa719625a0e455481') prepare(){ cd "$pkgname-$pkgver" - mkdir -p build/ + mkdir -p build/ cmd/ } build() { From 9fbf1a08ee0a1b3718a192ae98658859504b436b Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Fri, 10 May 2024 11:31:24 +0200 Subject: [PATCH 5/8] Attempt to fix credentials not being set in gui --- gui/src/gui/login.py | 4 ++-- gui/src/services/goldwarden.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gui/src/gui/login.py b/gui/src/gui/login.py index 0a8179b..7953bbd 100644 --- a/gui/src/gui/login.py +++ b/gui/src/gui/login.py @@ -52,9 +52,9 @@ class GoldwardenLoginApp(Adw.Application): server = self.server_row.get_text() goldwarden.set_url(server) if client_id != "": - goldwarden.set_client_id(client_id) + print("set client id result", goldwarden.set_client_id(client_id.strip())) if client_secret != "": - goldwarden.set_client_secret(client_secret) + print("set client secret result", goldwarden.set_client_secret(client_secret.strip())) goldwarden.login_with_password(email, "") self.window.close() diff --git a/gui/src/services/goldwarden.py b/gui/src/services/goldwarden.py index d691c17..7239012 100644 --- a/gui/src/services/goldwarden.py +++ b/gui/src/services/goldwarden.py @@ -81,10 +81,10 @@ def get_environment(): return None def set_client_id(client_id): - send_authenticated_command(f"config set-client-id \"{client_id}\"") + return send_authenticated_command(f"config set-client-id {client_id}") def set_client_secret(client_secret): - send_authenticated_command(f"config set-client-secret \"{client_secret}\"") + return send_authenticated_command(f"config set-client-secret {client_secret}") def login_with_password(email, password): result = send_authenticated_command(f"vault login --email {email}") From d70dd90630195b511c019461e01192703b1bb9f7 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Sat, 11 May 2024 03:35:30 +0200 Subject: [PATCH 6/8] Fix executable bit on main python file --- gui/goldwarden_ui_main.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 gui/goldwarden_ui_main.py diff --git a/gui/goldwarden_ui_main.py b/gui/goldwarden_ui_main.py old mode 100644 new mode 100755 From 3fa3ec2264158bbadf78a79d08766aa4e33193ac Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Sat, 11 May 2024 03:36:13 +0200 Subject: [PATCH 7/8] Fix server not being set when logging in from UI --- gui/src/gui/login.py | 2 +- gui/src/gui/quickaccess.py | 3 +++ gui/src/services/goldwarden.py | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/gui/src/gui/login.py b/gui/src/gui/login.py index 0a8179b..a3e6e5c 100644 --- a/gui/src/gui/login.py +++ b/gui/src/gui/login.py @@ -50,7 +50,7 @@ class GoldwardenLoginApp(Adw.Application): client_id = self.client_id_row.get_text() client_secret = self.client_secret_row.get_text() server = self.server_row.get_text() - goldwarden.set_url(server) + print("setting server to", server, "with result", goldwarden.set_server(server)) if client_id != "": goldwarden.set_client_id(client_id) if client_secret != "": diff --git a/gui/src/gui/quickaccess.py b/gui/src/gui/quickaccess.py index 100b2c6..4030814 100644 --- a/gui/src/gui/quickaccess.py +++ b/gui/src/gui/quickaccess.py @@ -69,6 +69,9 @@ class GoldwardenQuickAccessApp(Adw.Application): auto_type_combo = state & Gdk.ModifierType.CONTROL_MASK and state & Gdk.ModifierType.SHIFT_MASK copy_combo = state & Gdk.ModifierType.CONTROL_MASK and not state & Gdk.ModifierType.SHIFT_MASK + if not len(self.filtered_logins) > 0: + return + # totp code if keyval == Gdk.KEY_t or keyval == Gdk.KEY_T: if self.filtered_logins[self.selected_index]["totp"] == "": diff --git a/gui/src/services/goldwarden.py b/gui/src/services/goldwarden.py index d691c17..41755cd 100644 --- a/gui/src/services/goldwarden.py +++ b/gui/src/services/goldwarden.py @@ -70,8 +70,8 @@ def set_notification_url(url): def set_vault_url(url): send_authenticated_command(f"config set-vault-url {url}") -def set_url(url): - send_authenticated_command(f"config set-url {url}") +def set_server(url): + send_authenticated_command(f"config set-server {url}") def get_environment(): result = send_authenticated_command(f"config get-environment") From 50451914f283217312f639d9d5d080422acd3a30 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Sat, 11 May 2024 04:26:21 +0200 Subject: [PATCH 8/8] Present error on failed login --- gui/goldwarden_ui_main.py | 0 gui/src/gui/login.py | 31 +++++++++++++++++++++++++++++-- gui/src/services/goldwarden.py | 15 ++++++++++----- 3 files changed, 39 insertions(+), 7 deletions(-) mode change 100644 => 100755 gui/goldwarden_ui_main.py diff --git a/gui/goldwarden_ui_main.py b/gui/goldwarden_ui_main.py old mode 100644 new mode 100755 diff --git a/gui/src/gui/login.py b/gui/src/gui/login.py index 0a8179b..2104a82 100644 --- a/gui/src/gui/login.py +++ b/gui/src/gui/login.py @@ -50,12 +50,39 @@ class GoldwardenLoginApp(Adw.Application): client_id = self.client_id_row.get_text() client_secret = self.client_secret_row.get_text() server = self.server_row.get_text() - goldwarden.set_url(server) + try: + goldwarden.set_server(server) + except: + print("set server failed") + dialog = Adw.MessageDialog.new(self.window, + "Failed to set server", + "The server you entered is invalid, please try again.", + ) + dialog.add_response("ok", "Dismiss") + dialog.present() + return if client_id != "": goldwarden.set_client_id(client_id) if client_secret != "": goldwarden.set_client_secret(client_secret) - goldwarden.login_with_password(email, "") + try: + goldwarden.login_with_password(email, "") + except Exception as e: + if "errorbadpassword" in str(e): + dialog = Adw.MessageDialog.new(self.window, "Bad Password", "The username or password you entered is incorrect.") + dialog.add_response("ok", "Dismiss") + dialog.present() + return + if "errorcaptcha" in str(e): + dialog = Adw.MessageDialog.new(self.window, "Unusual traffic error", "Traffic is unusual, please set up api client id and client secret.") + dialog.add_response("ok", "Dismiss") + dialog.present() + return + if "errortotp" in str(e): + dialog = Adw.MessageDialog.new(self.window, "TOTP Invalid", "The TOTP code you entered is invalid.") + dialog.add_response("ok", "Dismiss") + dialog.present() + return self.window.close() if __name__ == "__main__": diff --git a/gui/src/services/goldwarden.py b/gui/src/services/goldwarden.py index d691c17..dcfeeb5 100644 --- a/gui/src/services/goldwarden.py +++ b/gui/src/services/goldwarden.py @@ -70,8 +70,10 @@ def set_notification_url(url): def set_vault_url(url): send_authenticated_command(f"config set-vault-url {url}") -def set_url(url): - send_authenticated_command(f"config set-url {url}") +def set_server(url): + result = send_authenticated_command(f"config set-server {url}") + if result.strip() != "Done": + raise Exception("Failed to set server") def get_environment(): result = send_authenticated_command(f"config get-environment") @@ -88,9 +90,12 @@ def set_client_secret(client_secret): def login_with_password(email, password): result = send_authenticated_command(f"vault login --email {email}") - if not "Logged in" in result: - return "badpass" - return "ok" + if "Login failed" in result and "username or password" in result.lower(): + raise Exception("errorbadpassword") + if "Login failed" in result and ("error code 7" in result.lower() or "error code 6" in result.lower()): + raise Exception("errorcaptcha") + if "Login failed" in result and "two-factor" in result.lower(): + raise Exception("errortotp") def login_passwordless(email): send_authenticated_command(f"vault login --email {email} --passwordless")