From 5aa407d832d2e8dd9c64c62d058b1caace916977 Mon Sep 17 00:00:00 2001 From: Ben McClelland Date: Mon, 1 Sep 2025 19:30:30 -0700 Subject: [PATCH] cleanup: ipa iam server debug logging done with debuglogger Move the debug output to the standard debuglogger for more consistency across the project. --- auth/iam.go | 3 +-- auth/iam_ipa.go | 17 +++++------------ cmd/versitygw/main.go | 9 +-------- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/auth/iam.go b/auth/iam.go index a702c65..c0aa5d1 100644 --- a/auth/iam.go +++ b/auth/iam.go @@ -144,7 +144,6 @@ type Opts struct { IpaUser string IpaPassword string IpaInsecure bool - IpaDebug bool } func New(o *Opts) (IAMService, error) { @@ -171,7 +170,7 @@ func New(o *Opts) (IAMService, error) { o.VaultServerCert, o.VaultClientCert, o.VaultClientCertKey) fmt.Printf("initializing Vault IAM with %q\n", o.VaultEndpointURL) case o.IpaHost != "": - svc, err = NewIpaIAMService(o.RootAccount, o.IpaHost, o.IpaVaultName, o.IpaUser, o.IpaPassword, o.IpaInsecure, o.IpaDebug) + svc, err = NewIpaIAMService(o.RootAccount, o.IpaHost, o.IpaVaultName, o.IpaUser, o.IpaPassword, o.IpaInsecure) fmt.Printf("initializing IPA IAM with %q\n", o.IpaHost) default: // if no iam options selected, default to the single user mode diff --git a/auth/iam_ipa.go b/auth/iam_ipa.go index 6f23a67..0fa8aab 100644 --- a/auth/iam_ipa.go +++ b/auth/iam_ipa.go @@ -26,7 +26,6 @@ import ( "errors" "fmt" "io" - "log" "net" "net/http" "net/http/cookiejar" @@ -36,6 +35,8 @@ import ( "strings" "syscall" "time" + + "github.com/versity/versitygw/debuglogger" ) const IpaVersion = "2.254" @@ -49,13 +50,12 @@ type IpaIAMService struct { username string password string kraTransportKey *rsa.PublicKey - debug bool rootAcc Account } var _ IAMService = &IpaIAMService{} -func NewIpaIAMService(rootAcc Account, host, vaultName, username, password string, isInsecure, debug bool) (*IpaIAMService, error) { +func NewIpaIAMService(rootAcc Account, host, vaultName, username, password string, isInsecure bool) (*IpaIAMService, error) { ipa := IpaIAMService{ id: 0, version: IpaVersion, @@ -63,7 +63,6 @@ func NewIpaIAMService(rootAcc Account, host, vaultName, username, password strin vaultName: vaultName, username: username, password: password, - debug: debug, rootAcc: rootAcc, } jar, err := cookiejar.New(nil) @@ -311,7 +310,7 @@ func (ipa *IpaIAMService) rpcInternal(req rpcRequest) (rpcResponse, error) { return rpcResponse{}, err } - ipa.log(fmt.Sprintf("%v", req)) + debuglogger.IAMLogf("IPA request: %v", req) httpReq.Header.Set("referer", fmt.Sprintf("%s/ipa", ipa.host)) httpReq.Header.Set("Content-Type", "application/json") @@ -338,7 +337,7 @@ func (ipa *IpaIAMService) rpcInternal(req rpcRequest) (rpcResponse, error) { defer httpResp.Body.Close() bytes, err := io.ReadAll(httpResp.Body) - ipa.log(string(bytes)) + debuglogger.IAMLogf("IPA response (%v): %v", err, string(bytes)) if err != nil { return rpcResponse{}, err } @@ -495,9 +494,3 @@ func (b *Base64Encoded) UnmarshalJSON(data []byte) error { *b, err = base64.StdEncoding.DecodeString(intermediate) return err } - -func (ipa *IpaIAMService) log(msg string) { - if ipa.debug { - log.Println(msg) - } -} diff --git a/cmd/versitygw/main.go b/cmd/versitygw/main.go index 635408a..126a80e 100644 --- a/cmd/versitygw/main.go +++ b/cmd/versitygw/main.go @@ -81,7 +81,7 @@ var ( dogstatsServers string ipaHost, ipaVaultName string ipaUser, ipaPassword string - ipaInsecure, ipaDebug bool + ipaInsecure bool iamDebug bool ) @@ -594,12 +594,6 @@ func initFlags() []cli.Flag { EnvVars: []string{"VGW_IPA_INSECURE"}, Destination: &ipaInsecure, }, - &cli.BoolFlag{ - Name: "ipa-debug", - Usage: "FreeIPA IAM debug output", - EnvVars: []string{"VGW_IPA_DEBUG"}, - Destination: &ipaDebug, - }, } } @@ -707,7 +701,6 @@ func runGateway(ctx context.Context, be backend.Backend) error { IpaUser: ipaUser, IpaPassword: ipaPassword, IpaInsecure: ipaInsecure, - IpaDebug: ipaDebug, }) if err != nil { return fmt.Errorf("setup iam: %w", err)