-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
bugfix: user-agent python-requests #8394
Conversation
Replaced user agent to avoid bot protection on private repositories
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 all seems a bit silly to me: a repository that doesn't allow downloads from the requests user agent is broken and should be fixed (or reconfigured)
however it also seems harmless enough I suppose
src/poetry/utils/authenticator.py
Outdated
@@ -193,7 +195,8 @@ def authenticated_url(self, url: str) -> str: | |||
def request( | |||
self, method: str, url: str, raise_for_status: bool = True, **kwargs: Any | |||
) -> requests.Response: | |||
headers = kwargs.get("headers") | |||
headers = kwargs.get("headers", {}) or {} |
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.
or {}
isn't doing anything useful
cf
poetry/src/poetry/publishing/uploader.py
Line 82 in 02448cf
session.headers["User-Agent"] = self.user_agent |
create_session()
.
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.
I think or {}
covers the potential of there being a headers
key in the dict
with a None
value.
I will apply the UA to the session itself. Thank you for the suggestion.
I do agree, it took me a while to figure out that the 403 I was receiving wasn't from bad credentials or authorization but from the user agent. It seems like our repository is proxied through a nginx configuration that blocks some "bot like" user agents, as to "protect" from vulnerability scans or other bot activity. A quick |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Replaced user agent to avoid bot protection on private repositories.
For lock and install commands, the requests library was used, resulting in HTTP requests with 'python-requests' User-agent being sent.
It is possible that HTTP Servers (such as OPNSens in my case) have 'bot protection' to automatically block "bot-like" user agents.
This quick fix comes as a counter measure for the following problem.
Pull Request Check List
Resolves: No tracked issue