Skip to content

fix(client): encode and scope HTTP Basic credentials - #42

Merged
jcardozo-eth merged 2 commits into
mainfrom
fix/http-basic-auth
Sep 9, 2026
Merged

fix(client): encode and scope HTTP Basic credentials#42
jcardozo-eth merged 2 commits into
mainfrom
fix/http-basic-auth

Conversation

@jcardozo-eth

@jcardozo-eth jcardozo-eth commented Sep 9, 2026

Copy link
Copy Markdown
Member

Closes #41

Summary

Configuring Client with a username and password raised AttributeError before it could make a request because it called a removed Base64 function.

This pull request:

  • Builds HTTP Basic credentials (RFC 7617) from UTF-8 bytes with the supported Base64 API.
  • Sends the resulting Authorization header on both POST and forced-GET requests.
  • Adds the header with Request.add_unredirected_header(), so urllib does not copy credentials to automatically redirected requests.

Test plan

  • uv run pytest src/oaipmh/tests/test_client.py -k "http_basic_authentication or request_without_credentials_omits_authorization" exercises authenticated POST, forced GET, text credential encoding, redirect confinement, and unauthenticated requests.
  • uv run pytest runs the complete test suite; all 83 tests pass locally.
  • CI runs the complete suite in the repository's Python 3.10 through 3.14 Nix environments.

Checklist

  • Tests green locally (uv run pytest)
  • Python 3.10 through 3.14 test matrix green in CI

@jcardozo-eth jcardozo-eth changed the title fix(client): fix HTTP Basic authentication fix(client): encode and scope HTTP Basic credentials Sep 9, 2026
@jcardozo-eth
jcardozo-eth merged commit 35f2059 into main Sep 9, 2026
14 checks passed
@jcardozo-eth
jcardozo-eth deleted the fix/http-basic-auth branch September 9, 2026 18:20
@jcardozo-eth jcardozo-eth mentioned this pull request Sep 9, 2026
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.

Fix HTTP Basic authentication support

1 participant