-
Notifications
You must be signed in to change notification settings - Fork 64
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
Validate BaseUrl for orgs #41
Comments
I've been having trouble with your chef-client lib and hosted chef organizations. Specifically, I've noticed that when I assign the client from the package function and call a method, it replaces portions of my BaseUrl route and hosted chef-api returns an error. I have to add a fake 'endpoint' to my BaseUrl or else I get 403'd. Official Chef-API Docs say that in order to interact with their API, you need to prefix the endpoint with organizations/[orgname]/[function]
Here is my workaround, adding the "/foo" portion to get around the limitation. func Main() {
key := readKey()
url, org := setupChef()
baseurl := url + "/organizations/" + org + "/foo"
fmt.Println(baseurl)
client, err := chef.NewClient(&chef.Config{
Name: "sethmoore",
Key: string(key),
BaseURL: baseurl,
})
cookList, err := client.Cookbooks.List()
if err != nil {
fmt.Println("ERROR:", err)
}
} Without the "/foo" appended to BaseUrl, I get
I have yet to figure out how to workaround searching. |
@sethdmoore thanks for the detailed report. I haven't been actively working with a chef-server, but I always thought what you were trying would 'just work'. I think https://github.com/go-chef/chef/blob/master/http.go#L171 this line may be the culprit. If not it is probably in NewRequest. Search in itself is a wild beast. No surprise it didn't behave. |
I've seen this problem too, you can remove the 'foo' part, you just need a trailing /
|
@bigkraig is that it ? I can just detect / correct this or document it if so. |
It "worked for me" :) |
Thanks! This saved me from pulling my hair out. The trailing slash at the end of Client.BaseURL also worked for me. Otherwise my workaround was this ugly thing:
So my call to
|
Tested on Chef Server 12.3.1 with the examples/search.go and examples/cookbooks.go examples from 849dab5 Works just fine with the following client config where the baseURL trailing slash is present after the orgname, SSL verification is skipped, and the client name matches the valid user key.
|
Thanks, I think we should probably validate that then. |
This is also related to #54 |
Initial plans for specifying and using the base url. For global endpoints with a base specified.
For organization endpoints
Need to check for odd cases and figure out what it does now. |
Fixed by #209. |
When invalid org is sent to chef-server bad things happen. We should just validate the BaseUrl at minimum has a trailing slash.
The text was updated successfully, but these errors were encountered: