Skip to content
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

Make sure the base url is set when calling authenticate_request #27

Merged
merged 2 commits into from
Feb 15, 2024

Conversation

louim
Copy link
Contributor

@louim louim commented Feb 13, 2024

This is a fix for the issue where the base url was not being set when calling authenticate_request.It caused an error later in the microsoft_kiota_authentication_oauth gem. The crux of the problem goes like that:

  • The request_info is passed to the access_token_provider and request_info.uri is used to build the request here. This uri is missing the base url.
  • The uri is then parsed here and an error is raised if scheme is not https. Because the base url is missing, the URI is only parsed as a relative path and thus always fails the scheme check.

The fix is to always make sure we set the baseurl before calling action where the url might be templated. The fix is inspired from the Csharp version of the class.

I tried adding some kind of test, but there almost nothing already in place and to test my small fix, I would have to either mock or instantiate a dozen of classes which some are not even in the same gem 😢.

This is a fix for the issue where the base url was not being set when calling authenticate_request.
This caused an error later in the kiota-authentication-oauth-ruby library. The request_info is passed
to the access_token_provider and request_info.uri is used to build the request. This uri is missing the
base url.
https://github.com/microsoft/kiota-abstractions-ruby/blob/7367a156276923eddd22e52335adbba88b1bf71e/lib/microsoft_kiota_abstractions/authentication/base_bearer_token_authentication_provider.rb#L21
Further down the line, the uri is parsed and an error is raised if scheme is not https. Because the base url
is missing, the URI is only parsed as a relative path and thus always fails the scheme check.
https://github.com/microsoft/kiota-authentication-oauth-ruby/blob/69ebeb6705b1d621a9943a15d634e9a33c77d23e/lib/microsoft_kiota_authentication_oauth/oauth_access_token_provider.rb#L54
baywet
baywet previously approved these changes Feb 14, 2024
Copy link
Member

@baywet baywet 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 so much for the contribution!
To ensure a swift publication of the patch, can you please:

I'll let @rkodev handle the release (you just need to create a tag on main like for the go repos) as I'm out this week.

Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@louim
Copy link
Contributor Author

louim commented Feb 14, 2024

@rkodev I pushed commit containing the version bump/changelog. @baywet you said to bump the patch, but I assume you meant the minor since the gem is in initial developement. Let me know if that's ok.

@baywet baywet merged commit 3a63521 into microsoft:main Feb 15, 2024
22 checks passed
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.

3 participants