Skip to content
This repository was archived by the owner on Nov 27, 2025. It is now read-only.

Add support for the KeePassNatMsg plugin#93

Draft
Abestanis wants to merge 37 commits intoRoelVB:dev-v1from
Abestanis:feature/kee_pass_native
Draft

Add support for the KeePassNatMsg plugin#93
Abestanis wants to merge 37 commits intoRoelVB:dev-v1from
Abestanis:feature/kee_pass_native

Conversation

@Abestanis
Copy link
Contributor

@Abestanis Abestanis commented Dec 7, 2022

This pull request includes changed from #92 and should be merged after it.

This adds support to connect to the KeePass password manage via the KeePassNatMsg plugin in addition to the KeePassHttp plugin that we already support, which is no longer being actively developed.

For this to work, we need the KeePassNatMsg to add our extension id to the list of allowed extensions in its native messaging configuration files. I created a pull request in their repository with the required changes here: smorks/keepassnatmsg#102

For testing this locally edit the kpnm_chrome.json configuration file (on Windows, its located at %LocalAppData%\KeePassNatMsg) and add "chrome-extension://<extension id>/", to the allowed_origins list, where <extension id> has to be replaced with the extension id of ChromeKeePass.

The user is able to select between the two plugins in the options. It is also possible to change the native messaging app id, this way one could also possibly connect to another plugin that provides the same interface as KeePassNatMsg. I also took the chance to clean up the association options UI and made the connect button save the current settings, so the users are actually connecting with the settings they see, not the ones that were saved in storage before they edited them:

The new settings
The new settings behaviour

The default in the settings is to connect via the KeePassHttp plugin, to not break existing configurations. But I think KeePassNatMsg should be the default, since KeePassHttp seems to be no longer actively maintained.
@RoelVB do you agree with that? In that case, we could add some code that saves the settings when the plugin is loaded, release a version that will save the KeePassHttp as the selected plugin, and then change the default.

I tested that fetching credentials normally and for http basic auth is still working with Chrome and Edge.

localStorage is not available in service workers.
It is no longer necessity, Chrome and Edge now set the `Origin` header
correctly.
@Abestanis Abestanis changed the title Feature/kee pass native Add support for the KeePassNatMsg plugin Dec 7, 2022
@Abestanis Abestanis changed the base branch from master to dev December 7, 2022 00:34
@Abestanis
Copy link
Contributor Author

The pull request in the KeePassNat plugin has now been merged and a new version of the plugin has been released, which includes ChromeKeePass in its list of allowed extension ids. 🎉

@Abestanis
Copy link
Contributor Author

@RoelVB Should I try to rebase this on the dev-v2 branch, or should I wait until you tell me it's ready?

@Abestanis
Copy link
Contributor Author

Hey @RoelVB, I hope you are doing good. Since version 2 of the extension has now been officially released, would you be interesting in accepting this MR if I rebased it onto the dev-v2 branch?

@ArtyoZ
Copy link

ArtyoZ commented Jul 30, 2025

Hello!
@Abestanis, I'm looking forward to these changes!
@RoelVB, when will they be in the main branch?

@Abestanis
Copy link
Contributor Author

Hey, I've been using this branch for the past 3 years in Chrome without a problem, it is working very well.

But the extension has changed quite a bit so it will take some work to bring this into the current main branch. I am willing to work towards merging it, but I would like to know that it's not going to sit unmerged again for 3 years before I put any more time in this.

@ArtyoZ
Copy link

ArtyoZ commented Jul 31, 2025

Hey, I've been using this branch for the past 3 years in Chrome without a problem, it is working very well.

Is it a compiled or an unpacked CRX? Could you share it?

But the extension has changed quite a bit so it will take some work to bring this into the current main branch. I am willing to work towards merging it, but I would like to know that it's not going to sit unmerged again for 3 years before I put any more time in this.

Yes, I understand you. It's a bit strange that @RoelVB hasn't merged your PR so far :(
It might be worth creating a fork and making a new PR for it...

@Abestanis
Copy link
Contributor Author

Is it a compiled or an unpacked CRX? Could you share it?

Sure, here is the zip: ChromeKeePass-feature-kee_pass_native.zip
If you want to build it for your self, just clone the fork, check out the feature/kee_pass_native branch, follow the build instructions and then enable developer mode in the Chrome/Edge extension settings and load the extension from the dist directory.

@ArtyoZ
Copy link

ArtyoZ commented Aug 8, 2025

Sure, here is the zip: ChromeKeePass-feature-kee_pass_native.zip

Thank you! However, I was unable to use this extension with KeePass v2.59 and KeePassNatMsg v2.0.17.0. After selecting the "KeePassNatMsg" access method and clicking the "Connect" button, I always receive the message "Something went wrong... did you accept the connection within KeePass?" The "KeePassXC-Browser" chrome extension works without any issues with the same configuration.

What am I doing wrong?

@Abestanis
Copy link
Contributor Author

Abestanis commented Aug 8, 2025

Ah, my bad, I forgot a step:

Because the browser assigns a random id to the extracted extension, we need to manually edit some files to allow the extension to talk to KeePassNatMsg. To do so, we need to edit all .json files in %LocalAppData%\KeePassNatMsg (that's the path on Windows, see here for information on where to find the path for other operating systems) and add "chrome-extension://abcd/", to the allowed_origins list, where abcd is replaced by the random id that is assigned to the extension.

So the files should looks something like this:
{
  "name": "org.keepassxc.keepassxc_browser",
  "description": "KeepassXC integration with Native Messaging support",
  "path" : "keepassnatmsg-proxy.exe",
  "type": "stdio",
  "allowed_origins": [
    "chrome-extension://iopaggbpplllidnfmcghoonnokmjoicf/",
    "chrome-extension://igehcghedoajofcldolpdbnlfapcoagk/",
    "chrome-extension://oboonakemofpalcgghocfoadofidjkkk/",
    "chrome-extension://pdffhmdngciaglkoonimfcmckehcpafo/"
  ]
}

@RoelVB
Copy link
Owner

RoelVB commented Aug 13, 2025

@ArtyoZ
Why would you need this support so bad? It doesn't really add anything.

In my opinion, the only reason to add support for this it to built OTP support into CKP, but this has a low priority. It's not really recommended to have your OTP in the same database as you username and password, that kind of defeats the purpose of OTP.

If we do add support for KeePassNatMsg there's some more things that need to happen. First of all it will have to be implemented in v2. But to do is right I would want an abstraction layer and we need automated tests.

@ArtyoZ
Copy link

ArtyoZ commented Oct 2, 2025

@RoelVB

Why would you need this support so bad? It doesn't really add anything.

Let's just compare KeePassHttp plugin and KeePassNatMsg plugin possibilities.

image image image image

And, of cause:

built OTP support

I really use and need options 1, 2, 3 marked red on KeePassNatMsg screenshots. Yes, we have KeePassXC-Browser Chrome extension that supports KeePassNatMsg plugin. But your extension works better in some cases.

@RoelVB
Copy link
Owner

RoelVB commented Oct 2, 2025

@ArtyoZ
Thanks for letting me know. I wasn't aware of those.

@Abestanis
Copy link
Contributor Author

But to do is right I would want an abstraction layer and we need automated tests.

This abstraction layer should be added before anything else. It is a refactoring of the existing KeePassHTTP connection interface and merging it with the addition of the KeePassNatMsg connection would create a huge PR. Same goes for the automated tests, they can be added for the existing KeePassHTTP connection interface before adding the KeePassNatMsg connection, and then it will be easy to add some for the new conneciton.

First of all it will have to be implemented in v2

Looks like the core logic does not really have to change, it's mainly the configuration interface that will need adapted. As outlined above, this can be done once the abstraction layer and tests for the KeePassHTTP connection have been added. Once these exist I'll be happy to add the KeePassNatMsg connection on top of the abstraction layer + tests based on the KeePassHTTP tests.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants