From 47c9d48735e2b0c7701189f685e1dd63e064d977 Mon Sep 17 00:00:00 2001 From: David Allen Date: Sat, 20 Sep 2025 15:26:09 -0600 Subject: [PATCH] refactor: changed how plugin kwargs are sent and other minor changes --- cmd/download.go | 11 ++++++----- cmd/run.go | 1 + cmd/serve.go | 6 ++++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cmd/download.go b/cmd/download.go index 6c50c3f..c19a783 100644 --- a/cmd/download.go +++ b/cmd/download.go @@ -1,6 +1,7 @@ package cmd import ( + "encoding/base64" "fmt" "net/http" "net/url" @@ -15,10 +16,7 @@ import ( "github.com/spf13/cobra" ) -var ( - pluginArgs []string - pluginKWArgs kwargs.KWArgs = kwargs.KWArgs{} -) +var pluginKWArgs kwargs.KWArgs = kwargs.KWArgs{} var downloadCmd = cobra.Command{ Use: "download", Example: ` @@ -52,6 +50,7 @@ var downloadCmd = cobra.Command{ configPath, _ = cmd.Flags().GetString("config") cacertPath, _ = cmd.Flags().GetString("cacert") pluginNames, _ = cmd.Flags().GetStringSlice("plugins") + pluginArgs, _ = cmd.Flags().GetStringSlice("plugin-args") profileIDs, _ = cmd.Flags().GetStringSlice("profiles") extract, _ = cmd.Flags().GetBool("extract") removeArchive, _ = cmd.Flags().GetBool("remove-archive") @@ -75,7 +74,7 @@ var downloadCmd = cobra.Command{ query += "&args=" + url.QueryEscape(strings.Join(pluginArgs, ",")) } if len(pluginKWArgs) > 0 { - query += "&kwargs=" + url.QueryEscape(pluginKWArgs.String()) + query += "&kwargs=" + base64.RawURLEncoding.EncodeToString(pluginKWArgs.Bytes()) } log.Debug(). @@ -86,6 +85,8 @@ var downloadCmd = cobra.Command{ Str("output", outputPath). Strs("profiles", profileIDs). Strs("plugins", pluginNames). + Strs("args", pluginArgs). + Any("kwargs", pluginKWArgs). Send() if cacertPath != "" { diff --git a/cmd/run.go b/cmd/run.go index 846e560..e738e26 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -44,6 +44,7 @@ var runCmd = &cobra.Command{ keyfile, _ = cmd.Flags().GetString("keyfile") timeout, _ = cmd.Flags().GetInt("timeout") pluginNames, _ = cmd.Flags().GetStringSlice("plugins") + pluginArgs, _ = cmd.Flags().GetStringSlice("plugin-args") profileIDs, _ = cmd.Flags().GetStringSlice("profiles") extract, _ = cmd.Flags().GetBool("extract") removeArchive, _ = cmd.Flags().GetBool("remove-archive") diff --git a/cmd/serve.go b/cmd/serve.go index b723a02..fba854b 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -94,8 +94,10 @@ func init() { serveCmd.Flags().String("host", "localhost:5050", "Set the configurator server host (can be set with MAKESHIFT_HOST)") serveCmd.Flags().String("root", "./", "Set the root path to serve files (can be set with MAKESHIFT_ROOT)") serveCmd.Flags().IntP("timeout", "t", 60, "Set the timeout in seconds for requests (can be set with MAKESHIFT_TIMEOUT)") - serveCmd.Flags().String("cacert", "", "Set the CA certificate path to load (can be set with MAKESHIFT_CACERT)") - serveCmd.Flags().String("keyfile", "", "Set the CA key file to use (can be set with MAKESHIFT_KEYFILE)") + serveCmd.Flags().String("cacert", "", "Set the CA certificate path to load (can be set with MAKESHIFT_CACERT, only used if set with '--keyfile' flag)") + serveCmd.Flags().String("keyfile", "", "Set the CA key file to use (can be set with MAKESHIFT_KEYFILE, only used if set with '--cacert' flag)") + serveCmd.Flags().String("keyurl", "", "Set the JWKS remote host for JWT verification") + serveCmd.Flags().StringSlice("protect-routes", []string{}, "Set the routes to require authentication (uses default routes if not set with '--keyurl' flag)") serveCmd.MarkFlagsRequiredTogether("cacert", "keyfile")