goldwarden/main.go

56 lines
1.9 KiB
Go
Raw Normal View History

2023-07-17 04:23:26 +03:00
package main
import (
"os"
"strings"
2024-05-04 02:06:24 +03:00
"github.com/quexten/goldwarden/cli/agent/config"
"github.com/quexten/goldwarden/cli/browserbiometrics"
"github.com/quexten/goldwarden/cli/cmd"
2023-07-17 04:23:26 +03:00
)
func main() {
2023-08-21 19:37:34 +03:00
var configPath string
if path, found := os.LookupEnv("GOLDWARDEN_CONFIG_DIRECTORY"); found {
configPath = path
} else {
configPath = config.DefaultConfigPath
}
userHome, _ := os.UserHomeDir()
configPath = strings.ReplaceAll(configPath, "~", userHome)
runtimeConfig := config.RuntimeConfig{
2024-02-09 21:37:09 +03:00
WebsocketDisabled: os.Getenv("GOLDWARDEN_WEBSOCKET_DISABLED") == "true",
DisableSSHAgent: os.Getenv("GOLDWARDEN_SSH_AGENT_DISABLED") == "true",
DoNotPersistConfig: os.Getenv("GOLDWARDEN_DO_NOT_PERSIST_CONFIG") == "true",
DeviceUUID: os.Getenv("GOLDWARDEN_DEVICE_UUID"),
AuthMethod: os.Getenv("GOLDWARDEN_AUTH_METHOD"),
User: os.Getenv("GOLDWARDEN_AUTH_USER"),
Password: os.Getenv("GOLDWARDEN_AUTH_PASSWORD"),
Pin: os.Getenv("GOLDWARDEN_PIN"),
UseMemguard: os.Getenv("GOLDWARDEN_NO_MEMGUARD") != "true",
SSHAgentSocketPath: os.Getenv("GOLDWARDEN_SSH_AUTH_SOCK"),
GoldwardenSocketPath: os.Getenv("GOLDWARDEN_SOCKET_PATH"),
DaemonAuthToken: os.Getenv("GOLDWARDEN_DAEMON_AUTH_TOKEN"),
2023-08-21 19:37:34 +03:00
ConfigDirectory: configPath,
}
2024-02-18 08:08:37 +03:00
_, err := os.Stat("/.flatpak-info")
2023-12-30 20:53:01 +03:00
isFlatpak := err == nil
if isFlatpak {
userHome, _ := os.UserHomeDir()
runtimeConfig.ConfigDirectory = userHome + "/.var/app/com.quexten.Goldwarden/config/goldwarden.json"
runtimeConfig.ConfigDirectory = strings.ReplaceAll(runtimeConfig.ConfigDirectory, "~", userHome)
}
if len(os.Args) > 1 && (strings.Contains(os.Args[1], "com.8bit.bitwarden.json") || strings.Contains(os.Args[1], "chrome-extension://")) {
2024-03-15 18:22:45 +03:00
err = browserbiometrics.Main(&runtimeConfig)
if err != nil {
panic(err)
}
}
2023-08-21 19:37:34 +03:00
cmd.Execute(runtimeConfig)
2023-07-17 04:23:26 +03:00
}