Merge branch 'main' into browser-err
This commit is contained in:
commit
3323326920
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"name": "com.8bit.bitwarden",
|
||||
"description": "Bitwarden desktop <-> browser bridge",
|
||||
"path": "@PATH@",
|
||||
"type": "stdio",
|
||||
"allowed_origins": [
|
||||
"chrome-extension://nngceckbapebfimnlniiiahkandclblb/",
|
||||
"chrome-extension://jbkfoedolllekgbhcbcoahefnbanhhlh/",
|
||||
"chrome-extension://ccnckbpmaceehanjmeomladnmlffdjgn/"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env 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
|
|
@ -1,6 +1,7 @@
|
|||
package browserbiometrics
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -10,6 +11,15 @@ import (
|
|||
"github.com/quexten/goldwarden/browserbiometrics/logging"
|
||||
)
|
||||
|
||||
//go:embed mozilla-com.8bit.bitwarden.json
|
||||
var templateMozilla string
|
||||
|
||||
//go:embed chrome-com.8bit.bitwarden.json
|
||||
var templateChrome string
|
||||
|
||||
//go:embed goldwarden-proxy.sh
|
||||
var proxyScript string
|
||||
|
||||
var chromiumPaths = []string{
|
||||
"~/.config/google-chrome/",
|
||||
"~/.config/google-chrome-beta/",
|
||||
|
@ -116,13 +126,25 @@ func detectAndInstallBrowsers(startPath string) error {
|
|||
fmt.Printf("Found mozilla-like browser: %s\n", path)
|
||||
|
||||
fmt.Println("Removing old manifest and proxy script")
|
||||
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")
|
||||
err = os.Chown(path+"/com.8bit.bitwarden.json", 7, 7)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = os.Remove(path + "/com.8bit.bitwarden.json")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = os.Chown(path+"/goldwarden-proxy.sh", 7, 7)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = os.Remove(path + "/goldwarden-proxy.sh")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("Writing new manifest")
|
||||
manifest := strings.Replace(templateMozilla, "PATH", path+"/goldwarden-proxy.sh", 1)
|
||||
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
|
||||
|
@ -137,13 +159,25 @@ func detectAndInstallBrowsers(startPath string) error {
|
|||
fmt.Printf("Found chrome-like browser: %s\n", path)
|
||||
|
||||
fmt.Println("Removing old manifest and proxy script")
|
||||
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")
|
||||
err = os.Chown(path+"/com.8bit.bitwarden.json", 7, 7)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = os.Remove(path + "/com.8bit.bitwarden.json")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = os.Chown(path+"/goldwarden-proxy.sh", 7, 7)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = os.Remove(path + "/goldwarden-proxy.sh")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("Writing new manifest")
|
||||
manifest := strings.Replace(templateChrome, "PATH", path+"/goldwarden-proxy.sh", 1)
|
||||
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
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
package browserbiometrics
|
||||
|
||||
const templateMozilla = `{
|
||||
"name": "com.8bit.bitwarden",
|
||||
"description": "Bitwarden desktop <-> browser bridge",
|
||||
"path": "PATH",
|
||||
"type": "stdio",
|
||||
"allowed_extensions": [
|
||||
"{446900e4-71c2-419f-a6a7-df9c091e268b}"
|
||||
]
|
||||
}`
|
||||
|
||||
const templateChrome = `{
|
||||
"name": "com.8bit.bitwarden",
|
||||
"description": "Bitwarden desktop <-> browser bridge",
|
||||
"path": "PATH",
|
||||
"type": "stdio",
|
||||
"allowed_origins": [
|
||||
"chrome-extension://nngceckbapebfimnlniiiahkandclblb/",
|
||||
"chrome-extension://jbkfoedolllekgbhcbcoahefnbanhhlh/",
|
||||
"chrome-extension://ccnckbpmaceehanjmeomladnmlffdjgn/"
|
||||
]
|
||||
}`
|
||||
|
||||
const proxyScript = `#!/usr/bin/env 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
|
||||
`
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"name": "com.8bit.bitwarden",
|
||||
"description": "Bitwarden desktop <-> browser bridge",
|
||||
"path": "@PATH@",
|
||||
"type": "stdio",
|
||||
"allowed_extensions": [
|
||||
"{446900e4-71c2-419f-a6a7-df9c091e268b}"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
[Unit]
|
||||
Description="Goldwarden daemon"
|
||||
After=graphical-session.target
|
||||
|
||||
[Service]
|
||||
ExecStart=@BINARY_PATH@ daemonize
|
||||
|
||||
[Install]
|
||||
WantedBy=graphical-session.target
|
|
@ -3,6 +3,7 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
@ -81,15 +82,8 @@ var polkitCmd = &cobra.Command{
|
|||
},
|
||||
}
|
||||
|
||||
const SYSTEMD_SERVICE = `[Unit]
|
||||
Description="Goldwarden daemon"
|
||||
After=graphical-session.target
|
||||
|
||||
[Service]
|
||||
ExecStart=BINARY_PATH daemonize
|
||||
|
||||
[Install]
|
||||
WantedBy=graphical-session.target`
|
||||
//go:embed goldwarden.service
|
||||
var systemdService string
|
||||
|
||||
func setupSystemd() {
|
||||
if isRoot() {
|
||||
|
@ -107,7 +101,7 @@ func setupSystemd() {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
_, err = file.WriteString(strings.ReplaceAll(SYSTEMD_SERVICE, "BINARY_PATH", path))
|
||||
_, err = file.WriteString(strings.ReplaceAll(systemdService, "@BINARY_PATH@", path))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue