1- use azure_core:: error:: { Error , ErrorKind , ResultExt } ;
2-
31use crate :: StorageCredentials ;
2+ use azure_core:: error:: { Error , ErrorKind } ;
43
54// Key names.
65pub const ACCOUNT_KEY_KEY_NAME : & str = "AccountKey" ;
@@ -188,15 +187,13 @@ impl<'a> ConnectionString<'a> {
188187 if self . account_key . is_some ( ) {
189188 log:: warn!( "Both account key and SAS defined in connection string. Using only the provided SAS." ) ;
190189 }
191- Ok ( StorageCredentials :: SASToken ( get_sas_token_parms (
192- sas_token,
193- ) ?) )
190+ StorageCredentials :: sas_token ( * sas_token)
194191 }
195192 ConnectionString {
196193 account_name : Some ( account) ,
197194 account_key : Some ( key) ,
198195 ..
199- } => Ok ( StorageCredentials :: Key ( ( * account) . to_string ( ) , ( * key) . to_string ( ) ) ) ,
196+ } => Ok ( StorageCredentials :: access_key ( * account, * key) ) ,
200197 _ => {
201198 Err ( Error :: message ( ErrorKind :: Credential ,
202199 "Could not create a `StorageCredentail` from the provided connection string. Please validate that you have specified a means of authentication (key, SAS, etc.)."
@@ -206,30 +203,6 @@ impl<'a> ConnectionString<'a> {
206203 }
207204}
208205
209- fn get_sas_token_parms ( sas_token : & str ) -> azure_core:: Result < Vec < ( String , String ) > > {
210- // Any base url will do: we just need to parse the SAS token
211- // to get its query pairs.
212- let base_url = url:: Url :: parse ( "https://blob.core.windows.net" ) . unwrap ( ) ;
213-
214- let url = url:: Url :: options ( ) . base_url ( Some ( & base_url) ) ;
215-
216- // this code handles the leading ?
217- // we support both with or without
218- let url = if sas_token. starts_with ( '?' ) {
219- url. parse ( sas_token)
220- } else {
221- url. parse ( & format ! ( "?{sas_token}" ) )
222- }
223- . with_context ( ErrorKind :: DataConversion , || {
224- format ! ( "failed to parse SAS token: {sas_token}" )
225- } ) ?;
226-
227- Ok ( url
228- . query_pairs ( )
229- . map ( |p| ( String :: from ( p. 0 ) , String :: from ( p. 1 ) ) )
230- . collect ( ) )
231- }
232-
233206#[ cfg( test) ]
234207mod tests {
235208 #[ allow( unused_imports) ]
0 commit comments