Skip to content

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

Merged
merged 2 commits into from
Jun 21, 2022

Conversation

spica314
Copy link
Contributor

@spica314 spica314 commented Jun 18, 2022

fixes #831

Copy link
Member

@cataggar cataggar left a 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.

@cataggar cataggar requested a review from rylev June 19, 2022 20:29
@@ -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..];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@rylev rylev left a 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?

@ghost
Copy link

ghost commented Jun 20, 2022

CLA assistant check
All CLA requirements met.

@spica314
Copy link
Contributor Author

spica314 commented Jun 20, 2022

@rylev
Thank you for your review!

I moved the code for striping the leading slash to generate_resource_link.
(Since my English skill is poor, if my comments are incorrect, please tell me...)

And I also rewrite tests for generate_resource_link, but I'm not sure whether I'm following your suggestion.
If not, please tell me more (example or functions to use).

@spica314 spica314 requested a review from rylev June 20, 2022 14:22
Copy link
Contributor

@rylev rylev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! 🎉

@rylev rylev merged commit 99be8f0 into Azure:main Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unauthorized error in CosmosDB operations
3 participants