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

GitOps API's Don't Read ApiKey from Client #200

Open
steve-gray opened this issue Oct 23, 2022 · 0 comments
Open

GitOps API's Don't Read ApiKey from Client #200

steve-gray opened this issue Oct 23, 2022 · 0 comments

Comments

@steve-gray
Copy link

steve-gray commented Oct 23, 2022

Trying to debug some issues with Terraform module for Harness, and found that after trying to use the underlying SDK for Go directly myself that it suffers from the same problem I was seeing: 401 unauthorized.

Looking into the various underlying operations, such as GetClusterList we see the auth code is trying to read from the context:

	if ctx != nil {
		// API Key Authentication
		if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
			var key string
			if auth.Prefix != "" {
				key = auth.Prefix + " " + auth.Key
			} else {
				key = auth.Key
			}
			localVarHeaderParams["x-api-key"] = key

		}
	}

However, I'm not sure - but don't these need to also check the c.client.cfg.ApiKey? I'm passing the API key as a setup parameter to the nextgen API client, and it's being propagated into the struct for the clusters APIs etc. If I hack the code to manually set my API key from the structs API key, then it seems to work fine though. It seems like this is a pattern throughout the whole SDK.

Cross reference at: harness/terraform-provider-harness#260

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant