@@ -11,11 +11,10 @@ pub mod sigv4 {
11
11
SignableRequest , SignatureLocation , SigningParams , SigningSettings ,
12
12
UriPathNormalizationMode ,
13
13
} ;
14
- use aws_smithy_http :: property_bag :: PropertyBag ;
14
+ use aws_smithy_runtime_api :: client :: auth :: { AuthSchemeId , HttpAuthScheme , HttpRequestSigner } ;
15
15
use aws_smithy_runtime_api:: client:: identity:: { Identity , IdentityResolver , IdentityResolvers } ;
16
- use aws_smithy_runtime_api:: client:: orchestrator:: {
17
- BoxError , HttpAuthScheme , HttpRequest , HttpRequestSigner ,
18
- } ;
16
+ use aws_smithy_runtime_api:: client:: orchestrator:: { BoxError , ConfigBagAccessors , HttpRequest } ;
17
+ use aws_smithy_runtime_api:: config_bag:: ConfigBag ;
19
18
use aws_types:: region:: SigningRegion ;
20
19
use aws_types:: SigningService ;
21
20
use std:: time:: { Duration , SystemTime } ;
@@ -24,7 +23,7 @@ pub mod sigv4 {
24
23
`expires_in` duration because the credentials used to sign it will expire first.";
25
24
26
25
/// Auth scheme ID for SigV4.
27
- pub const SCHEME_ID : & str = "sigv4" ;
26
+ pub const SCHEME_ID : AuthSchemeId = AuthSchemeId :: new ( "sigv4" ) ;
28
27
29
28
/// SigV4 auth scheme.
30
29
#[ derive( Debug , Default ) ]
@@ -40,7 +39,7 @@ pub mod sigv4 {
40
39
}
41
40
42
41
impl HttpAuthScheme for SigV4HttpAuthScheme {
43
- fn scheme_id ( & self ) -> & ' static str {
42
+ fn scheme_id ( & self ) -> AuthSchemeId {
44
43
SCHEME_ID
45
44
}
46
45
@@ -88,8 +87,6 @@ pub mod sigv4 {
88
87
pub signing_optional : bool ,
89
88
/// Optional expiration (for presigning)
90
89
pub expires_in : Option < Duration > ,
91
- /// Timestamp to sign with.
92
- pub request_timestamp : SystemTime ,
93
90
}
94
91
95
92
impl Default for SigningOptions {
@@ -103,7 +100,6 @@ pub mod sigv4 {
103
100
signature_type : HttpSignatureType :: HttpRequestHeaders ,
104
101
signing_optional : false ,
105
102
expires_in : None ,
106
- request_timestamp : SystemTime :: now ( ) ,
107
103
}
108
104
}
109
105
}
@@ -168,11 +164,11 @@ pub mod sigv4 {
168
164
settings : SigningSettings ,
169
165
credentials : & ' a Credentials ,
170
166
operation_config : & ' a SigV4OperationSigningConfig ,
167
+ request_timestamp : SystemTime ,
171
168
) -> SigningParams < ' a > {
172
169
if let Some ( expires_in) = settings. expires_in {
173
170
if let Some ( creds_expires_time) = credentials. expiry ( ) {
174
- let presigned_expires_time =
175
- operation_config. signing_options . request_timestamp + expires_in;
171
+ let presigned_expires_time = request_timestamp + expires_in;
176
172
if presigned_expires_time > creds_expires_time {
177
173
tracing:: warn!( EXPIRATION_WARNING ) ;
178
174
}
@@ -184,7 +180,7 @@ pub mod sigv4 {
184
180
. secret_key ( credentials. secret_access_key ( ) )
185
181
. region ( operation_config. region . as_ref ( ) )
186
182
. service_name ( operation_config. service . as_ref ( ) )
187
- . time ( operation_config . signing_options . request_timestamp )
183
+ . time ( request_timestamp)
188
184
. settings ( settings) ;
189
185
builder. set_security_token ( credentials. session_token ( ) ) ;
190
186
builder. build ( ) . expect ( "all required fields set" )
@@ -196,12 +192,12 @@ pub mod sigv4 {
196
192
& self ,
197
193
request : & mut HttpRequest ,
198
194
identity : & Identity ,
199
- // TODO(enableNewSmithyRuntime): should this be the config bag?
200
- signing_properties : & PropertyBag ,
195
+ config_bag : & ConfigBag ,
201
196
) -> Result < ( ) , BoxError > {
202
- let operation_config = signing_properties
197
+ let operation_config = config_bag
203
198
. get :: < SigV4OperationSigningConfig > ( )
204
199
. ok_or ( "missing operation signing config for SigV4" ) ?;
200
+ let request_time = config_bag. request_time ( ) . unwrap_or_default ( ) . system_time ( ) ;
205
201
206
202
let credentials = if let Some ( creds) = identity. data :: < Credentials > ( ) {
207
203
creds
@@ -213,7 +209,8 @@ pub mod sigv4 {
213
209
} ;
214
210
215
211
let settings = Self :: settings ( operation_config) ;
216
- let signing_params = Self :: signing_params ( settings, credentials, operation_config) ;
212
+ let signing_params =
213
+ Self :: signing_params ( settings, credentials, operation_config, request_time) ;
217
214
218
215
let ( signing_instructions, _signature) = {
219
216
// A body that is already in memory can be signed directly. A body that is not in memory
@@ -283,17 +280,16 @@ pub mod sigv4 {
283
280
signature_type : HttpSignatureType :: HttpRequestHeaders ,
284
281
signing_optional : false ,
285
282
expires_in : None ,
286
- request_timestamp : now,
287
283
payload_override : None ,
288
284
} ,
289
285
} ;
290
- SigV4HttpRequestSigner :: signing_params ( settings, & credentials, & operation_config) ;
286
+ SigV4HttpRequestSigner :: signing_params ( settings, & credentials, & operation_config, now ) ;
291
287
assert ! ( !logs_contain( EXPIRATION_WARNING ) ) ;
292
288
293
289
let mut settings = SigningSettings :: default ( ) ;
294
290
settings. expires_in = Some ( creds_expire_in + Duration :: from_secs ( 10 ) ) ;
295
291
296
- SigV4HttpRequestSigner :: signing_params ( settings, & credentials, & operation_config) ;
292
+ SigV4HttpRequestSigner :: signing_params ( settings, & credentials, & operation_config, now ) ;
297
293
assert ! ( logs_contain( EXPIRATION_WARNING ) ) ;
298
294
}
299
295
}
0 commit comments