How to fix the connection between Firefox Based browsers (like Zen) and KeepassXC (both installed via flatpak)
Credits to this comment i found: keepassxreboot/keepassxc#7352 (comment)
Sadly this only works for firefox but not firefox based browsers like Zen
So after literally live debugging the source code of zen here is the fix (technical explanation further down):
TL;DR:
Please skip the parts you already did if you already followed the linked comment at the top
Please also make sure to replaceYOUR_USERwith your username (echo $USER) and all zen related names with the ones from your browser in the following instructions
- Make sure your firefox based browser and keepass are installed and closed
- Create a file under
/home/YOUR_USER/.var/app/app.zen_browser.zen/.zen/native-messaging-hosts/(zen as example - please replace with flatpak app id and browser name) calledorg.keepassxc.keepassxc_browser.json - Paste following content into it:
{
"allowed_extensions": [
"keepassxc-browser@keepassxc.org"
],
"description": "KeePassXC integration with native messaging support",
"name": "org.keepassxc.keepassxc_browser",
"path": "/home/YOUR_USER/.mozilla/native-messaging-hosts/keepassxc-proxy",
"type": "stdio"
}- Make sure you have cargo/rust installed for the next step (try to run
cargoif it fails runcurl https://sh.rustup.rs -sSf | sh) - Execute following commands one after the other to build the keepass proxy (rust):
git clone https://github.com/varjolintu/keepassxc-proxy-rust.git
cd keepassxc-proxy-rust
cargo build --release- Wait for it to build and copy the newly created binary to the native-messaging-hosts dir:
cp ./target/release/keepassxc-proxy /home/YOUR_USER/.var/app/app.zen_browser.zen/.zen/native-messaging-hosts/keepassxc-proxy- Create a symlink folder under
/home/YOUR_USERNAME/.mozillathat points to the .zen folder of your flatpak installation which is normally located at/home/YOUR_USERNAME/.var/app/app.zen_browser.zen/.zen:
ln -s /home/YOUR_USERNAME/.var/app/app.zen_browser.zen/.zen /home/YOUR_USERNAME/.mozilla- Give your browsers flatpak sandbox access to this symlink and the keepass socket (run with sudo for system wide installation):
flatpak override --user --filesystem=~/.mozilla app.zen_browser.zen
flatpak override --user --filesystem=xdg-run/app/org.keepassxc.KeePassXC/:create app.zen_browser.zen- Open up KeepassXC and go into Settings > Browser Integration > Advanced and disable "Update native messaging manifest files at startup" as this will overwrite the native messaging host path for our keepass proxy file and thus breaking the whole setup on restart.
Please be aware that this can break other Installations or Browsers especially if they are installed after KeepassXC. In that case just try to find the native messaging hosts files/folder of the affected Browser and change the path to the keepass proxy by hand. As long as the path doesnt change the browser should be good!
- Thats it! Now you should be able to open keypass (dont forget to open a db and also activate browser extension in settings) and then open zen to connect the extension. Maybe also reboot maybe dont idk.
If you have problems you can write me on discord. My tag is
deadlinecode
No matter the rebranding of the firefox browser it will still try to search the .mozilla directory for the native-messaging-hosts Normally in the flatpak sandbox a symlink is available from ~/.zen to ~/.var/app/app.zen_browser.zen/.zen. On normal firefox it wouldn't be called .zen but rather .mozilla. Thats why you can...
Try running flatpak run --command=sh app.zen_browser.zen to access the sandbox via a shell. You can use this shell to see if you setup the folders correctly (you should be able to cd into ~/.mozilla/native-messaging-hosts/ and see both files json and binary).
You can also use the Browser Console in Zen (Top Right Three Dots -> More tools -> Browser Console) to see if you get any errors on startup or when clicking the refresh button in the KeepassXC Extension. (Something like "No such native extension: org.keepassxc.keepassxc_browser")
And like i said: If you have problems you can write me on discord. My tag is deadlinecode. Or just write under this gist :)
THANK YOU! The only fixed that worked for my flatpak floorp setup. I did give up and tried using their ppa, but its outdated as sh*t. Thank god flatpak did not nuke my user settings after I uninstalled Floorp. Thank you again.