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

Add support for presigning sts:GetCallerIdentity #1030

Merged
merged 2 commits into from
Jan 13, 2021

Conversation

skmcgrail
Copy link
Member

@skmcgrail skmcgrail commented Jan 8, 2021

Add support for presigning sts:GetCallerIdentity.

Fix: #1021

Validated with the following code:

package main

import (
	"context"
	"fmt"
	"io/ioutil"
	"net/http"
	"net/url"

	"github.com/aws/aws-sdk-go-v2/config"
	"github.com/aws/aws-sdk-go-v2/service/sts"
)

func main() {
	cfg, err := config.LoadDefaultConfig(context.Background())
	if err != nil {
		panic(err)
	}

	presignClient := sts.NewPresignClient(sts.NewFromConfig(cfg))

	getCallerIdentity, err := presignClient.PresignGetCallerIdentity(context.Background(), &sts.GetCallerIdentityInput{})
	if err != nil {
		panic(err)
	}

	req := &http.Request{
		Method: getCallerIdentity.Method,
		URL: func() *url.URL {
			parse, err := url.Parse(getCallerIdentity.URL)
			if err != nil {
				panic(err)
			}
			return parse
		}(),
		Header: getCallerIdentity.SignedHeader,
	}

	response, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}

	body, err := ioutil.ReadAll(response.Body)
	if err != nil {
		panic(err)
	}

	fmt.Printf("%s\n", body)
}

@skmcgrail skmcgrail requested a review from jasdel January 8, 2021 23:41
@jasdel
Copy link
Contributor

jasdel commented Jan 11, 2021

Looks like compile issue with service/s3. Also looks like the eachmodule tool has issue and doesn't correct output stdout or stderr in case of a failure correctly.

@skmcgrail
Copy link
Member Author

Looks like compile issue with service/s3. Also looks like the eachmodule tool has issue and doesn't correct output stdout or stderr in case of a failure correctly.

Fixed didn't notice the S3 presign test cases beforehand.

@skmcgrail skmcgrail requested a review from jasdel January 11, 2021 22:39
@skmcgrail skmcgrail merged commit e0f7284 into aws:main Jan 13, 2021
@skmcgrail skmcgrail deleted the presignSTS branch January 13, 2021 00:20
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

Successfully merging this pull request may close these issues.

STS Presign Client
2 participants