@@ -43,7 +43,7 @@ enum Credential {
43
43
44
44
/// The credential is a key to be used to sign the HTTP request (a shared key)
45
45
#[ cfg( feature = "key-auth" ) ]
46
- SigningKey ( Secret ) ,
46
+ PrimaryKey ( Secret ) ,
47
47
}
48
48
49
49
#[ cfg( feature = "key-auth" ) ]
@@ -86,7 +86,7 @@ impl AuthorizationPolicy {
86
86
#[ cfg( feature = "key-auth" ) ]
87
87
pub ( crate ) fn from_shared_key ( key : Secret ) -> Self {
88
88
Self {
89
- credential : Credential :: SigningKey ( key) ,
89
+ credential : Credential :: PrimaryKey ( key) ,
90
90
}
91
91
}
92
92
}
@@ -188,16 +188,18 @@ fn generate_resource_link(request: &Request) -> String {
188
188
}
189
189
}
190
190
191
- /// The `CosmosDB` authorization can either be:
192
- /// - "primary": one of the two service-level tokens
193
- /// - "resource": e.g. a single database
194
- /// - "aad": Azure Active Directory token
191
+ /// Generates the 'Authorization' header value based on the provided values.
192
+ ///
193
+ /// The specific result format depends on the type of the auth token provided.
194
+ /// - "primary": one of the two service-level tokens
195
+ /// - "aad": Azure Active Directory token
196
+ ///
195
197
/// In the "primary" case the signature must be constructed by signing the HTTP method,
196
198
/// resource type, resource link (the relative URI) and the current time.
197
199
///
198
- /// In the "resource" case, the signature is just the resource key.
199
- ///
200
200
/// In the "aad" case, the signature is the AAD token.
201
+ ///
202
+ /// NOTE: Resource tokens are not yet supported.
201
203
async fn generate_authorization < ' a > (
202
204
auth_token : & Credential ,
203
205
url : & Url ,
@@ -215,7 +217,7 @@ async fn generate_authorization<'a>(
215
217
) ,
216
218
217
219
#[ cfg( feature = "key-auth" ) ]
218
- Credential :: SigningKey ( key) => {
220
+ Credential :: PrimaryKey ( key) => {
219
221
let string_to_sign = string_to_sign ( signature_target) ;
220
222
( "master" , hmac_sha256 ( & string_to_sign, key) ?)
221
223
}
@@ -310,7 +312,7 @@ mon, 01 jan 1900 01:00:00 gmt
310
312
async fn generate_authorization_00 ( ) {
311
313
let time = date:: parse_rfc3339 ( "1900-01-01T01:00:00.000000000+00:00" ) . unwrap ( ) ;
312
314
313
- let auth_token = Credential :: SigningKey (
315
+ let auth_token = Credential :: PrimaryKey (
314
316
"8F8xXXOptJxkblM1DBXW7a6NMI5oE8NnwPGYBmwxLCKfejOK7B7yhcCHMGvN3PBrlMLIOeol1Hv9RCdzAZR5sg==" . into ( ) ,
315
317
)
316
318
. unwrap ( ) ;
@@ -341,7 +343,7 @@ mon, 01 jan 1900 01:00:00 gmt
341
343
async fn generate_authorization_01 ( ) {
342
344
let time = date:: parse_rfc3339 ( "2017-04-27T00:51:12.000000000+00:00" ) . unwrap ( ) ;
343
345
344
- let auth_token = Credential :: SigningKey (
346
+ let auth_token = Credential :: PrimaryKey (
345
347
"dsZQi3KtZmCv1ljt3VNWNm7sQUF1y5rJfC6kv5JiwvW0EndXdDku/dkKBp8/ufDToSxL" . into ( ) ,
346
348
)
347
349
. unwrap ( ) ;
0 commit comments