Update
This commit is contained in:
44
vendor/github.com/aws/aws-sdk-go-v2/service/sts/auth.go
generated
vendored
44
vendor/github.com/aws/aws-sdk-go-v2/service/sts/auth.go
generated
vendored
@@ -12,10 +12,13 @@ import (
|
||||
"github.com/aws/smithy-go/middleware"
|
||||
"github.com/aws/smithy-go/tracing"
|
||||
smithyhttp "github.com/aws/smithy-go/transport/http"
|
||||
"slices"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func bindAuthParamsRegion(_ interface{}, params *AuthResolverParameters, _ interface{}, options Options) {
|
||||
func bindAuthParamsRegion(_ interface{}, params *AuthResolverParameters, _ interface{}, options Options) error {
|
||||
params.Region = options.Region
|
||||
return nil
|
||||
}
|
||||
|
||||
type setLegacyContextSigningOptionsMiddleware struct {
|
||||
@@ -92,14 +95,16 @@ type AuthResolverParameters struct {
|
||||
Region string
|
||||
}
|
||||
|
||||
func bindAuthResolverParams(ctx context.Context, operation string, input interface{}, options Options) *AuthResolverParameters {
|
||||
func bindAuthResolverParams(ctx context.Context, operation string, input interface{}, options Options) (*AuthResolverParameters, error) {
|
||||
params := &AuthResolverParameters{
|
||||
Operation: operation,
|
||||
}
|
||||
|
||||
bindAuthParamsRegion(ctx, params, input, options)
|
||||
if err := bindAuthParamsRegion(ctx, params, input, options); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return params
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// AuthSchemeResolver returns a set of possible authentication options for an
|
||||
@@ -162,7 +167,10 @@ func (m *resolveAuthSchemeMiddleware) HandleFinalize(ctx context.Context, in mid
|
||||
_, span := tracing.StartSpan(ctx, "ResolveAuthScheme")
|
||||
defer span.End()
|
||||
|
||||
params := bindAuthResolverParams(ctx, m.operation, getOperationInput(ctx), m.options)
|
||||
params, err := bindAuthResolverParams(ctx, m.operation, getOperationInput(ctx), m.options)
|
||||
if err != nil {
|
||||
return out, metadata, fmt.Errorf("bind auth scheme params: %w", err)
|
||||
}
|
||||
options, err := m.options.AuthSchemeResolver.ResolveAuthSchemes(ctx, params)
|
||||
if err != nil {
|
||||
return out, metadata, fmt.Errorf("resolve auth scheme: %w", err)
|
||||
@@ -181,7 +189,8 @@ func (m *resolveAuthSchemeMiddleware) HandleFinalize(ctx context.Context, in mid
|
||||
}
|
||||
|
||||
func (m *resolveAuthSchemeMiddleware) selectScheme(options []*smithyauth.Option) (*resolvedAuthScheme, bool) {
|
||||
for _, option := range options {
|
||||
sorted := sortAuthOptions(options, m.options.AuthSchemePreference)
|
||||
for _, option := range sorted {
|
||||
if option.SchemeID == smithyauth.SchemeIDAnonymous {
|
||||
return newResolvedAuthScheme(smithyhttp.NewAnonymousScheme(), option), true
|
||||
}
|
||||
@@ -200,6 +209,29 @@ func (m *resolveAuthSchemeMiddleware) selectScheme(options []*smithyauth.Option)
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func sortAuthOptions(options []*smithyauth.Option, preferred []string) []*smithyauth.Option {
|
||||
byPriority := make([]*smithyauth.Option, 0, len(options))
|
||||
for _, prefName := range preferred {
|
||||
for _, option := range options {
|
||||
optName := option.SchemeID
|
||||
if parts := strings.Split(option.SchemeID, "#"); len(parts) == 2 {
|
||||
optName = parts[1]
|
||||
}
|
||||
if prefName == optName {
|
||||
byPriority = append(byPriority, option)
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, option := range options {
|
||||
if !slices.ContainsFunc(byPriority, func(o *smithyauth.Option) bool {
|
||||
return o.SchemeID == option.SchemeID
|
||||
}) {
|
||||
byPriority = append(byPriority, option)
|
||||
}
|
||||
}
|
||||
return byPriority
|
||||
}
|
||||
|
||||
type resolvedAuthSchemeKey struct{}
|
||||
|
||||
type resolvedAuthScheme struct {
|
||||
|
||||
Reference in New Issue
Block a user