Repository navigation
fix(oauth): allow http scheme for localhost and return nil on invalid host - #187
Hardik K (hardikkaurani) wants to merge 8 commits into
Conversation
|
Hi Vincent Biret (@baywet), I've opened this PR to allow HTTP on localhost and loopback addresses in OAuthAccessTokenProvider (#117) and fix the guard return check for invalid hosts. Comprehensive RSpec tests are included. Ready for review! |
… localhost, and preserve fiber contract
|
I've addressed the review feedback in the latest commit. Changes
The changes are ready for review. When you have a chance, could you please take another look? Thank you for your time and feedback! |
|
Hardik K (@hardikkaurani) the linting is failing, would you mind fixing this please? |
|
Vincent Biret (@baywet) Just doing it ! |
|
I have updated the PR and resolved the RuboCop \Metrics/BlockLength\ offenses by modularizing the test suite into dedicated spec files matching the existing project structure (\�ase_bearer_token_authentication_provider_spec.rb\ and \oauth_access_token_provider_spec.rb).
Ready for review and workflow approval! Thank you! |
|
Now also failing, just give me a minute ! I am taking a close look into this Vincent Biret (@baywet) |
|
I have fixed the linting offense in All modified files have been verified to have zero RuboCop offenses. The fix has been pushed in commit 2732a7a and is ready for workflow approval and review! |
… host validation on localhost in provider
|
I have updated the PR in commit d51b090 following your review feedback:
Ready for your review! |
| it 'validates host with https scheme and rejects non-https' do | ||
| validator = described_class.new(['example.com', 'localhost']) | ||
| expect(validator.url_host_valid?('http://example.com')).to be(false) | ||
| expect(validator.url_host_valid?('http://localhost:8080')).to be(false) |
There was a problem hiding this comment.
| expect(validator.url_host_valid?('http://localhost:8080')).to be(false) | |
| expect(validator.url_host_valid?('http://localhost:8080')).to be(true) |
There was a problem hiding this comment.
Updated in 6c131f5: Updated AllowedHostsValidator#url_host_valid? to allow http scheme for localhost / loopback targets when included in �llowed_hosts, and updated this test expectation to o be(true).
…idation from scheme enforcement
|
I have updated the PR with commit 6c131f5 addressing your review suggestion and Copilot's review feedback:
Ready for your review! Thank you! |
…IPv6 allowlist entries
|
I have updated the PR with commit 8af8838 addressing the IPv6 allowlist matching feedback:
Ready for your review! Thank you! |
|
Hi Vincent Biret (@baywet), I've addressed the review feedback and added regression tests for IPv6 allowlist handling. The relevant tests pass locally, and I've pushed the updates to the PR. When you have a chance, could you please take another look? Thank you for your time and feedback! I've enjoyed contributing to Microsoft's open-source ecosystem and read your blog here: https://share.google/njEoOo6gDbfbit5Lf. I'd love to connect with you on LinkedIn and learn from your open-source experience. Thank you! This PR is actually good to go with. |


Description
Fixes #117
This PR allows the
httpscheme for localhost and loopback targets inOAuthAccessTokenProvider, aligning Ruby with the behavior in Kiota Go (kiota-authentication-azure-go#102), Python, and PHP:httpscheme when the target host matcheslocalhost,127.0.0.1,::1, or[::1].raise StandardError, 'Only https is supported').returnonreturn nil if !uri || !@host_validator.url_host_valid?(uri)which previously evaluatednilas a statement without returning, allowingURI(uri)to be called with invalid/nil targets.Related Issue
Fixes #117
Testing
Added RSpec tests in
components/authentication/oauth/spec/microsoft_kiota_authentication_oauth_spec.rb:get_authorization_tokenreturnsnilfornilor disallowed hosts.httponlocalhost,127.0.0.1, and[::1]successfully creates and resumes authentication fiber.httpon external non-localhost hosts raisesStandardError, 'Only https is supported'.cc Vincent Biret (@baywet)