@@ -134,6 +134,13 @@ func getServerConfigFromEnv() (*auth_providers.Server, error) {
134134 apiPath , aOk := os .LookupEnv (auth_providers .EnvKeyfactorAPIPath )
135135 clientId , cOk := os .LookupEnv (auth_providers .EnvKeyfactorClientID )
136136 clientSecret , csOk := os .LookupEnv (auth_providers .EnvKeyfactorClientSecret )
137+ audience , _ := os .LookupEnv (auth_providers .EnvKeyfactorAuthAudience )
138+ scopesCSV , _ := os .LookupEnv (auth_providers .EnvKeyfactorAuthScopes )
139+ var scopes []string
140+ if scopesCSV != "" {
141+ scopes = strings .Split (scopesCSV , "," )
142+ }
143+
137144 tokenUrl , tOk := os .LookupEnv (auth_providers .EnvKeyfactorAuthTokenURL )
138145 skipVerify , svOk := os .LookupEnv (auth_providers .EnvKeyfactorSkipVerify )
139146 var skipVerifyBool bool
@@ -160,24 +167,44 @@ func getServerConfigFromEnv() (*auth_providers.Server, error) {
160167 }
161168
162169 if isBasicAuth {
163- log .Debug ().
164- Str ("username" , username ).
165- Str ("password" , hashSecretValue (password )).
166- Str ("domain" , domain ).
167- Str ("hostname" , hostname ).
170+
171+ log .Debug ().Str ("hostname" , hostname ).
168172 Str ("apiPath" , apiPath ).
169173 Bool ("skipVerify" , skipVerifyBool ).
170- Msg ("call: basicAuthNoParamsConfig.Authenticate() " )
174+ Msg ("setting up basic auth client base configuration " )
171175 basicAuthNoParamsConfig .WithCommandHostName (hostname ).
172176 WithCommandAPIPath (apiPath ).
173177 WithSkipVerify (skipVerifyBool )
174178
175- bErr := basicAuthNoParamsConfig .
179+ log .Debug ().
180+ Str ("username" , username ).
181+ Str ("password" , hashSecretValue (password )).
182+ Str ("domain" , domain ).
183+ Msg ("setting up basic auth configuration" )
184+ _ = basicAuthNoParamsConfig .
176185 WithUsername (username ).
177186 WithPassword (password ).
178- WithDomain (domain ).
179- Authenticate ()
180- log .Debug ().Msg ("complete: basicAuthNoParamsConfig.Authenticate()" )
187+ WithDomain (domain )
188+
189+ log .Debug ().
190+ Str ("username" , basicAuthNoParamsConfig .Username ).
191+ Str ("password" , hashSecretValue (password )).
192+ Str ("domain" , basicAuthNoParamsConfig .Domain ).
193+ Str ("hostname" , basicAuthNoParamsConfig .CommandHostName ).
194+ Str ("apiPath" , basicAuthNoParamsConfig .CommandAPIPath ).
195+ Bool ("skipVerify" , basicAuthNoParamsConfig .CommandAuthConfig .SkipVerify ).
196+ Msg (fmt .Sprintf ("%s basicAuthNoParamsConfig.Authenticate()" , DebugFuncCall ))
197+
198+ bErr := basicAuthNoParamsConfig .Authenticate ()
199+ log .Debug ().
200+ Str ("username" , basicAuthNoParamsConfig .Username ).
201+ Str ("password" , hashSecretValue (password )).
202+ Str ("domain" , basicAuthNoParamsConfig .Domain ).
203+ Str ("hostname" , basicAuthNoParamsConfig .CommandHostName ).
204+ Str ("apiPath" , basicAuthNoParamsConfig .CommandAPIPath ).
205+ Bool ("skipVerify" , basicAuthNoParamsConfig .CommandAuthConfig .SkipVerify ).
206+ Msg ("complete: basicAuthNoParamsConfig.Authenticate()" )
207+
181208 if bErr != nil {
182209 log .Error ().Err (bErr ).Msg ("unable to authenticate with provided credentials" )
183210 return nil , bErr
@@ -186,16 +213,36 @@ func getServerConfigFromEnv() (*auth_providers.Server, error) {
186213 return basicAuthNoParamsConfig .GetServerConfig (), nil
187214 } else if isOAuth {
188215 log .Debug ().
189- Str ("clientId" , clientId ).
190- Str ("clientSecret" , hashSecretValue (clientSecret )).
191- Str ("tokenUrl" , tokenUrl ).
192216 Str ("hostname" , hostname ).
193217 Str ("apiPath" , apiPath ).
194218 Bool ("skipVerify" , skipVerifyBool ).
195- Msg ("call: oAuthNoParamsConfig.Authenticate() " )
219+ Msg ("setting up oAuth client base configuration " )
196220 _ = oAuthNoParamsConfig .CommandAuthConfig .WithCommandHostName (hostname ).
197221 WithCommandAPIPath (apiPath ).
198222 WithSkipVerify (skipVerifyBool )
223+
224+ log .Debug ().
225+ Str ("clientId" , clientId ).
226+ Str ("clientSecret" , hashSecretValue (clientSecret )).
227+ Str ("tokenUrl" , tokenUrl ).
228+ Str ("audience" , audience ).
229+ Strs ("scopes" , scopes ).
230+ Msg ("setting up oAuth configuration" )
231+ _ = oAuthNoParamsConfig .WithClientId (clientId ).
232+ WithClientSecret (clientSecret ).
233+ WithTokenUrl (tokenUrl ).
234+ WithAudience (audience ).
235+ WithScopes (scopes )
236+
237+ log .Debug ().
238+ Str ("clientId" , oAuthNoParamsConfig .ClientID ).
239+ Str ("clientSecret" , hashSecretValue (oAuthNoParamsConfig .ClientSecret )).
240+ Str ("tokenUrl" , oAuthNoParamsConfig .TokenURL ).
241+ Str ("hostname" , oAuthNoParamsConfig .CommandHostName ).
242+ Str ("apiPath" , oAuthNoParamsConfig .CommandAPIPath ).
243+ Bool ("skipVerify" , oAuthNoParamsConfig .SkipVerify ).
244+ Str ("caCert" , oAuthNoParamsConfig .CommandCACert ).
245+ Msg (fmt .Sprintf ("%s oAuthNoParamsConfig.Authenticate()" , DebugFuncCall ))
199246 oErr := oAuthNoParamsConfig .Authenticate ()
200247 log .Debug ().Msg ("complete: oAuthNoParamsConfig.Authenticate()" )
201248 if oErr != nil {
0 commit comments