added keyring auth, so we don't have to save credentials in file

This commit is contained in:
2025-09-16 13:47:28 +02:00
parent d38aeda6c0
commit eea479b3df
3 changed files with 60 additions and 30 deletions

View File

@@ -67,6 +67,12 @@
<p>Updated to newest FreeRDP which seems to fix issues with hanging / freezing</p>
</description>
</release>
<release version="1.3.0" date="2025-02-19">
<url type="details">https://gitea.farmdash.org/angoosh/Flatpaks/src/tag/1.3.0</url>
<description>
<p>Changed pasword storage from file to system keyring. Still using file for compatibility. Also added menu for credential selection.</p>
</description>
</release>
</releases>
<screenshots>

View File

@@ -31,6 +31,7 @@ finish-args:
- --filesystem=xdg-download
- --socket=pcsc
# - --socket=system-bus
- --socket=session-bus
# - --talk-name=org.freedesktop.Flatpak
add-build-extensions:
@@ -68,7 +69,7 @@ modules:
build-args:
- --share=network
build-commands:
- pip3 install PyGObject cryptography
- pip3 install PyGObject cryptography keyring
- name: rdpconnect
buildsystem: simple

View File

@@ -18,13 +18,15 @@ from cryptography.fernet import Fernet
gi.require_version('Gtk', '4.0')
gi.require_version('Adw', '1')
from gi.repository import Gtk, Adw, Gdk, Gio
import keyring
APPID = "com.angoosh.RDPConnect"
HOMEDIR = os.path.expanduser('~')
VERSION = "1.2.0"
VERSION = "1.3.0"
conn_info = {}
hist_info = {}
settings = {}
settings["extra_params"] = {}
fernet = ""
@@ -47,6 +49,18 @@ def load_keys():
def load_config():
global conn_info, settings
loaded_json = ""
try:
with open(HOMEDIR+"/.config/rdpconnect/history.json", "r") as history_file:
for line in connection_file:
loaded_json += line
hist_info = json.loads(loaded_json)
last_conn = conn_info[max(hist_info)]
conn_info["user"] = last_conn.split('@')[0]
conn_info["ip"] = last_conn.split('@')[1]
conn_info["passwd"] = keyring.get_password("rdpconnect", last_conn)
except:
try:
with open(HOMEDIR+"/.config/rdpconnect/connection.json", "r") as connection_file:
for line in connection_file:
@@ -261,6 +275,15 @@ class MyApp(Adw.Application):
def saveConnConf(self):
if settings["save_conn"]:
password = conn_info["passwd"]
useratip = conn_info["user"] + "@" + conn_info["ip"]
with open(HOMEDIR+"/.config/rdpconnect/history.json", "a") as hist_file:
hist_id = str(int(max(hist_info)) + 1)
hist_info[hist_id] = useratip
js = json.dumps(hist_info, sort_keys=True, indent=4, separators=(',', ': '))
hist_file.write(js)
try:
keyring.set_password("rdpconnect", useratip, password)
except:
conn_info["passwd"] = fernet.encrypt(password.encode()).decode("utf-8")
print("Saving connection config to "+HOMEDIR+"/.config/rdpconnect/connection.json")