goldwarden-vaultwarden-bitw.../main.go

65 lines
1.9 KiB
Go
Raw Normal View History

2023-07-17 03:23:26 +02:00
package main
import (
2023-08-04 00:44:15 +02:00
"fmt"
"os"
"strings"
2023-08-04 00:44:15 +02:00
"time"
2023-08-21 18:37:34 +02:00
"github.com/quexten/goldwarden/agent/config"
"github.com/quexten/goldwarden/browserbiometrics"
2023-07-17 03:23:26 +02:00
"github.com/quexten/goldwarden/cmd"
)
func main() {
if len(os.Args) > 1 && strings.Contains(os.Args[1], "com.8bit.bitwarden.json") {
browserbiometrics.Main()
return
}
2023-08-21 18:37:34 +02: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{
DisableAuth: os.Getenv("GOLDWARDEN_WEBSOCKET_DISABLED") == "true",
DisablePinRequirement: os.Getenv("GOLDWARDEN_PIN_REQUIREMENT_DISABLED") == "true",
DoNotPersistConfig: os.Getenv("GOLDWARDEN_DO_NOT_PERSIST_CONFIG") == "true",
ApiURI: os.Getenv("GOLDWARDEN_API_URI"),
IdentityURI: os.Getenv("GOLDWARDEN_IDENTITY_URI"),
SingleProcess: os.Getenv("GOLDWARDEN_SINGLE_PROCESS") == "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"),
ConfigDirectory: configPath,
}
if runtimeConfig.SingleProcess {
runtimeConfig.DisablePinRequirement = true
runtimeConfig.DisableAuth = true
}
if runtimeConfig.DisablePinRequirement {
runtimeConfig.DoNotPersistConfig = true
}
if runtimeConfig.DisableAuth {
os.Setenv("GOLDWARDEN_SYSTEM_AUTH_DISABLED", "true")
}
if !cmd.IsPolkitSetup() && !runtimeConfig.DisableAuth {
2023-08-04 00:44:15 +02:00
fmt.Println("Polkit is not setup. Run 'goldwarden setup polkit' to set it up.")
time.Sleep(3 * time.Second)
}
2023-08-21 18:37:34 +02:00
cmd.Execute(runtimeConfig)
2023-07-17 03:23:26 +02:00
}