client_secret_cmd

This commit is contained in:
abs3nt 2023-01-10 13:38:28 -08:00
parent 2a0b47f7cd
commit 7d45a3dd4c
2 changed files with 13 additions and 2 deletions

View File

@ -4,7 +4,9 @@ import (
"context" "context"
"fmt" "fmt"
"os" "os"
"os/exec"
"path/filepath" "path/filepath"
"strings"
"gospt/internal/auth" "gospt/internal/auth"
"gospt/internal/config" "gospt/internal/config"
@ -84,4 +86,12 @@ func initConfig() {
if err := loader.Load(); err != nil { if err := loader.Load(); err != nil {
panic(err) 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))
}
} }

View File

@ -3,4 +3,5 @@ package config
var Values struct { var Values struct {
ClientId string `yaml:"client_id"` ClientId string `yaml:"client_id"`
ClientSecret string `yaml:"client_secret"` ClientSecret string `yaml:"client_secret"`
ClientSecretCmd string `yaml:"client_secret_cmd"`
} }