Add flatpak biometric setup

This commit is contained in:
Bernd Schoolmann 2024-02-17 12:28:04 +01:00
parent 3b2d1fcf11
commit 623fdcb719
No known key found for this signature in database
2 changed files with 41 additions and 9 deletions

View File

@ -108,19 +108,40 @@ func detectAndInstallBrowsers(startPath string) error {
return nil
}
binPath, err := os.Executable()
if info.IsDir() && info.Name() == "native-messaging-hosts" {
fmt.Printf("Found mozilla-like browser: %s\n", path)
os.Chown(path+"/com.8bit.bitwarden.json", 7, 7)
os.Remove(path + "/com.8bit.bitwarden.json")
os.Chown(path+"/goldwarden-proxy.sh", 7, 7)
os.Remove(path + "/goldwarden-proxy.sh")
manifest := strings.Replace(templateMozilla, "PATH", path+"/goldwarden-proxy.sh", 1)
err = os.WriteFile(path+"/com.8bit.bitwarden.json", []byte(manifest), 0444)
if err != nil {
return err
}
err = os.WriteFile(path+"/goldwarden-proxy.sh", []byte(proxyScript), 0755)
if err != nil {
return err
}
if info.IsDir() && info.Name() == "native-messaging-hosts" {
fmt.Printf("Found mozilla-like browser: %s\n", path)
manifest := strings.Replace(templateMozilla, "PATH", binPath, 1)
err = os.WriteFile(path+"/com.8bit.bitwarden.json", []byte(manifest), 0644)
} else if info.IsDir() && info.Name() == "NativeMessagingHosts" {
fmt.Printf("Found chrome-like browser: %s\n", path)
manifest := strings.Replace(templateChrome, "PATH", binPath, 1)
err = os.WriteFile(path+"/com.8bit.bitwarden.json", []byte(manifest), 0644)
os.Chown(path+"/com.8bit.bitwarden.json", 7, 7)
os.Remove(path + "/com.8bit.bitwarden.json")
os.Chown(path+"/goldwarden-proxy.sh", 7, 7)
os.Remove(path + "/goldwarden-proxy.sh")
manifest := strings.Replace(templateChrome, "PATH", path+"/goldwarden-proxy.sh", 1)
err = os.WriteFile(path+"/com.8bit.bitwarden.json", []byte(manifest), 0444)
if err != nil {
return err
}
err = os.WriteFile(path+"/goldwarden-proxy.sh", []byte(proxyScript), 0755)
if err != nil {
return err
}
}
return err

View File

@ -21,3 +21,14 @@ const templateChrome = `{
"chrome-extension://ccnckbpmaceehanjmeomladnmlffdjgn/"
]
}`
const proxyScript = `#!/bin/bash
# Check if the "com.quexten.Goldwarden" Flatpak is installed
if flatpak list | grep -q "com.quexten.Goldwarden"; then
flatpak run --command=goldwarden com.quexten.Goldwarden "$@"
else
# If not installed, attempt to run the local version
goldwarden "$@"
fi
`