@@ -3,29 +3,29 @@ module Client
33 # @api private
44 module Auth
55 class << self
6- def resolve_auth ( context , endpoint_properties = { } )
6+ def resolve ( context , endpoint_properties = { } )
77 if endpoint_properties . key? ( 'authSchemes' )
8- resolve_auth_scheme_with_endpoint ( context , endpoint_properties [ 'authSchemes' ] )
8+ resolve_with_endpoint_auth ( context , endpoint_properties [ 'authSchemes' ] )
99 else
10- resolve_auth_scheme_without_endpoint ( context )
10+ resolve_without_endpoint_auth ( context )
1111 end
1212 end
1313
1414 private
1515
16- def resolve_auth_scheme_with_endpoint ( context , endpoint_auth_schemes )
16+ def resolve_with_endpoint_auth ( context , endpoint_auth_schemes )
1717 normalized_endpoint_schemes = [ ]
1818 endpoint_auth_schemes . each do |scheme |
1919 scheme_id = context . config . endpoint_auth_schemes [ scheme [ 'name' ] ]
2020 next unless scheme_id
2121
22- normalized_scheme = { scheme_id : scheme_id }
22+ properties = { }
2323 scheme . each do |key , value |
2424 next if key == 'name'
2525
26- normalized_scheme [ key ] = value
26+ properties [ key ] = value
2727 end
28- normalized_endpoint_schemes << normalized_scheme
28+ normalized_endpoint_schemes << { scheme_id : scheme_id , properties : properties }
2929 end
3030 resolved_auth_options = prioritize_auth_options (
3131 normalized_endpoint_schemes ,
@@ -34,7 +34,7 @@ def resolve_auth_scheme_with_endpoint(context, endpoint_auth_schemes)
3434 resolve_auth_scheme ( context . config . auth_schemes , resolved_auth_options )
3535 end
3636
37- def resolve_auth_scheme_without_endpoint ( context )
37+ def resolve_without_endpoint_auth ( context )
3838 auth_parameters = context . client . class . auth_parameters . create ( context )
3939 auth_options = context . config . auth_resolver . resolve ( auth_parameters )
4040 resolved_auth_options = prioritize_auth_options ( auth_options , context . config . auth_scheme_preference )
@@ -66,23 +66,24 @@ def resolve_auth_scheme(auth_schemes, auth_options)
6666 failures = [ ]
6767 auth_options . each do |auth_option |
6868 scheme_id = auth_option [ :scheme_id ]
69+ if scheme_id == 'smithy.api#noAuth'
70+ return AuthScheme . new ( identity_provider : nil , scheme_id : 'smithy.api#noAuth' , signer : NullSigner . new )
71+ end
6972
70- # Anonymous auth does not have a plugin and does not sign
71- return auth_option if scheme_id == 'smithy.api#noAuth'
72-
73- error = validate_auth_scheme ( auth_schemes , scheme_id )
74- return auth_option unless error
73+ auth_scheme = auth_schemes [ scheme_id ]
74+ error = validate_auth_scheme ( auth_scheme , scheme_id )
75+ return auth_scheme unless error
7576
7677 failures << error
7778 end
7879
7980 raise failures . join ( "\n " )
8081 end
8182
82- def validate_auth_scheme ( auth_schemes , scheme_id )
83- return "Auth scheme #{ scheme_id } was not enabled for this request" unless auth_schemes . key? ( scheme_id )
83+ def validate_auth_scheme ( auth_scheme , scheme_id )
84+ return "Auth scheme #{ scheme_id } was not enabled for this request" unless auth_scheme
8485
85- identity_provider = auth_schemes [ scheme_id ]
86+ identity_provider = auth_scheme . identity_provider
8687 return "Auth scheme #{ scheme_id } did not have an identity provider configured" unless identity_provider
8788 return "Auth scheme #{ scheme_id } failed to resolve identity" unless identity_provider . set?
8889
0 commit comments