From 7d45a3dd4c3c537e1c64d03156d28ecb677e723d Mon Sep 17 00:00:00 2001 From: abs3nt Date: Tue, 10 Jan 2023 13:38:28 -0800 Subject: [PATCH] client_secret_cmd --- cmd/root.go | 10 ++++++++++ internal/config/config.go | 5 +++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index dd2011f..b6540d8 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -4,7 +4,9 @@ import ( "context" "fmt" "os" + "os/exec" "path/filepath" + "strings" "gospt/internal/auth" "gospt/internal/config" @@ -84,4 +86,12 @@ func initConfig() { if err := loader.Load(); err != nil { panic(err) } + if config.Values.ClientSecretCmd != "" { + args := strings.Fields(config.Values.ClientSecretCmd) + secret, err := exec.Command(args[0], args[1:]...).Output() + if err != nil { + panic(err) + } + config.Values.ClientSecret = strings.TrimSpace(string(secret)) + } } diff --git a/internal/config/config.go b/internal/config/config.go index aebac1d..8a47056 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -1,6 +1,7 @@ package config var Values struct { - ClientId string `yaml:"client_id"` - ClientSecret string `yaml:"client_secret"` + ClientId string `yaml:"client_id"` + ClientSecret string `yaml:"client_secret"` + ClientSecretCmd string `yaml:"client_secret_cmd"` }