Skip to content

MLE-34233 Scope credentials to configured origin - #156

Merged
jonmille merged 2 commits into
developfrom
MLE-34233
Nov 19, 2026
Merged

jonmille merged 2 commits into
developfrom
MLE-34233

Conversation

@jonmille

Copy link
Copy Markdown

Summary

Prevent the Python client from sending credentials or bearer tokens to an origin other than its configured MarkLogic host.

Changes

  • Reject cross-origin absolute and scheme-relative request URLs while allowing same-origin URLs.
  • Limit Cloud Auth token renewal and request retry to the configured origin.
  • Add regression coverage for cross-origin URLs, a cross-origin redirect returning 401, and same-origin token renewal.

Testing

  • Full suite: 126 passed, 2 skipped (Same as Jenkins Pipeline).
  • Two existing HTTPS verification warnings were reported.

User impact

Intended same-origin use is unchanged. Requests targeting another origin are now rejected, and Cloud Auth no longer retries a foreign-origin 401.

Copilot AI balanced review requested due to automatic review settings November 18, 2026 16:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Redirect handling can leak credentials across origins, and inconsistent Unicode hostname normalization blocks legitimate same-origin Cloud Auth renewal.

2 open issues
What changed in this PR

This PR adds origin checks to the MarkLogic Python client to keep credentials and bearer tokens scoped to the configured server.

Changes:

  • Adds shared origin comparison and rejects cross-origin request URLs.
  • Restricts Cloud Auth token renewal and retries to same-origin responses.
  • Adds security regression tests and a unit-test marker that skips database cleanup.
File Description
tests/​test_client_security.py Tests URL restrictions, redirect token handling, and same-origin renewal.
tests/​conftest.py Skips database cleanup for unit-marked tests.
pyproject.toml Registers the unit-test marker.
marklogic/​internal/​url.py Adds origin comparison with default-port handling.
marklogic/​cloud_auth.py Guards token renewal and retry by origin.
marklogic/​client.py Rejects cross-origin URLs during request preparation.

Review effort: Balanced

Comment thread marklogic/client.py Resolved
Comment thread marklogic/internal/url.py Resolved
@jonmille
jonmille merged commit 16b911f into develop Nov 19, 2026
4 checks passed
@jonmille
jonmille deleted the MLE-34233 branch November 19, 2026 15:34
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.

3 participants