Repository navigation
bitwarden-desktop: fix system authentication - #339384
Conversation
|
Oh and I assume I should @ maintainers: |
|
I agree with both your suggestions regarding extracting the polkit file automatically - unfortunately I can't type very much right now due to wrist pain so I will have to get back to it soon. |
|
@amarshall @Aleksanaa |
878c002 to
4a3920e
Compare
|
@amarshall Sorry to bother - any chance you could review this in the near future? Let me know if you'd like any changes. |
|
Hi I'm sorry I can't give much time to review this at the moment. Have you verified the new command you use to extract |
No worries at all!
haha I have now! It missed the first line before, now its identical. Thanks for making me double check. Should be ready to merge anytime |
|
I wish I had seen this before! I created #344073 after several days of manually digging through each thing. Would you also be able to fix the startup app path issue as well in here? |
|
@alexyao2015 Are you able to test this PR? I don’t use this functionality and don’t have biometrics hardware to test it. |
|
I've been using this for a few days and it works well (after I figured out that I needed to move bitwarden from being installed as a user package via home manager to a regular system package instead). |
@alexyao2015 Hi! I'm not exactly sure what you mean by "the startup app path issue"; I think my fix here accounts for what you're talking about but if I missed something I will definitely add it to this PR. Also, for anyone wanting to test this PR, note that you don't need biometrics hardware; all this feature does is integrate with polkit, which can be configured to authenticate in many different ways (by changing it's pam.d configuration to use eg. fprintd, yubikey, or just standard password prompts via polkit agents like polkit-gnome-authentication-agent-1). And yeah, as @jamesbirtles mentioned, you have to use NixOS's |
|
Hey by "startup app path issue", take a look at the linked issue under I'm thinking instead of replacing the return statement, create a git patch to replace the two instances of Alternatively, I'm thinking, in this case, we could even do a find replace of all code in the repo for |
This is probably an undesirable result, forcing people to use |
Ah, you're right! I've never used autostart before so I never noticed.
Both approaches seem good; I'll start working on whichever one seems nicer now.
I agree, but sadly not that I know of! Maybe there should be though. |
|
It doesn’t force anyone to use systemPackages. That’s only necessary if one needs the polkit features. It’s nothing unique to Bitwarden, either, but applicable to any package requiring polkit or other similar privileged access. |
|
I see something like this being done in the pam module. Perhaps something similar can be done in the polkit module. |
|
Alright @alexyao2015 @amarshall I've changed # 3 to replace all instances of |
|
I tested it and it seems to work well. On this particular version (2024.8.x) with a new Bitwarden extension (2024.9.x), I noticed that the system unlock didn't function correctly. Updating the package to the latest version (2024.9.0) fixed the issue and I was able to unlock the extension once again. You might want to rebase your change on master again to pull in the change that updates Bitwarden to 2024.9.0. I created a separate branch with a few cherry picked commits to test this here. |
a873810 to
cdb96a2
Compare
Done. (Sorry about the force push; I'm still kinda unsure about how to handle this situation properly in git) |
|
Just updated to the latest commit, still working well, and the startup checkbox is now working properly too 👍 |
There was a problem hiding this comment.
This feels brittle.
I wonder, if you apply the below patch, is this still needed? Reason being that I think this makes the --inherit-argv0 actually have an effect, and I suspect may mean getPath('exe') will be the wrapper instead of the electron.
diff --git a/pkgs/by-name/bi/bitwarden-desktop/package.nix b/pkgs/by-name/bi/bitwarden-desktop/package.nix
index 104abfb85505..11373f398978 100644
--- a/pkgs/by-name/bi/bitwarden-desktop/package.nix
+++ b/pkgs/by-name/bi/bitwarden-desktop/package.nix
@@ -10,8 +10,8 @@
, gtk3
, jq
, libsecret
+, makeBinaryWrapper
, makeDesktopItem
-, makeWrapper
, napi-rs-cli
, nix-update-script
, nodejs_20
@@ -78,7 +78,7 @@ in buildNpmPackage rec {
cargo
copyDesktopItems
jq
- makeWrapper
+ makeBinaryWrapper
napi-rs-cli
pkg-config
(python3.withPackages (ps: with ps; [ setuptools ]))There was a problem hiding this comment.
Actually, I think the docs are outdated and the shell makeWrapper does support it (though maybe there’s still some difference). Question is then: how is Electron getting the wrong exe path?
There was a problem hiding this comment.
Looking into the source, Electron defers to Chromium which, on Linux, gets the path by resolving /proc/self/exe, so argv0 I guess won’t have an effect on it.
I may try to hack on something a bit later or tomorrow…
There was a problem hiding this comment.
This feels brittle.
Understood, that's fair - would you be OK with the manual git patch and substituteAllInPlace approach (as previously described) instead of the current global find/replace?
I wonder, if you apply the below patch, is this still needed? Reason being that I think this makes the --inherit-argv0 actually have an effect, and I suspect may mean getPath('exe') will be the wrapper instead of the electron.
Question is then: how is Electron getting the wrong exe path?
Looking into the source, Electron defers to Chromium which, on Linux, gets the path by resolving /proc/self/exe, so argv0 I guess won’t have an effect on it.
I had a similar thought initially (aside from the /proc/self/exe part which I never discovered) and I believe, even if electron did read from argv0, this solution would still also require a change to electron packaging in nixpkgs, because while electron apps' wrapper scripts do set the electron package's argv0 to their wrapper's names, that electron package itself is a wrapper which does not set the unwrapped electron binary's argv0 to the one that script inherited (see cat $(nix eval --raw nixpkgs#electron.outPath)/bin/electron, no exec -a). That's what I initially noticed and why I went for patching bitwarden instead, as any change that would make it work would be far out of the scope of this PR. But if I'm reading the scripts wrong or you come up with something, let us know!
There was a problem hiding this comment.
I came up with a simpler alternative to this—check out 597b42f#diff-abc99a217fe3c23c6ad190d6c205e836b702d4f921e90bacf7f9a4bfdffdb893
There was a problem hiding this comment.
awesome, that's super clean. I'll add this in rn
|
Instead of fixing bitwarden's native messaging host installer, maybe we should use nix's firefox packages' I hate to keep bikeshedding this, but this seems like the method that other packages, like |
Thanks, I was not aware of this, however I still don't feel that that's a good enough solution because:
I'm still willing to be convinced but I'd argue that a solution like the current one is still optimal. (we could consider also copying the native messaging file to @amarshall I'd like to get this merged when possible, what are your thoughts? Are you ok enough with the current find/replace or rather switch to a git patch and substituteAllInPlace, or @huantianad's idea, or something else completely? |
|
Thanks @amarshall, I switched to what you came up with. |
|
I believe all the subsequent commits are just updates to the first one, and are semantically one commit, as such, please squash them and then I think this is good-to-go. |
1f20405 to
4cc4fd6
Compare
done! |
Maybe we could do this so this derivation is consistent with the others? Also this native messaging hosts is done on the derivation level and not on the module level. I'm also not sure if there is something that the Firefox maintainers would prefer, not sure if it's worth asking tho. I think we can discuss this further in a separate issue/PR if more convenient and get this merged first. |
I'm happy to do that in a separate issue/PR (whatever works) where you can ping relevant FF maintainers if need be |
|
@amarshall this should be ready to merge anytime (correct me if not) |
|
@amarshall Sorry to be annoying about this - any chance this could be merged soon? Thanks. |
Description of changes
This does 3 things:
com.bitwarden.Bitwarden.policypolkit action file (required for system authentication)/usr/share/polkit-1/actions/now we can use bitwarden-desktop to authenticate with biometrics in the web extension via polkit and native messaging :)
Relevant:
Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.