Skip to content

Throw error on https:// and http:// prefix if present in allowed host value - #461

Merged
Vincent Biret (baywet) merged 3 commits into
microsoft:mainfrom
svrooij:fix-allowed-hosts-validator
Jan 28, 2025
Merged

Vincent Biret (baywet) merged 3 commits into
microsoft:mainfrom
svrooij:fix-allowed-hosts-validator

Conversation

@svrooij

@svrooij Stephan van Rooij (svrooij) commented Jan 26, 2025 •

Copy link
Copy Markdown
Contributor

Fixes #201

Add error handling for 'https://' and 'http://' prefixes in allowed host values.

  • Modify AllowedHostsValidator class in packages/abstractions/kiota_abstractions/authentication/allowed_hosts_validator.py to throw a ValueError if any allowed host contains 'https://' or 'http://' prefix.
  • Add a check in the __init__ method and set_allowed_hosts method to throw a ValueError if any allowed host contains 'https://' or 'http://' prefix.
  • Add tests in packages/abstractions/tests/authentication/test_api_key_authentication_provider.py to verify that a ValueError is thrown when 'https://' or 'http://' prefix is present in allowed host value.

For more details, open the Copilot Workspace session.

…host value

Fixes microsoft#201

Add error handling for 'https://' and 'http://' prefixes in allowed host values.

* Modify `AllowedHostsValidator` class in `packages/abstractions/kiota_abstractions/authentication/allowed_hosts_validator.py` to throw a `ValueError` if any allowed host contains 'https://' or 'http://' prefix.
* Add a check in the `__init__` method and `set_allowed_hosts` method to throw a `ValueError` if any allowed host contains 'https://' or 'http://' prefix.
* Add tests in `packages/abstractions/tests/authentication/test_api_key_authentication_provider.py` to verify that a `ValueError` is thrown when 'https://' or 'http://' prefix is present in allowed host value.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/microsoft/kiota-python/issues/201?shareId=XXXX-XXXX-XXXX-XXXX).
@svrooij
Stephan van Rooij (svrooij) requested a review from a team as a code owner January 26, 2025 13:53

@baywet Vincent Biret (baywet) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the contribution!

@baywet
Vincent Biret (baywet) enabled auto-merge (squash) January 28, 2025 14:14
@sonarqubecloud

Copy link
Copy Markdown

@baywet
Vincent Biret (baywet) merged commit d259efa into microsoft:main Jan 28, 2025
@baywet Vincent Biret (baywet) added the release-please:force-run used to force releases with RP label Jan 28, 2025
@release-please release-please Bot removed the release-please:force-run used to force releases with RP label Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Throw error on https:// and http:// prefix if present in allowed host value

3 participants