8000 rkt: add AWS auth headerer support to `rkt config` by rufoa · Pull Request #3910 · rkt/rkt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Feb 24, 2020. It is now read-only.

rkt: add AWS auth headerer support to rkt config #3910

Merged
merged 1 commit into from
Mar 27, 2018
Merged
Show file tree
Hide file tree
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
12 changes: 4 additions & 8 deletions rkt/config/auth.go
10000
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,15 @@ func (h *oAuthBearerTokenHeaderer) SignRequest(r *http.Request) *http.Request {
}

type awsAuthHeaderer struct {
accessKeyID string
secretAccessKey string
region string
auth awsV1
}

func (h *awsAuthHeaderer) GetHeader() http.Header {
return make(http.Header)
}

func (h *awsAuthHeaderer) SignRequest(r *http.Request) *http.Request {
region := h.region
region := h.auth.Region

var body io.ReadSeeker
if r.Body != nil {
Expand All @@ -134,7 +132,7 @@ func (h *awsAuthHeaderer) SignRequest(r *http.Request) *http.Request {
SigningName: awsS3Service,
},
Config: aws.Config{
Credentials: credentials.NewStaticCredentials(h.accessKeyID, h.secretAccessKey, ""),
Credentials: credentials.NewStaticCredentials(h.auth.AccessKeyID, h.auth.SecretAccessKey, ""),
},
HTTPRequest: r,
Body: body,
Expand Down Expand Up @@ -243,9 +241,7 @@ func (p *authV1JsonParser) getAWSV1Headerer(raw json.RawMessage) (Headerer, erro
return nil, fmt.Errorf("no AWS Secret Access Key specified")
}
return &awsAuthHeaderer{
accessKeyID: aws.AccessKeyID,
secretAccessKey: aws.SecretAccessKey,
region: aws.Region,
auth: aws,
}, nil
}

Expand Down
3 changes: 3 additions & 0 deletions rkt/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ func (c *Config) MarshalJSON() ([]byte, error) {
case *oAuthBearerTokenHeaderer:
typ = "oauth"
credentials = h.auth
case *awsAuthHeaderer:
typ = "aws"
credentials = h.auth
default:
return nil, errors.New("unknown headerer type")
}
Expand Down
0