preSign produces the authentication values required for AWS_MSK_IAM.
(ctx context.Context)
| 87 | |
| 88 | // preSign produces the authentication values required for AWS_MSK_IAM. |
| 89 | func (m *Mechanism) preSign(ctx context.Context) (map[string]string, error) { |
| 90 | req, err := buildReq(ctx, defaultExpiry(m.Expiry)) |
| 91 | if err != nil { |
| 92 | return nil, err |
| 93 | } |
| 94 | |
| 95 | creds, err := m.Credentials.Retrieve(ctx) |
| 96 | if err != nil { |
| 97 | return nil, err |
| 98 | } |
| 99 | |
| 100 | signedUrl, header, err := m.Signer.PresignHTTP(ctx, creds, req, signPayload, signService, m.Region, defaultSignTime(m.SignTime)) |
| 101 | if err != nil { |
| 102 | return nil, err |
| 103 | } |
| 104 | |
| 105 | u, err := url.Parse(signedUrl) |
| 106 | if err != nil { |
| 107 | return nil, err |
| 108 | } |
| 109 | return buildSignedMap(u, header), nil |
| 110 | } |
| 111 | |
| 112 | // buildReq builds http.Request for aws PreSign. |
| 113 | func buildReq(ctx context.Context, expiry time.Duration) (*http.Request, error) { |
no test coverage detected