Use go's embed to have access to the plain files

This makes it pretty easy for distros to install the files already to
the correct positions
This commit is contained in:
Sandro Jäckel 2024-03-15 15:38:41 +01:00
parent c134a0e61d
commit 86d4f907fb
No known key found for this signature in database
GPG Key ID: 3AF5A43A3EECC2E5
7 changed files with 52 additions and 44 deletions

View File

@ -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/"
]
}

View File

@ -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

View File

@ -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/",

View File

@ -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
`

View File

@ -0,0 +1,9 @@
{
"name": "com.8bit.bitwarden",
"description": "Bitwarden desktop <-> browser bridge",
"path": "@PATH@",
"type": "stdio",
"allowed_extensions": [
"{446900e4-71c2-419f-a6a7-df9c091e268b}"
]
}

9
cmd/goldwarden.service Normal file
View File

@ -0,0 +1,9 @@
[Unit]
Description="Goldwarden daemon"
After=graphical-session.target
[Service]
ExecStart=@BINARY_PATH@ daemonize
[Install]
WantedBy=graphical-session.target

View File

@ -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)
}
file.WriteString(strings.ReplaceAll(SYSTEMD_SERVICE, "BINARY_PATH", path))
file.WriteString(strings.ReplaceAll(systemdService, "@BINARY_PATH@", path))
file.Close()
userDirectory := os.Getenv("HOME")