Permalink
Browse files

rkt: add AWS auth headerer support to `rkt config`

This refactors awsAuthHeaderer to match oAuthBearerTokenHeaderer and modifies
the `config` command so awsAuthHeaderer can be marshaled to JSON (support for
this was previously missing).
  • Loading branch information...
rufoa committed Sep 23, 2017
1 parent 8b64477 commit 68e2d06667b1bfc571618ecaf16b117d339cad1a
Showing with 7 additions and 8 deletions.
  1. +4 −8 rkt/config/auth.go
  2. +3 −0 rkt/config/config.go
@@ -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 {
@@ -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,
@@ -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
}
@@ -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")
}

0 comments on commit 68e2d06

Please sign in to comment.