diff --git a/apps/desktop/desktop_native/core/src/ipc/mod.rs b/apps/desktop/desktop_native/core/src/ipc/mod.rs index b4c59245e6b..b844bd8d392 100644 --- a/apps/desktop/desktop_native/core/src/ipc/mod.rs +++ b/apps/desktop/desktop_native/core/src/ipc/mod.rs @@ -19,8 +19,11 @@ pub const NATIVE_MESSAGING_BUFFER_SIZE: usize = 1024 * 1024; /// but ideally the messages should be processed as quickly as possible. pub const MESSAGE_CHANNEL_BUFFER: usize = 32; -pub const FLATPAK_PATHS: [&str; 1] = [ +pub const FLATPAK_PATHS: [&str; 4] = [ "org.mozilla.firefox/.mozilla/native-messaging-hosts", + "com.google.Chrome/.config/google-chrome/NativeMessagingHosts", + "org.chromium.Chromium/.config/chromium/NativeMessagingHosts", + "com.microsoft.Edge/.config/microsoft-edge/NativeMessagingHosts", ]; /// This is the codec used for communication through the UNIX socket / Windows named pipe. diff --git a/apps/desktop/electron-builder.json b/apps/desktop/electron-builder.json index 1e96198d4ad..6320fef35df 100644 --- a/apps/desktop/electron-builder.json +++ b/apps/desktop/electron-builder.json @@ -106,7 +106,7 @@ "to": "desktop_proxy" } ], - "target": ["deb", "freebsd", "rpm", "AppImage", "snap"], + "target": ["snap"], "desktop": { "Name": "Bitwarden", "Type": "Application", @@ -256,6 +256,12 @@ "action-prefix": "com.bitwarden.Bitwarden" } }, + { + "personal-files": { + "read": [], + "write": ["$HOME/.config/chromium", "$HOME/.config/google-chrome", "$HOME/.mozilla"] + } + }, "u2f-devices" ], "stagePackages": ["default"] diff --git a/apps/desktop/resources/com.bitwarden.desktop.devel.yaml b/apps/desktop/resources/com.bitwarden.desktop.devel.yaml index 2df7b6ca9ec..1c37f895112 100644 --- a/apps/desktop/resources/com.bitwarden.desktop.devel.yaml +++ b/apps/desktop/resources/com.bitwarden.desktop.devel.yaml @@ -17,7 +17,7 @@ finish-args: - --talk-name=org.freedesktop.secrets - --talk-name=com.canonical.AppMenu.Registrar - --system-talk-name=org.freedesktop.PolicyKit1 - # Lock on lockscreen + # Lock on lockscreen - --talk-name=org.gnome.ScreenSaver - --talk-name=org.freedesktop.ScreenSaver - --system-talk-name=org.freedesktop.login1 @@ -27,8 +27,12 @@ finish-args: # Browser integration # The config directory is needed to write manifests for non-flatpak # Sockets are mounted in each app's directory - - --filesystem=xdg-config + # + # Non-sandboxed + - --filesystem=xdg-config/google-chrome + - --filesystem=xdg-config/chromium - --filesystem=home/.mozilla + # Flatpak-sandboxed - --filesystem=~/.var/app/org.mozilla.firefox/ modules: - name: bitwarden-desktop diff --git a/apps/desktop/src/app/accounts/settings.component.ts b/apps/desktop/src/app/accounts/settings.component.ts index 83c982fbaba..134f2ee64a1 100644 --- a/apps/desktop/src/app/accounts/settings.component.ts +++ b/apps/desktop/src/app/accounts/settings.component.ts @@ -693,22 +693,6 @@ export class SettingsComponent implements OnInit, OnDestroy { ipc.platform.allowBrowserintegrationOverride || ipc.platform.isDev; if (!skipSupportedPlatformCheck) { - if ( - ipc.platform.deviceType === DeviceType.MacOsDesktop && - !this.platformUtilsService.isMacAppStore() - ) { - await this.dialogService.openSimpleDialog({ - title: { key: "browserIntegrationUnsupportedTitle" }, - content: { key: "browserIntegrationMasOnlyDesc" }, - acceptButtonText: { key: "ok" }, - cancelButtonText: null, - type: "warning", - }); - - this.form.controls.enableBrowserIntegration.setValue(false); - return; - } - if (ipc.platform.isWindowsStore) { await this.dialogService.openSimpleDialog({ title: { key: "browserIntegrationUnsupportedTitle" }, @@ -721,19 +705,6 @@ export class SettingsComponent implements OnInit, OnDestroy { this.form.controls.enableBrowserIntegration.setValue(false); return; } - - if (ipc.platform.isSnapStore || ipc.platform.isFlatpak) { - await this.dialogService.openSimpleDialog({ - title: { key: "browserIntegrationUnsupportedTitle" }, - content: { key: "browserIntegrationLinuxDesc" }, - acceptButtonText: { key: "ok" }, - cancelButtonText: null, - type: "warning", - }); - - this.form.controls.enableBrowserIntegration.setValue(false); - return; - } } await this.desktopSettingsService.setBrowserIntegrationEnabled( diff --git a/apps/desktop/src/locales/en/messages.json b/apps/desktop/src/locales/en/messages.json index 1ae304287c7..6b2516ecf1a 100644 --- a/apps/desktop/src/locales/en/messages.json +++ b/apps/desktop/src/locales/en/messages.json @@ -2115,15 +2115,9 @@ "browserIntegrationErrorDesc": { "message": "An error has occurred while enabling browser integration." }, - "browserIntegrationMasOnlyDesc": { - "message": "Unfortunately browser integration is only supported in the Mac App Store version for now." - }, "browserIntegrationWindowsStoreDesc": { "message": "Unfortunately browser integration is currently not supported in the Microsoft Store version." }, - "browserIntegrationLinuxDesc": { - "message": "Unfortunately browser integration is currently not supported in the linux version." - }, "enableBrowserIntegrationFingerprint": { "message": "Require verification for browser integration" }, diff --git a/apps/desktop/src/main/native-messaging.main.ts b/apps/desktop/src/main/native-messaging.main.ts index 27b9378895e..fb93c9e41ec 100644 --- a/apps/desktop/src/main/native-messaging.main.ts +++ b/apps/desktop/src/main/native-messaging.main.ts @@ -110,7 +110,7 @@ export class NativeMessagingMain { } }); - for (const path in this.ipcServer.getPaths()) { + for (const path of this.ipcServer.getPaths()) { this.logService.info("Native messaging server started at:", path); } @@ -197,17 +197,33 @@ export class NativeMessagingMain { break; } case "linux": { + // Because on linux, th path inside the sandbox is different, and we want to support: + // Flatpak App, Unsandboxed App, Flatpak Browser, Unsandboxed Browser, Snap App, Unsandboxed App + // and any combination of the above, we copy the binary to the applications native-messaging-hosts path + // so that a canonical path to put in the manifest can be used. + + // Unsandboxed browser for (const [key, value] of Object.entries(this.getLinuxNMHS())) { if (existsSync(value)) { + let nhmsPath = path.join(value, "NativeMessagingHosts"); + if (key === "Firefox") { + nhmsPath = path.join(value, "native-messaging-hosts"); + } + const browserBinaryPath = path.join(nhmsPath, ".bitwarden_desktop_proxy"); + + await fs.mkdir(nhmsPath, { recursive: true }); + await fs.copyFile(binaryPath, browserBinaryPath); + this.logService.info(`Copied ${binaryPath} to ${browserBinaryPath}`); + if (key === "Firefox") { await this.writeManifest( - path.join(value, "native-messaging-hosts", "com.8bit.bitwarden.json"), - await this.generateFirefoxJson(binaryPath), + path.join(nhmsPath, "com.8bit.bitwarden.json"), + await this.generateFirefoxJson(browserBinaryPath), ); } else { await this.writeManifest( - path.join(value, "NativeMessagingHosts", "com.8bit.bitwarden.json"), - await this.generateChromeJson(binaryPath), + path.join(nhmsPath, "com.8bit.bitwarden.json"), + await this.generateChromeJson(browserBinaryPath), ); } } else { @@ -216,11 +232,9 @@ export class NativeMessagingMain { } for (const [key, value] of Object.entries(this.getFlatpakNMHS())) { - this.logService.info(`Flatpak ${key} found at ${value}`); if (existsSync(value)) { - this.logService.info(`Flatpak ${key} found at ${value}`); const sandboxedProxyBinaryPath = path.join(value, "bitwarden_desktop_proxy"); - await fs.copyFile(binaryPath, path.join(value, "bitwarden_desktop_proxy")); + await fs.copyFile(binaryPath, path.join(value, ".bitwarden_desktop_proxy")); this.logService.info( `Copied ${sandboxedProxyBinaryPath} to ${path.join(value, "bitwarden_desktop_proxy")}`, ); @@ -372,6 +386,9 @@ export class NativeMessagingMain { private getFlatpakNMHS() { return { Firefox: `${this.homedir()}/.var/app/org.mozilla.firefox/.mozilla/native-messaging-hosts/`, + Chrome: `${this.homedir()}/.var/app/com.google.Chrome/.config/google-chrome/`, + Chromium: `${this.homedir()}/.var/app/org.chromium.Chromium/.config/chromium/`, + "Microsoft Edge": `${this.homedir()}/.var/app/com.microsoft.Edge/.config/microsoft-edge/`, }; } diff --git a/apps/desktop/src/utils.ts b/apps/desktop/src/utils.ts index c798faac36e..57713627e16 100644 --- a/apps/desktop/src/utils.ts +++ b/apps/desktop/src/utils.ts @@ -74,7 +74,7 @@ export function isWindowsPortable() { /** * We block the browser integration on some unsupported platforms, which also - * blocks partially supported platforms (mac .dmg in dev builds) / prevents + * blocks partially supported platforms / prevents * experimenting with the feature for QA. So this env var allows overriding * the block. */