build(deps): bump github.com/open-policy-agent/opa from 0.62.1 to 0.64.1
Bumps [github.com/open-policy-agent/opa](https://github.com/open-policy-agent/opa) from 0.62.1 to 0.64.1. - [Release notes](https://github.com/open-policy-agent/opa/releases) - [Changelog](https://github.com/open-policy-agent/opa/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-policy-agent/opa/compare/v0.62.1...v0.64.1) --- updated-dependencies: - dependency-name: github.com/open-policy-agent/opa dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
committed by
Ralf Haferkamp
parent
237623178a
commit
2623d6cc75
Generated
Vendored
+1
-1
@@ -42,7 +42,7 @@ func init() {
|
||||
*
|
||||
* D) When comparing "between" a set of fields and a referenced fragment, first
|
||||
* a comparison is made between each field in the original set of fields and
|
||||
* each field in the the referenced set of fields.
|
||||
* each field in the referenced set of fields.
|
||||
*
|
||||
* E) Also, if any fragment is referenced in the referenced selection set,
|
||||
* then a comparison is made "between" the original set of fields and the
|
||||
|
||||
+17
-5
@@ -17,6 +17,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
v4 "github.com/open-policy-agent/opa/internal/providers/aws/v4"
|
||||
|
||||
"github.com/open-policy-agent/opa/ast"
|
||||
)
|
||||
|
||||
@@ -104,7 +106,7 @@ func SignRequest(req *http.Request, service string, creds Credentials, theTime t
|
||||
signedHeaders := SignV4a(req.Header, req.Method, req.URL, body, service, creds, now)
|
||||
req.Header = signedHeaders
|
||||
} else {
|
||||
authHeader, awsHeaders := SignV4(req.Header, req.Method, req.URL, body, service, creds, now)
|
||||
authHeader, awsHeaders := SignV4(req.Header, req.Method, req.URL, body, service, creds, now, false)
|
||||
req.Header.Set("Authorization", authHeader)
|
||||
for k, v := range awsHeaders {
|
||||
req.Header.Add(k, v)
|
||||
@@ -115,14 +117,16 @@ func SignRequest(req *http.Request, service string, creds Credentials, theTime t
|
||||
}
|
||||
|
||||
// SignV4 modifies a map[string][]string of headers to generate an AWS V4 signature + headers based on the config/credentials provided.
|
||||
func SignV4(headers map[string][]string, method string, theURL *url.URL, body []byte, service string, awsCreds Credentials, theTime time.Time) (string, map[string]string) {
|
||||
func SignV4(headers map[string][]string, method string, theURL *url.URL, body []byte, service string,
|
||||
awsCreds Credentials, theTime time.Time, disablePayloadSigning bool) (string, map[string]string) {
|
||||
// General ref. https://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html
|
||||
// S3 ref. https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-auth-using-authorization-header.html
|
||||
// APIGateway ref. https://docs.aws.amazon.com/apigateway/api-reference/signing-requests/
|
||||
bodyHexHash := fmt.Sprintf("%x", sha256.Sum256(body))
|
||||
|
||||
now := theTime.UTC()
|
||||
|
||||
contentSha256 := getContentHash(disablePayloadSigning, body)
|
||||
|
||||
// V4 signing has specific ideas of how it wants to see dates/times encoded
|
||||
dateNow := now.Format("20060102")
|
||||
iso8601Now := now.Format("20060102T150405Z")
|
||||
@@ -134,7 +138,7 @@ func SignV4(headers map[string][]string, method string, theURL *url.URL, body []
|
||||
|
||||
// s3 and glacier require the extra x-amz-content-sha256 header. other services do not.
|
||||
if service == "s3" || service == "glacier" {
|
||||
awsHeaders["x-amz-content-sha256"] = bodyHexHash
|
||||
awsHeaders[amzContentSha256Key] = contentSha256
|
||||
}
|
||||
|
||||
// the security token header is necessary for ephemeral credentials, e.g. from
|
||||
@@ -173,7 +177,7 @@ func SignV4(headers map[string][]string, method string, theURL *url.URL, body []
|
||||
// include the list of the signed headers
|
||||
headerList := strings.Join(orderedKeys, ";")
|
||||
canonicalReq += headerList + "\n"
|
||||
canonicalReq += bodyHexHash
|
||||
canonicalReq += contentSha256
|
||||
|
||||
// the "string to sign" is a time-bounded, scoped request token which
|
||||
// is linked to the "canonical request" by inclusion of its SHA-256 hash
|
||||
@@ -202,3 +206,11 @@ func SignV4(headers map[string][]string, method string, theURL *url.URL, body []
|
||||
|
||||
return authHeader, awsHeaders
|
||||
}
|
||||
|
||||
// getContentHash returns UNSIGNED-PAYLOAD if payload signing is disabled else will compute sha256 from body
|
||||
func getContentHash(disablePayloadSigning bool, body []byte) string {
|
||||
if disablePayloadSigning {
|
||||
return v4.UnsignedPayload
|
||||
}
|
||||
return fmt.Sprintf("%x", sha256.Sum256(body))
|
||||
}
|
||||
|
||||
+4
-4
@@ -32,6 +32,7 @@ const (
|
||||
amzSecurityTokenKey = v4Internal.AmzSecurityTokenKey
|
||||
amzDateKey = v4Internal.AmzDateKey
|
||||
authorizationHeader = "Authorization"
|
||||
amzContentSha256Key = "x-amz-content-sha256"
|
||||
|
||||
signingAlgorithm = "AWS4-ECDSA-P256-SHA256"
|
||||
|
||||
@@ -192,7 +193,7 @@ func (s *httpSigner) Build() (signedRequest, error) {
|
||||
|
||||
// seemingly required by S3/MRAP -- 403 Forbidden otherwise
|
||||
headers.Set("host", req.URL.Host)
|
||||
headers.Set("x-amz-content-sha256", s.PayloadHash)
|
||||
headers.Set(amzContentSha256Key, s.PayloadHash)
|
||||
|
||||
s.setRequiredSigningFields(headers, query)
|
||||
|
||||
@@ -381,8 +382,7 @@ type signedRequest struct {
|
||||
|
||||
// SignV4a returns a map[string][]string of headers, including an added AWS V4a signature based on the config/credentials provided.
|
||||
func SignV4a(headers map[string][]string, method string, theURL *url.URL, body []byte, service string, awsCreds Credentials, theTime time.Time) map[string][]string {
|
||||
bodyHexHash := fmt.Sprintf("%x", sha256.Sum256(body))
|
||||
|
||||
contentSha256 := getContentHash(false, body)
|
||||
key, err := retrievePrivateKey(awsCreds)
|
||||
if err != nil {
|
||||
return map[string][]string{}
|
||||
@@ -394,7 +394,7 @@ func SignV4a(headers map[string][]string, method string, theURL *url.URL, body [
|
||||
|
||||
signer := &httpSigner{
|
||||
Request: req,
|
||||
PayloadHash: bodyHexHash,
|
||||
PayloadHash: contentSha256,
|
||||
ServiceName: service,
|
||||
RegionSet: []string{"*"},
|
||||
Credentials: key,
|
||||
|
||||
Reference in New Issue
Block a user