aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/aws/aws-sdk-go-v2/internal/auth
diff options
context:
space:
mode:
authorvitalyisaev <vitalyisaev@ydb.tech>2023-12-12 21:55:07 +0300
committervitalyisaev <vitalyisaev@ydb.tech>2023-12-12 22:25:10 +0300
commit4967f99474a4040ba150eb04995de06342252718 (patch)
treec9c118836513a8fab6e9fcfb25be5d404338bca7 /vendor/github.com/aws/aws-sdk-go-v2/internal/auth
parent2ce9cccb9b0bdd4cd7a3491dc5cbf8687cda51de (diff)
downloadydb-4967f99474a4040ba150eb04995de06342252718.tar.gz
YQ Connector: prepare code base for S3 integration
1. Кодовая база Коннектора переписана с помощью Go дженериков так, чтобы добавление нового источника данных (в частности S3 + csv) максимально переиспользовало имеющийся код (чтобы сохранялась логика нарезания на блоки данных, учёт трафика и пр.) 2. API Connector расширено для работы с S3, но ещё пока не протестировано.
Diffstat (limited to 'vendor/github.com/aws/aws-sdk-go-v2/internal/auth')
-rw-r--r--vendor/github.com/aws/aws-sdk-go-v2/internal/auth/gotest/ya.make5
-rw-r--r--vendor/github.com/aws/aws-sdk-go-v2/internal/auth/scheme.go186
-rw-r--r--vendor/github.com/aws/aws-sdk-go-v2/internal/auth/scheme_test.go75
-rw-r--r--vendor/github.com/aws/aws-sdk-go-v2/internal/auth/ya.make15
4 files changed, 281 insertions, 0 deletions
diff --git a/vendor/github.com/aws/aws-sdk-go-v2/internal/auth/gotest/ya.make b/vendor/github.com/aws/aws-sdk-go-v2/internal/auth/gotest/ya.make
new file mode 100644
index 0000000000..ec146f4a47
--- /dev/null
+++ b/vendor/github.com/aws/aws-sdk-go-v2/internal/auth/gotest/ya.make
@@ -0,0 +1,5 @@
+GO_TEST_FOR(vendor/github.com/aws/aws-sdk-go-v2/internal/auth)
+
+LICENSE(Apache-2.0)
+
+END()
diff --git a/vendor/github.com/aws/aws-sdk-go-v2/internal/auth/scheme.go b/vendor/github.com/aws/aws-sdk-go-v2/internal/auth/scheme.go
new file mode 100644
index 0000000000..ff229c048f
--- /dev/null
+++ b/vendor/github.com/aws/aws-sdk-go-v2/internal/auth/scheme.go
@@ -0,0 +1,186 @@
+package auth
+
+import (
+ "context"
+ "fmt"
+
+ smithy "github.com/aws/smithy-go"
+ "github.com/aws/smithy-go/middleware"
+)
+
+// SigV4 is a constant representing
+// Authentication Scheme Signature Version 4
+const SigV4 = "sigv4"
+
+// SigV4A is a constant representing
+// Authentication Scheme Signature Version 4A
+const SigV4A = "sigv4a"
+
+// None is a constant representing the
+// None Authentication Scheme
+const None = "none"
+
+// SupportedSchemes is a data structure
+// that indicates the list of supported AWS
+// authentication schemes
+var SupportedSchemes = map[string]bool{
+ SigV4: true,
+ SigV4A: true,
+ None: true,
+}
+
+// AuthenticationScheme is a representation of
+// AWS authentication schemes
+type AuthenticationScheme interface {
+ isAuthenticationScheme()
+}
+
+// AuthenticationSchemeV4 is a AWS SigV4 representation
+type AuthenticationSchemeV4 struct {
+ Name string
+ SigningName *string
+ SigningRegion *string
+ DisableDoubleEncoding *bool
+}
+
+func (a *AuthenticationSchemeV4) isAuthenticationScheme() {}
+
+// AuthenticationSchemeV4A is a AWS SigV4A representation
+type AuthenticationSchemeV4A struct {
+ Name string
+ SigningName *string
+ SigningRegionSet []string
+ DisableDoubleEncoding *bool
+}
+
+func (a *AuthenticationSchemeV4A) isAuthenticationScheme() {}
+
+// AuthenticationSchemeNone is a representation for the none auth scheme
+type AuthenticationSchemeNone struct{}
+
+func (a *AuthenticationSchemeNone) isAuthenticationScheme() {}
+
+// NoAuthenticationSchemesFoundError is used in signaling
+// that no authentication schemes have been specified.
+type NoAuthenticationSchemesFoundError struct{}
+
+func (e *NoAuthenticationSchemesFoundError) Error() string {
+ return fmt.Sprint("No authentication schemes specified.")
+}
+
+// UnSupportedAuthenticationSchemeSpecifiedError is used in
+// signaling that only unsupported authentication schemes
+// were specified.
+type UnSupportedAuthenticationSchemeSpecifiedError struct {
+ UnsupportedSchemes []string
+}
+
+func (e *UnSupportedAuthenticationSchemeSpecifiedError) Error() string {
+ return fmt.Sprint("Unsupported authentication scheme specified.")
+}
+
+// GetAuthenticationSchemes extracts the relevant authentication scheme data
+// into a custom strongly typed Go data structure.
+func GetAuthenticationSchemes(p *smithy.Properties) ([]AuthenticationScheme, error) {
+ var result []AuthenticationScheme
+ if !p.Has("authSchemes") {
+ return nil, &NoAuthenticationSchemesFoundError{}
+ }
+
+ authSchemes, _ := p.Get("authSchemes").([]interface{})
+
+ var unsupportedSchemes []string
+ for _, scheme := range authSchemes {
+ authScheme, _ := scheme.(map[string]interface{})
+
+ switch authScheme["name"] {
+ case SigV4:
+ v4Scheme := AuthenticationSchemeV4{
+ Name: SigV4,
+ SigningName: getSigningName(authScheme),
+ SigningRegion: getSigningRegion(authScheme),
+ DisableDoubleEncoding: getDisableDoubleEncoding(authScheme),
+ }
+ result = append(result, AuthenticationScheme(&v4Scheme))
+ case SigV4A:
+ v4aScheme := AuthenticationSchemeV4A{
+ Name: SigV4A,
+ SigningName: getSigningName(authScheme),
+ SigningRegionSet: getSigningRegionSet(authScheme),
+ DisableDoubleEncoding: getDisableDoubleEncoding(authScheme),
+ }
+ result = append(result, AuthenticationScheme(&v4aScheme))
+ case None:
+ noneScheme := AuthenticationSchemeNone{}
+ result = append(result, AuthenticationScheme(&noneScheme))
+ default:
+ unsupportedSchemes = append(unsupportedSchemes, authScheme["name"].(string))
+ continue
+ }
+ }
+
+ if len(result) == 0 {
+ return nil, &UnSupportedAuthenticationSchemeSpecifiedError{
+ UnsupportedSchemes: unsupportedSchemes,
+ }
+ }
+
+ return result, nil
+}
+
+type disableDoubleEncoding struct{}
+
+// SetDisableDoubleEncoding sets or modifies the disable double encoding option
+// on the context.
+//
+// Scoped to stack values. Use github.com/aws/smithy-go/middleware#ClearStackValues
+// to clear all stack values.
+func SetDisableDoubleEncoding(ctx context.Context, value bool) context.Context {
+ return middleware.WithStackValue(ctx, disableDoubleEncoding{}, value)
+}
+
+// GetDisableDoubleEncoding retrieves the disable double encoding option
+// from the context.
+//
+// Scoped to stack values. Use github.com/aws/smithy-go/middleware#ClearStackValues
+// to clear all stack values.
+func GetDisableDoubleEncoding(ctx context.Context) (value bool, ok bool) {
+ value, ok = middleware.GetStackValue(ctx, disableDoubleEncoding{}).(bool)
+ return value, ok
+}
+
+func getSigningName(authScheme map[string]interface{}) *string {
+ signingName, ok := authScheme["signingName"].(string)
+ if !ok || signingName == "" {
+ return nil
+ }
+ return &signingName
+}
+
+func getSigningRegionSet(authScheme map[string]interface{}) []string {
+ untypedSigningRegionSet, ok := authScheme["signingRegionSet"].([]interface{})
+ if !ok {
+ return nil
+ }
+ signingRegionSet := []string{}
+ for _, item := range untypedSigningRegionSet {
+ signingRegionSet = append(signingRegionSet, item.(string))
+ }
+ return signingRegionSet
+}
+
+func getSigningRegion(authScheme map[string]interface{}) *string {
+ signingRegion, ok := authScheme["signingRegion"].(string)
+ if !ok || signingRegion == "" {
+ return nil
+ }
+ return &signingRegion
+}
+
+func getDisableDoubleEncoding(authScheme map[string]interface{}) *bool {
+ disableDoubleEncoding, ok := authScheme["disableDoubleEncoding"].(bool)
+ if !ok {
+ return nil
+ }
+ return &disableDoubleEncoding
+}
diff --git a/vendor/github.com/aws/aws-sdk-go-v2/internal/auth/scheme_test.go b/vendor/github.com/aws/aws-sdk-go-v2/internal/auth/scheme_test.go
new file mode 100644
index 0000000000..49fc3c94be
--- /dev/null
+++ b/vendor/github.com/aws/aws-sdk-go-v2/internal/auth/scheme_test.go
@@ -0,0 +1,75 @@
+package auth
+
+import (
+ "testing"
+
+ smithy "github.com/aws/smithy-go"
+)
+
+func TestV4(t *testing.T) {
+
+ propsV4 := smithy.Properties{}
+
+ propsV4.Set("authSchemes", interface{}([]interface{}{
+ map[string]interface{}{
+ "disableDoubleEncoding": true,
+ "name": "sigv4",
+ "signingName": "s3",
+ "signingRegion": "us-west-2",
+ },
+ }))
+
+ result, err := GetAuthenticationSchemes(&propsV4)
+ if err != nil {
+ t.Fatalf("Did not expect error, got %v", err)
+ }
+
+ _, ok := result[0].(AuthenticationScheme)
+ if !ok {
+ t.Fatalf("Did not get expected AuthenticationScheme. %v", result[0])
+ }
+
+ v4Scheme, ok := result[0].(*AuthenticationSchemeV4)
+ if !ok {
+ t.Fatalf("Did not get expected AuthenticationSchemeV4. %v", result[0])
+ }
+
+ if v4Scheme.Name != "sigv4" {
+ t.Fatalf("Did not get expected AuthenticationSchemeV4 signer version name")
+ }
+
+}
+
+func TestV4A(t *testing.T) {
+
+ propsV4A := smithy.Properties{}
+
+ propsV4A.Set("authSchemes", []interface{}{
+ map[string]interface{}{
+ "disableDoubleEncoding": true,
+ "name": "sigv4a",
+ "signingName": "s3",
+ "signingRegionSet": []string{"*"},
+ },
+ })
+
+ result, err := GetAuthenticationSchemes(&propsV4A)
+ if err != nil {
+ t.Fatalf("Did not expect error, got %v", err)
+ }
+
+ _, ok := result[0].(AuthenticationScheme)
+ if !ok {
+ t.Fatalf("Did not get expected AuthenticationScheme. %v", result[0])
+ }
+
+ v4AScheme, ok := result[0].(*AuthenticationSchemeV4A)
+ if !ok {
+ t.Fatalf("Did not get expected AuthenticationSchemeV4A. %v", result[0])
+ }
+
+ if v4AScheme.Name != "sigv4a" {
+ t.Fatalf("Did not get expected AuthenticationSchemeV4A signer version name")
+ }
+
+}
diff --git a/vendor/github.com/aws/aws-sdk-go-v2/internal/auth/ya.make b/vendor/github.com/aws/aws-sdk-go-v2/internal/auth/ya.make
new file mode 100644
index 0000000000..99a0b2eaa2
--- /dev/null
+++ b/vendor/github.com/aws/aws-sdk-go-v2/internal/auth/ya.make
@@ -0,0 +1,15 @@
+GO_LIBRARY()
+
+LICENSE(Apache-2.0)
+
+SRCS(
+ scheme.go
+)
+
+GO_TEST_SRCS(scheme_test.go)
+
+END()
+
+RECURSE(
+ gotest
+)