bitwarden-desktop: fix system authentication

This commit is contained in:
Jack N 2024-09-03 18:11:41 -07:00
parent 84bd184f81
commit 4cc4fd6ff1
3 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,13 @@
diff --git a/apps/desktop/src/platform/main/biometric/biometric.unix.main.ts b/apps/desktop/src/platform/main/biometric/biometric.unix.main.ts
index e2428d9d12..de4e9e1e62 100644
--- a/apps/desktop/src/platform/main/biometric/biometric.unix.main.ts
+++ b/apps/desktop/src/platform/main/biometric/biometric.unix.main.ts
@@ -109,7 +109,7 @@ export default class BiometricUnixMain implements OsBiometricService {
// The user needs to manually set up the polkit policy outside of the sandbox
// since we allow access to polkit via dbus for the sandboxed clients, the authentication works from
// the sandbox, once the policy is set up outside of the sandbox.
- return isLinux() && !isSnapStore() && !isFlatpak();
+ return false;
}
async osBiometricsSetup(): Promise<void> {

View File

@ -40,11 +40,15 @@ in buildNpmPackage rec {
patches = [
./electron-builder-package-lock.patch
./dont-auto-setup-biometrics.patch
./set-exe-path.patch # ensures `app.getPath("exe")` returns our wrapper, not ${electron}/bin/electron
];
postPatch = ''
# remove code under unfree license
rm -r bitwarden_license
substituteInPlace apps/desktop/src/main.ts --replace-fail '%%exePath%%' "$out/bin/bitwarden"
'';
nodejs = nodejs_20;
@ -174,6 +178,13 @@ in buildNpmPackage rec {
--set-default ELECTRON_IS_DEV 0 \
--inherit-argv0
# Extract the polkit policy file from the multiline string in the source code.
# This may break in the future but its better than copy-pasting it manually.
mkdir -p $out/share/polkit-1/actions/
pushd apps/desktop/src/platform/main/biometric
awk '/const polkitPolicy = `/{gsub(/^.*`/, ""); print; str=1; next} str{if (/`;/) str=0; gsub(/`;/, ""); print}' biometric.unix.main.ts > $out/share/polkit-1/actions/com.bitwarden.Bitwarden.policy
popd
pushd apps/desktop/resources/icons
for icon in *.png; do
dir=$out/share/icons/hicolor/"''${icon%.png}"/apps

View File

@ -0,0 +1,13 @@
diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.ts
index 86d07440a7..be9fa6b4ab 100644
--- a/apps/desktop/src/main.ts
+++ b/apps/desktop/src/main.ts
@@ -80,6 +80,8 @@ export class Main {
appDataPath = path.join(process.env.SNAP_USER_DATA, "appdata");
}
+ app.setPath("exe", "%%exePath%%");
+
app.on("ready", () => {
// on ready stuff...
});