@@ -33,6 +33,7 @@ func newClient(config *keyfactorConfig, b *keyfactorBackend) (*keyfactorClient,
33
33
}
34
34
35
35
hostname := config .KeyfactorUrl
36
+ b .Logger ().Debug (fmt .Sprintf ("using hostname %s" , hostname ))
36
37
37
38
isBasicAuth := config .Username != "" && config .Password != ""
38
39
isOAuth := (config .ClientId != "" && config .ClientSecret != "" && config .TokenUrl != "" ) || config .AccessToken != ""
@@ -48,20 +49,44 @@ func newClient(config *keyfactorConfig, b *keyfactorBackend) (*keyfactorClient,
48
49
basicAuthConfig := & auth_providers.CommandAuthConfigBasic {}
49
50
50
51
if isBasicAuth {
51
- b .Logger ().Debug (fmt .Sprintf ("using basic auth with username %s, domain %s and password (hidden)" , config .Username , config .Domain ))
52
+ b .Logger ().Debug (
53
+ fmt .Sprintf (
54
+ "using basic auth with username %s, domain %s and password (hidden)" ,
55
+ config .Username ,
56
+ config .Domain ,
57
+ ),
58
+ )
59
+ b .Logger ().With (
60
+ "url" , hostname ,
61
+ "api_path" , config .CommandAPIPath ,
62
+ "skip_verify" , config .SkipTLSVerify ,
63
+ "ca_cert" , config .CommandCertPath ,
64
+ ).Debug ("setting base Command configuration" )
52
65
53
66
basicAuthConfig .WithCommandHostName (hostname ).
54
67
WithCommandAPIPath (config .CommandAPIPath ).
55
68
WithSkipVerify (config .SkipTLSVerify ).
56
69
WithCommandCACert (config .CommandCertPath )
70
+
71
+ b .Logger ().With (
72
+ "username" ,
73
+ config .Username ,
74
+ "domain" ,
75
+ config .Domain ,
76
+ "password" ,
77
+ "(hidden)" ,
78
+ ).Debug ("setting basic auth credentials" )
57
79
bErr := basicAuthConfig .
58
80
WithUsername (config .Username ).
59
81
WithPassword (config .Password ).
60
82
WithDomain (config .Domain ).
61
83
Authenticate ()
62
84
63
85
if bErr != nil {
64
- errMsg := fmt .Sprintf ("[ERROR] unable to authenticate with provided basic auth credentials: %s" , bErr .Error ())
86
+ errMsg := fmt .Sprintf (
87
+ "[ERROR] unable to authenticate with provided basic auth credentials: %s" ,
88
+ bErr .Error (),
89
+ )
65
90
b .Logger ().Error (errMsg )
66
91
return nil , bErr
67
92
} else {
@@ -77,12 +102,24 @@ func newClient(config *keyfactorConfig, b *keyfactorBackend) (*keyfactorClient,
77
102
}
78
103
79
104
} else if isOAuth {
80
- b .Logger ().Debug (fmt .Sprintf ("using oAuth authentication with client_id: %s, token_url %s and client_secret: (hidden)" , config .ClientId , config .TokenUrl ))
105
+ b .Logger ().With (
106
+ "url" , hostname ,
107
+ "api_path" , config .CommandAPIPath ,
108
+ "skip_verify" , config .SkipTLSVerify ,
109
+ "ca_cert" , config .CommandCertPath ,
110
+ ).Debug ("setting base Command configuration" )
81
111
_ = oAuthConfig .WithCommandHostName (hostname ).
82
112
WithCommandAPIPath (config .CommandAPIPath ).
83
113
WithSkipVerify (config .SkipTLSVerify ).
84
114
WithCommandCACert (config .CommandCertPath )
85
115
116
+ b .Logger ().Debug (
117
+ fmt .Sprintf (
118
+ "using oAuth authentication with client_id: %s, token_url %s and client_secret: (hidden)" ,
119
+ config .ClientId ,
120
+ config .TokenUrl ,
121
+ ),
122
+ )
86
123
oErr := oAuthConfig .
87
124
WithClientId (config .ClientId ).
88
125
WithClientSecret (config .ClientSecret ).
0 commit comments