Skip to content

Commit

Permalink
fix(client): include baseconfig params and pass to authproviders
Browse files Browse the repository at this point in the history
  • Loading branch information
spbsoluble committed Oct 28, 2024
1 parent bfbe31f commit 5a50bf5
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions v3/api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,21 @@ func NewKeyfactorClient(cfg *auth_providers.Server, ctx *context.Context) (*Clie
initLogger(ctx)
client := Client{}
clientAuthType := cfg.GetAuthType()

baseConfig := auth_providers.CommandAuthConfig{
CommandHostName: cfg.Host,
CommandPort: cfg.Port,
CommandAPIPath: cfg.APIPath,
CommandCACert: cfg.CACertPath,
SkipVerify: cfg.SkipTLSVerify,
}

if clientAuthType == "basic" {
basicCfg := auth_providers.CommandAuthConfigBasic{
Username: cfg.Username,
Password: cfg.Password,
Domain: cfg.Domain,
CommandAuthConfig: baseConfig,
Username: cfg.Username,
Password: cfg.Password,
Domain: cfg.Domain,
}
aErr := basicCfg.Authenticate()
if aErr != nil {
Expand All @@ -151,9 +161,10 @@ func NewKeyfactorClient(cfg *auth_providers.Server, ctx *context.Context) (*Clie
return &client, nil
} else if clientAuthType == "oauth" {
oauthCfg := auth_providers.CommandConfigOauth{
ClientID: cfg.ClientID,
ClientSecret: cfg.ClientSecret,
TokenURL: cfg.OAuthTokenUrl,
CommandAuthConfig: baseConfig,
ClientID: cfg.ClientID,
ClientSecret: cfg.ClientSecret,
TokenURL: cfg.OAuthTokenUrl,
}
aErr := oauthCfg.Authenticate()
if aErr != nil {
Expand Down

0 comments on commit 5a50bf5

Please sign in to comment.