Skip to content

Pr 12724#12898

Draft
cdrini wants to merge 7 commits into
internetarchive:masterfrom
cdrini:pr-12724
Draft

Pr 12724#12898
cdrini wants to merge 7 commits into
internetarchive:masterfrom
cdrini:pr-12724

Conversation

@cdrini

@cdrini cdrini commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Closes #

Technical

Testing

Screenshot

Stakeholders

mekarpeles and others added 7 commits May 20, 2026 17:07
The global setup_requests() approach (HTTP_PROXY env vars, no auth)
is insufficient for services that require per-service proxy credentials.

Adds get_proxy_params(service_tag) to utils.py: reads from a new
http_proxies config section (url/user/password per service) and returns
a requests-compatible proxies dict with credentials embedded in the URL,
or None to fall through to the global env var default.

Updates recaptcha to pass proxies=get_proxy_params("recaptcha") so
that service-specific proxy auth is used when configured.

Updates affiliate_server load_config to read amazon proxy settings
from http_proxies.amazon, falling back to the legacy http_proxy /
http_proxy_creds flat keys for backward compatibility.

Documents the new config section in conf/openlibrary.yml.

Closes internetarchive#12715

[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
URL-encode user and password before embedding in the proxy netloc so
special characters (@ : % etc.) don't break the URL. Also relax the
auth guard to inject credentials whenever user is set, even when
password is empty.

Adds TestGetProxyParams unit tests covering: no config → None,
unknown service → None, url-only, url+auth, and special-char encoding.

[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
OAuth2TokenManager.refresh_token() calls bare requests.post(), which
reads HTTP_PROXY from the environment.  After the per-service proxy
config lands (http_proxy = bare squid URL, http_proxies.amazon = creds),
that env var no longer carries auth → Amazon token endpoint returns 403.

Inject a _ProxyAwareTokenManager subclass into the SDK's ApiClient when
proxy_creds are present.  The subclass overrides refresh_token() to use
a requests.Session with the authenticated proxy URL embedded directly,
bypassing env-var lookup entirely.  The existing rest_client injection
(urllib3 / RESTClientObject) already handles all other API calls; this
commit covers the one OAuth path that goes through requests directly.
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.

2 participants