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

DXE-2381 V4 of Edgegrid Does Not Parse Host Name #182

Closed
patalwell opened this issue Feb 15, 2023 · 2 comments
Closed

DXE-2381 V4 of Edgegrid Does Not Parse Host Name #182

patalwell opened this issue Feb 15, 2023 · 2 comments

Comments

@patalwell
Copy link

patalwell commented Feb 15, 2023

Hi folks, seems like there is a bit of a bug when parsing the host from the edgegrid library, which causes issues when signing the auth header for the server. We should rectify this by altering instructions or by appending the appropriate protocol to the request URL.

Here's what id expect to do based on your instructions:

         edgerc := akamai.Must(akamai.New(
		akamai.WithFile(".edgerc"),
	))

	client := &http.Client{
		Timeout: 3 * time.Second,
	}

	req, _ := http.NewRequest(http.MethodGet, "/gtm-api/v1/reports/domain-list", nil)
        edgerc.SignRequest(req)
	resp, err := client.Do(req)
	if err != nil {
		log.Println("failed to make request")
		log.Fatal(err)
	}

Which leads to 2023/02/15 12:06:41 Get "//akab-zpqlazcvjpvvkirv-tarozpg25ilmzdhi.luna.akamaiapis.net/gtm-api/v1/reports/domain-list": unsupported protocol scheme ""

This is what I actually need to do:

edgerc := akamai.Must(akamai.New(
		akamai.WithFile(".edgerc"),
	))

	client := &http.Client{
		Timeout: 3 * time.Second,
	}

	req, _ := http.NewRequest(http.MethodGet, "/gtm-api/v1/reports/domain-list", nil)
	endpoint := fmt.Sprintf("https:%s", req.URL)
	parsedUrl, err := url.Parse(endpoint)
	if err != nil {
		log.Fatal(err)
	}
	req.URL = parsedUrl
	edgerc.SignRequest(req)

	resp, err := client.Do(req)
	if err != nil {
		log.Println("failed to make request")
		log.Fatal(err)
	}

Minor adjustments, but think it would help others when setting up clients for the first time. :) My .edgrerc file is correct, I have my hostname from the credentials I've created, but apparently something doesn't update it correctly. I believe this happens in the http package.

@wzagrajcz wzagrajcz changed the title V4 of Edgegrid Does Not Parse Host Name DXE-2381 V4 of Edgegrid Does Not Parse Host Name Feb 21, 2023
@mgwoj
Copy link
Contributor

mgwoj commented Feb 21, 2023

Hello,

Thank you for reporting this issue. We are going to fix the code in the upcoming release.

@kaush- kaush- mentioned this issue Feb 27, 2023
@lkowalsk-akamai-com
Copy link
Contributor

Hi @patalwell, this issue should be resolved with recent release.

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

No branches or pull requests

3 participants