Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cloud-provisioning): Fixes graphql client initialization in cloud connector #477

Merged
merged 1 commit into from
May 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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