func newRequestMetadata(r *gohttp.Request) (*requestMetadata, error) {
	authorizationStr := r.Header.Get("Authorization")
	amzDateStr := r.Header.Get("X-Amz-Date")
	if authorizationStr == "" {
		return nil, nil
	}
	date, err := newAmzDate(amzDateStr)
	if err != nil {
		return nil, err
	}
	reqMeta, err := requestMetadataFromAuthz(authorizationStr)
	if err != nil {
		return nil, err
	}
	reqMeta.date = date
	return reqMeta, nil
}
newRequestMetadata parses the request headers to extract the metadata
necessary to sign the request
package aws
import (
	"bytes"
	"fmt"
	"io/ioutil"
	gohttp "net/http"
	"net/url"
	"strings"
	"time"
	"github.com/aws/aws-sdk-go/aws/credentials"
	"github.com/aws/aws-sdk-go/aws/endpoints"
	signer "github.com/aws/aws-sdk-go/aws/signer/v4"
	"github.com/cyberark/secretless-broker/pkg/secretless/plugin/connector"
)
const timeFormat = "20060102T150405Z"
func newAmzDate(amzDateStr string) (time.Time, error) {
	if amzDateStr == "" {
		return time.Time{}, fmt.Errorf("missing required header: %s", "X-Amz-Date")
	}
	return time.Parse(timeFormat, amzDateStr)
}
func requestMetadataFromAuthz(authorizationStr string) (*requestMetadata, error) {
	tokens := strings.Split(authorizationStr, ", ")
	if len(tokens) != 3 || tokens[0] == "" || tokens[1] == "" || tokens[2] == "" {
		return nil, fmt.Errorf("malformed Authorization header")
	}
	credentialParts := strings.SplitN(tokens[0], "/", 5)
	if len(credentialParts) != 5 {
		return nil, fmt.Errorf("malformed credential component of Authorization header")
	}
	region := credentialParts[2]
	serviceName := credentialParts[3]
	signedHeaders := strings.Split(
		strings.TrimPrefix(tokens[1], "SignedHeaders="),
		";",
	)
	return &requestMetadata{
		region:        region,
		serviceName:   serviceName,
		signedHeaders: signedHeaders,
	}, nil
}
type requestMetadata struct {
	date          time.Time
	region        string
	serviceName   string
	signedHeaders []string
}