Skip to content

Commit

Permalink
Merge pull request #477 from Venafi/fix-graphql-client
Browse files Browse the repository at this point in the history
fix(cloud-provisioning): Fixes graphql client initialization in cloud connector
  • Loading branch information
rvelaVenafi authored May 15, 2024
2 parents 81adb2c + 14c1588 commit 55e78bc
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions pkg/venafi/cloud/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,35 +141,30 @@ func (c *Connector) Authenticate(auth *endpoint.Authentication) error {
return fmt.Errorf("failed to authenticate: missing credentials")
}

//1. Access token. Assign it to connector and return
//1. Access token. Assign it to connector
if auth.AccessToken != "" {
c.accessToken = auth.AccessToken
return nil
}

//2. JWT and token URL. use it to request new access token
if auth.TokenURL != "" && auth.ExternalJWT != "" {
} else if auth.TokenURL != "" && auth.ExternalJWT != "" {
//2. JWT and token URL. use it to request new access token
tokenResponse, err := c.GetAccessToken(auth)
if err != nil {
return err
}
c.accessToken = tokenResponse.AccessToken
return nil
}

// 3. API key. Get user to test authentication
c.apiKey = auth.APIKey
url := c.getURL(urlResourceUserAccounts)
statusCode, status, body, err := c.request("GET", url, nil, true)
if err != nil {
return err
}
ud, err := parseUserDetailsResult(http.StatusOK, statusCode, status, body)
if err != nil {
return err
} else if auth.APIKey != "" {
// 3. API key. Get user to test authentication
c.apiKey = auth.APIKey
url := c.getURL(urlResourceUserAccounts)
statusCode, status, body, err := c.request("GET", url, nil, true)
if err != nil {
return err
}
ud, err := parseUserDetailsResult(http.StatusOK, statusCode, status, body)
if err != nil {
return err
}
c.user = ud
}
c.user = ud

c.cloudProvidersClient = cloudproviders.NewCloudProvidersClient(c.getURL(urlGraphql), c.getGraphqlHTTPClient())

return nil
Expand Down

0 comments on commit 55e78bc

Please sign in to comment.