-
Notifications
You must be signed in to change notification settings - Fork 290
Fix 401 Unauthorized error in CosmosDB operations #832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fine to me. I'd like @rylev to review. Would prefer a test added. I wonder if the query part is actually needed for the AuthorizationPolicy.
@@ -57,11 +57,11 @@ impl Policy for AuthorizationPolicy { | |||
|
|||
let time_nonce = TimeNonce::new(); | |||
|
|||
let uri_path = request.path_and_query(); | |||
let uri_path = &request.path_and_query()[1..]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This matches what the code was, prior to this change:
https://github.com/Azure/azure-sdk-for-rust/pull/811/files#diff-1d8d32914ddb120499d9acbf8fb856f3757b01bf2d612c4eef44e5ff9590dcbaL57
I think in #811, there was a switch from http::Uri
to url::Url
and path_and_query
existed in the former.
https://docs.rs/http/latest/http/uri/struct.Uri.html#method.path_and_query
https://docs.rs/url/latest/url/struct.Url.html#method.path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops! Good find. I think we should probably change the generate_resource_link
to take a &Request
and have that function do the magical &request.path_and_query()[1..]
dance. That way it's all contained within that function and not the callers responsibility to give the generate_resource_link
function a "uri path" in the right format.
I also agree that it would be nice to have a test for this. Maybe we can change the tests at the end of the file to generate the resource_link instead of hard coding it?
@rylev I moved the code for striping the leading slash to And I also rewrite tests for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! 🎉
fixes #831