kamranayub / azure-storage-rest-postman

Postman collection to sign requests to Azure Storage Management REST API
Apache License 2.0
26 stars 34 forks source link

Set Blob Service Properties authorization fails #6

Open sergeidavydov opened 3 years ago

sergeidavydov commented 3 years ago

Hi there,

The PUT request fails authorization when sent by Postman 8.0.5, don't know about other versions.

As I found the problem is an incorrect signature generated because "content-length" header is not included in it. Proved this by passing a correct value to signatureParts array instead of headers["content-length"] || "".

kamranayub commented 3 years ago

Thanks will take a look this week. 👍

kamranayub commented 3 years ago

Have to test in v8, previous version I'm on (6.4.2) includes the content length properly. You can also check the Postman Console to see the logs:

image

kamranayub commented 3 years ago

Hmm, this is working for me in v8. Are you using the latest version in master branch? May need more info with steps to reproduce. There was a fix 6mo ago to fix content-length and I am guessing if you downloaded it from Exercise Files in Pluralsight, it's out-of-date (it's tough for me to update those but if you did, I should ask).

sergeidavydov commented 3 years ago

Hi. I downloaded the collection file from here, the master branch.

I downloaded and re-imported the collection again. Postman updated to version 8.0.6. The problem is still present.

image

Signature String "PUT\n\n\n\n\napplication/xml\n\n\n\n\n\n\nx-ms-date:Sun, 21 Feb 2021 21:25:43 GMT\nx-ms-version:2018-03-28\n/storageaccountname/\ncomp:properties\nrestype:service"

`\<?xml version="1.0" encoding="utf-8"?> \<Error> \<Code>AuthenticationFailed\</Code> \<Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:60cf16be-c01e-0048-2398-08cbe7000000 Time:2021-02-21T21:25:43.8009749Z\</Message> \<AuthenticationErrorDetail>The MAC signature found in the HTTP request 'XcmkeYO/9vxPNbbxyffsv8aQGTHpe05Q3My+rx8p1SI=' is not the same as any computed signature. Server used following string to sign: 'PUT

765

application/xml

x-ms-date:Sun, 21 Feb 2021 21:25:43 GMT x-ms-version:2018-03-28 /storageaccountname/ comp:properties restype:service'.\</AuthenticationErrorDetail> \</Error>`

kamranayub commented 3 years ago

Thanks, I can try and take a closer look. Something isn't right, it's possible I have different code running.

You have a content body being sent, correct?

SuneethaYamani commented 3 years ago

Hi. I downloaded the collection file from here, the master branch.

I downloaded and re-imported the collection again. Postman updated to version 8.0.6. The problem is still present.

image

Signature String "PUT\n\n\n\n\napplication/xml\n\n\n\n\n\n\nx-ms-date:Sun, 21 Feb 2021 21:25:43 GMT\nx-ms-version:2018-03-28\n/storageaccountname/\ncomp:properties\nrestype:service"

`<?xml version="1.0" encoding="utf-8"?>

AuthenticationFailed Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:60cf16be-c01e-0048-2398-08cbe7000000 Time:2021-02-21T21:25:43.8009749Z The MAC signature found in the HTTP request 'XcmkeYO/9vxPNbbxyffsv8aQGTHpe05Q3My+rx8p1SI=' is not the same as any computed signature. Server used following string to sign: 'PUT 765 application/xml x-ms-date:Sun, 21 Feb 2021 21:25:43 GMT x-ms-version:2018-03-28 /storageaccountname/ comp:properties restype:service'. `

I am facing same issue..any luck

sergeidavydov commented 3 years ago

Thanks, I can try and take a closer look. Something isn't right, it's possible I have different code running.

You have a content body being sent, correct?

Yes, the body content sent was correct.